pge.mp3.loop(true)
green = pge.gfx.createcolor(0, 255, 0)
white = pge.gfx.createcolor(255, 255, 255)
black = pge.gfx.createcolor(0, 0, 0)
red = pge.gfx.createcolor(255, 0, 0)
blue = pge.gfx.createcolor(0, 0, 255)
yellow = pge.gfx.createcolor(255, 255, 0)

verdana12 = pge.font.load("verdana.ttf", 12)
verdana18 = pge.font.load("verdana.ttf", 18)
verdana24 = pge.font.load("verdana.ttf", 24)

intro1 = pge.texture.load("intro1.png")
languagepic = pge.texture.load("language.png")
lang_deu = pge.texture.load("lang_deu.png")
lang_eng = pge.texture.load("lang_eng.png")
pfeil = pge.texture.load("pfeil.png", PGE_VRAM)

intro_alpha = 0
hud_zoom_x = 0
hud_zoom_y = 0
x_middle = 240
y_middle = 136
cursorx = 240
cursory = 136
amodifier = 3
whichfunction = 1
lang_timer_deu = 999
lang_timer_eng = 999

function initialsetup()
hmenu = pge.texture.load("menu.png")
menu_text = pge.texture.load("menu_text.png")
menu_overlay = pge.texture.load("menu_overlay.png")
selpic = pge.texture.load("selection.png")
sp_wheel = pge.texture.load("sp_wheel.png")
sp_sign = pge.texture.load("sp_sign.png")
miss = pge.texture.load("miss.png")
army2_fade = pge.texture.load("army2_fade.png")
army3 = pge.texture.load("army3.png")
hud = pge.texture.load("hud.png")
angel = pge.texture.load("angel.png", PGE_VRAM)
devil = pge.texture.load("devil.png", PGE_VRAM)
heal = pge.texture.load("heal.png")
bow = pge.texture.load("bow.png")
sap = pge.texture.load("sap.png")
ax = pge.texture.load("ax.png")
block = pge.texture.load("block.png")
whosturn_pfeil = pge.texture.load("whosturn_pfeil.png")
levelup = pge.texture.load("levelup.png")
bar_pfeil = pge.texture.load("bar_pfeil.png")
hud_original_resized = pge.texture.load("hud_original_resized.png")
moregames = pge.texture.load("moregames.png")

score = 0
x_1 = 130
x_2 = 178
x_3 = 225
x_4 = 273
x_5 = 320
y_angel = 100
y_devil = 150
x_timer = 0
x_fade = 0
xmodifier = 0.6
army2_fade_alpha = 0
whichmenupic = 1
whichintropic = 1
whichgamepic = 1
player_hp = 100
hell_hp = 100
player_hp_color = green
hell_hp_color = green
selpicx = 81
verschieben = 0
miss_timer = 999
player_heal_timer = 999
player_bow_timer = 999
player_sap_timer = 999
player_ax_timer = 999
player_block_timer = 999
hell_heal_timer = 999
hell_bow_timer = 999
hell_sap_timer = 999
hell_ax_timer = 999
hell_block_timer = 999
whos_turn = 1
whosturn_pfeil_y = 100
delaytimer1 = 999
delaytimer2 = 999
levelup_timer = 999
player_block_active = 0
hell_block_active = 0
level = 1
hell_hp_correction = 1
bar_pfeil_x = 75 - 9
bar_pfeil_accel = 0
chance_bar_timer = 99999
swirltimer = 999
end

function renewvars()
	alpha = 0
	x_fade = 0
	xmodifier = 0.6
	army2_fade_alpha = 0
	selpicrot = 0.3
	sp_wheelrot = 0.01
end

renewvars()

function renewindvars()
	ind_alpha = 255
	ind_zoom_x = 0
	ind_zoom_y = 0
	ind_x_middle = 240
	ind_y_middle = 136
end

renewindvars()

function whosturn_pfeil_hoch()
	if whosturn_pfeil_y > 105 then
	whosturn_pfeil_y = whosturn_pfeil_y - 5
	end
end

function whosturn_pfeil_runter()
	if whosturn_pfeil_y < 155 then
	whosturn_pfeil_y = whosturn_pfeil_y + 5
	end
end

function msgsetup()
	pge.utils.msginit("Game created by Preyker\n\nThanks to:\n> Bumuckl\n> alexking\n> Shoesy\n> InsertWittyName\n> Criptych\n> FaT3oYCG")
end

credits_enabled = false

function saveinit()
	pge.utils.autosaveinit(level.."!"..score, "HVHBP0000", "Heaven VS Hell by Preyker", "Current Level & Score", "Level: "..level.."\nScore: "..score)
end

save_enabled = false
save_state = -1

function loadinit()
	pge.utils.loadinit(10, "HVHBP0000")
end

load_enabled = false
load_state = -1

function cursorf()
	pfeil:activate()
	pfeil:draweasy(cursorx, cursory, 0, alpha)
	
	if not load_enabled and not credits_enabled then
		if pge.controls.analogx() < -60 then
		cursorx = cursorx - 5
		end
		
		if pge.controls.analogx() > 60 then
		cursorx = cursorx + 5
		end
		
		if pge.controls.analogy() < -60 then
		cursory = cursory - 5
		end
		
		if pge.controls.analogy() > 60 then
		cursory = cursory + 5
		end
		
		if pge.controls.held(PGE_CTRL_LEFT) then
		cursorx = cursorx - 2
		end
		
		if pge.controls.held(PGE_CTRL_RIGHT) then
		cursorx = cursorx + 2
		end
		
		if pge.controls.held(PGE_CTRL_UP) then
		cursory = cursory - 2
		end
		
		if pge.controls.held(PGE_CTRL_DOWN) then
		cursory = cursory + 2
		end
	end
	
	if cursorx < 0 then
	cursorx = 0
	end
	
	if cursorx > 480 then
	cursorx = 480
	end
	
	if cursory < 0 then
	cursory = 0
	end
	
	if cursory > 272 then
	cursory = 272
	end
end

function chance_bar_heal()
	if level < 60 then
	
	pge.gfx.drawrect(75, 210, 190, 3, red)
	pge.gfx.drawrect(75, 214, 190, 1, red)
	pge.gfx.drawrect(75, 216, 190, 3, red)
	pge.gfx.drawrect(265, 210, 70, 3, yellow)
	pge.gfx.drawrect(265, 214, 70, 1, yellow)
	pge.gfx.drawrect(265, 216, 70, 3, yellow)
	pge.gfx.drawrect(335, 210, 20, 3, green)
	pge.gfx.drawrect(335, 214, 20, 1, green)
	pge.gfx.drawrect(335, 216, 20, 3, green)
	pge.gfx.drawrect(355, 210, 50, 3, red)
	pge.gfx.drawrect(355, 214, 50, 1, red)
	pge.gfx.drawrect(355, 216, 50, 3, red)
	
	else
	
	pge.gfx.drawrect(75, 210, 190, 3, red)
	pge.gfx.drawrect(75, 214, 190, 1, red)
	pge.gfx.drawrect(75, 216, 190, 3, red)
	pge.gfx.drawrect(265, 210, 70, 3, green)
	pge.gfx.drawrect(265, 214, 70, 1, green)
	pge.gfx.drawrect(265, 216, 70, 3, green)
	pge.gfx.drawrect(335, 210, 20, 3, green)
	pge.gfx.drawrect(335, 214, 20, 1, green)
	pge.gfx.drawrect(335, 216, 20, 3, green)
	pge.gfx.drawrect(355, 210, 50, 3, red)
	pge.gfx.drawrect(355, 214, 50, 1, red)
	pge.gfx.drawrect(355, 216, 50, 3, red)
	end
	
	if bar_pfeil_x < 405 - 9 then
	bar_pfeil_x = bar_pfeil_x + bar_pfeil_accel
	end
	
	if level < 60 then
	
	if bar_pfeil_x < 265 - 9 and pge.controls.pressed(PGE_CTRL_CROSS) then
	miss_timer = 0
	renewindvars()
	newchance()
	whos_turn = 0
	delaytimer2 = 0
	chance_bar_timer = 99999
	elseif bar_pfeil_x >= 265 - 9 and bar_pfeil_x < 345 - 9 and pge.controls.pressed(PGE_CTRL_CROSS) then
		if chance <= 0.2 then
		score = score + 25
		player_hp = player_hp + 25
		player_heal_timer = 0
		renewindvars()
		newchance()
		whos_turn = 0
		delaytimer2 = 0
		else
		miss_timer = 0
		renewindvars()
		newchance()
		whos_turn = 0
		delaytimer2 = 0
		end
		chance_bar_timer = 99999
	elseif bar_pfeil_x >= 345 - 9 and bar_pfeil_x < 365 - 9 and pge.controls.pressed(PGE_CTRL_CROSS) then
	score = score + 25
	player_hp = player_hp + 25
	player_heal_timer = 0
	renewindvars()
	newchance()
	whos_turn = 0
	delaytimer2 = 0
	chance_bar_timer = 99999
	elseif bar_pfeil_x >= 365 - 9 and bar_pfeil_x < 405 - 9 and pge.controls.pressed(PGE_CTRL_CROSS) then
	miss_timer = 0
	renewindvars()
	newchance()
	whos_turn = 0
	delaytimer2 = 0
	chance_bar_timer = 99999
	elseif bar_pfeil_x >= 395 then
	miss_timer = 0
	renewindvars()
	newchance()
	whos_turn = 0
	delaytimer2 = 0
	chance_bar_timer = 99999
	end
	
	else
	
	if bar_pfeil_x < 265 - 9 and pge.controls.pressed(PGE_CTRL_CROSS) then
	miss_timer = 0
	renewindvars()
	newchance()
	whos_turn = 0
	delaytimer2 = 0
	chance_bar_timer = 99999
	elseif bar_pfeil_x >= 265 - 9 and bar_pfeil_x < 365 - 9 and pge.controls.pressed(PGE_CTRL_CROSS) then
	score = score + 25
	player_hp = player_hp + 25
	player_heal_timer = 0
	renewindvars()
	newchance()
	whos_turn = 0
	delaytimer2 = 0
	chance_bar_timer = 99999
	elseif bar_pfeil_x >= 365 - 9 and bar_pfeil_x < 405 - 9 and pge.controls.pressed(PGE_CTRL_CROSS) then
	miss_timer = 0
	renewindvars()
	newchance()
	whos_turn = 0
	delaytimer2 = 0
	chance_bar_timer = 99999
	elseif bar_pfeil_x >= 395 then
	miss_timer = 0
	renewindvars()
	newchance()
	whos_turn = 0
	delaytimer2 = 0
	chance_bar_timer = 99999
	end
	
	end
	
	bar_pfeil_accel = bar_pfeil_accel + 0.1
end

function chance_bar_bow()
	pge.gfx.drawrect(75, 210, 190, 3, red)
	pge.gfx.drawrect(75, 214, 190, 1, red)
	pge.gfx.drawrect(75, 216, 190, 3, red)
	pge.gfx.drawrect(265, 210, 60, 3, yellow)
	pge.gfx.drawrect(265, 214, 60, 1, yellow)
	pge.gfx.drawrect(265, 216, 60, 3, yellow)
	pge.gfx.drawrect(325, 210, 30, 3, green)
	pge.gfx.drawrect(325, 214, 30, 1, green)
	pge.gfx.drawrect(325, 216, 30, 3, green)
	pge.gfx.drawrect(355, 210, 50, 3, red)
	pge.gfx.drawrect(355, 214, 50, 1, red)
	pge.gfx.drawrect(355, 216, 50, 3, red)
	
	if bar_pfeil_x < 405 - 9 then
	bar_pfeil_x = bar_pfeil_x + bar_pfeil_accel
	end
	
	if bar_pfeil_x < 265 - 9 and pge.controls.pressed(PGE_CTRL_CROSS) then
	miss_timer = 0
	renewindvars()
	newchance()
	whos_turn = 0
	delaytimer2 = 0
	chance_bar_timer = 99999
	elseif bar_pfeil_x >= 265 - 9 and bar_pfeil_x < 325 - 9 and pge.controls.pressed(PGE_CTRL_CROSS) then
		if chance <= 0.5 then
			if level < 60 then
			score = score + 30
			hell_hp = hell_hp - 30
			else
			score = score + 60
			hell_hp = hell_hp - 60
			end
		hell_bow_timer = 0
		renewindvars()
		newchance()
		whos_turn = 0
		delaytimer2 = 0
		else
		miss_timer = 0
		renewindvars()
		newchance()
		whos_turn = 0
		delaytimer2 = 0
		end
		chance_bar_timer = 99999
	elseif bar_pfeil_x >= 325 - 9 and bar_pfeil_x < 365 - 9 and pge.controls.pressed(PGE_CTRL_CROSS) then
		if level < 60 then
		score = score + 30
		hell_hp = hell_hp - 30
		else
		score = score + 60
		hell_hp = hell_hp - 60
		end
	hell_bow_timer = 0
	renewindvars()
	newchance()
	whos_turn = 0
	delaytimer2 = 0
	chance_bar_timer = 99999
	elseif bar_pfeil_x >= 365 - 9 and bar_pfeil_x < 405 - 9 and pge.controls.pressed(PGE_CTRL_CROSS) then
	miss_timer = 0
	renewindvars()
	newchance()
	whos_turn = 0
	delaytimer2 = 0
	chance_bar_timer = 99999
	elseif bar_pfeil_x >= 395 then
	miss_timer = 0
	renewindvars()
	newchance()
	whos_turn = 0
	delaytimer2 = 0
	chance_bar_timer = 99999
	end
	
	bar_pfeil_accel = bar_pfeil_accel + 0.1
end

function chance_bar_sap()
	pge.gfx.drawrect(75, 210, 100, 3, red)
	pge.gfx.drawrect(75, 214, 100, 1, red)
	pge.gfx.drawrect(75, 216, 100, 3, red)
	pge.gfx.drawrect(175, 210, 130, 3, yellow)
	pge.gfx.drawrect(175, 214, 130, 1, yellow)
	pge.gfx.drawrect(175, 216, 130, 3, yellow)
	pge.gfx.drawrect(305, 210, 50, 3, green)
	pge.gfx.drawrect(305, 214, 50, 1, green)
	pge.gfx.drawrect(305, 216, 50, 3, green)
	pge.gfx.drawrect(355, 210, 50, 3, red)
	pge.gfx.drawrect(355, 214, 50, 1, red)
	pge.gfx.drawrect(355, 216, 50, 3, red)
	
	if bar_pfeil_x < 405 - 9 then
	bar_pfeil_x = bar_pfeil_x + bar_pfeil_accel
	end
	
	if bar_pfeil_x < 175 - 9 and pge.controls.pressed(PGE_CTRL_CROSS) then
	miss_timer = 0
	renewindvars()
	newchance()
	whos_turn = 0
	delaytimer2 = 0
	chance_bar_timer = 99999
	elseif bar_pfeil_x >= 175 - 9 and bar_pfeil_x < 305 - 9 and pge.controls.pressed(PGE_CTRL_CROSS) then
		if chance <= 0.9 then
			if level < 60 then
			score = score + 5
			hell_hp = hell_hp - 5
			else
			score = score + 10
			hell_hp = hell_hp - 10
			end
		hell_sap_timer = 0
		renewindvars()
		newchance()
		whos_turn = 0
		delaytimer2 = 0
		else
		miss_timer = 0
		renewindvars()
		newchance()
		whos_turn = 0
		delaytimer2 = 0
		end
		chance_bar_timer = 99999
	elseif bar_pfeil_x >= 305 - 9 and bar_pfeil_x < 355 - 9 and pge.controls.pressed(PGE_CTRL_CROSS) then
		if level < 60 then
		score = score + 5
		hell_hp = hell_hp - 5
		else
		score = score + 10
		hell_hp = hell_hp - 10
		end
	hell_sap_timer = 0
	renewindvars()
	newchance()
	whos_turn = 0
	delaytimer2 = 0
	chance_bar_timer = 99999
	elseif bar_pfeil_x >= 355 - 9 and bar_pfeil_x < 405 - 9 and pge.controls.pressed(PGE_CTRL_CROSS) then
	miss_timer = 0
	renewindvars()
	newchance()
	whos_turn = 0
	delaytimer2 = 0
	chance_bar_timer = 99999
	elseif bar_pfeil_x >= 395 then
	miss_timer = 0
	renewindvars()
	newchance()
	whos_turn = 0
	delaytimer2 = 0
	chance_bar_timer = 99999
	end
	
	bar_pfeil_accel = bar_pfeil_accel + 0.1
end

function chance_bar_ax()
	pge.gfx.drawrect(75, 210, 190, 3, red)
	pge.gfx.drawrect(75, 214, 190, 1, red)
	pge.gfx.drawrect(75, 216, 190, 3, red)
	pge.gfx.drawrect(265, 210, 70, 3, yellow)
	pge.gfx.drawrect(265, 214, 70, 1, yellow)
	pge.gfx.drawrect(265, 216, 70, 3, yellow)
	pge.gfx.drawrect(335, 210, 20, 3, green)
	pge.gfx.drawrect(335, 214, 20, 1, green)
	pge.gfx.drawrect(335, 216, 20, 3, green)
	pge.gfx.drawrect(355, 210, 50, 3, red)
	pge.gfx.drawrect(355, 214, 50, 1, red)
	pge.gfx.drawrect(355, 216, 50, 3, red)
	
	if bar_pfeil_x < 405 - 9 then
	bar_pfeil_x = bar_pfeil_x + bar_pfeil_accel
	end
	
	if bar_pfeil_x < 265 - 9 and pge.controls.pressed(PGE_CTRL_CROSS) then
	miss_timer = 0
	renewindvars()
	newchance()
	whos_turn = 0
	delaytimer2 = 0
	chance_bar_timer = 99999
	elseif bar_pfeil_x >= 265 - 9 and bar_pfeil_x < 345 - 9 and pge.controls.pressed(PGE_CTRL_CROSS) then
		if chance <= 0.3 then
			if level < 60 then
			score = score + 40
			hell_hp = hell_hp - 40
			else
			score = score + 80
			hell_hp = hell_hp - 80
			end
		hell_ax_timer = 0
		renewindvars()
		newchance()
		whos_turn = 0
		delaytimer2 = 0
		else
		miss_timer = 0
		renewindvars()
		newchance()
		whos_turn = 0
		delaytimer2 = 0
		end
		chance_bar_timer = 99999
	elseif bar_pfeil_x >= 345 - 9 and bar_pfeil_x < 365 - 9 and pge.controls.pressed(PGE_CTRL_CROSS) then
		if level < 60 then
		score = score + 40
		hell_hp = hell_hp - 40
		else
		score = score + 80
		hell_hp = hell_hp - 80
		end
	hell_ax_timer = 0
	renewindvars()
	newchance()
	whos_turn = 0
	delaytimer2 = 0
	chance_bar_timer = 99999
	elseif bar_pfeil_x >= 365 - 9 and bar_pfeil_x < 405 - 9 and pge.controls.pressed(PGE_CTRL_CROSS) then
	miss_timer = 0
	renewindvars()
	newchance()
	whos_turn = 0
	delaytimer2 = 0
	chance_bar_timer = 99999
	elseif bar_pfeil_x >= 395 then
	miss_timer = 0
	renewindvars()
	newchance()
	whos_turn = 0
	delaytimer2 = 0
	chance_bar_timer = 99999
	end
	
	bar_pfeil_accel = bar_pfeil_accel + 0.1
end

function resetpokevars()
poke_height1 = 0
poke_length1 = 0
poke_height2 = 0
poke_length2 = 0
poke_height3 = 0
poke_length3 = 0
poke_height4 = 0
poke_length4 = 0
poke_height5 = 0
poke_length5 = 0
poke_height6 = 0
poke_length6 = 0
poke_height7 = 0
poke_length7 = 0
poke_height8 = 0
poke_length8 = 0
poke_height9 = 0
poke_length9 = 0
poke_height10 = 0
poke_length10 = 0
end

resetpokevars()

function pokemonswirl()
	pge.gfx.drawrect(0, 0, 50, poke_height1, black)
	pge.gfx.drawrect(0, 222, poke_length1, 50, black)
	pge.gfx.drawrect(430, 222, 50, poke_height2, black)
	pge.gfx.drawrect(430, 0, poke_length2, 50, black)
	pge.gfx.drawrect(50, 50, 50, poke_height3, black)
	pge.gfx.drawrect(50, 172, poke_length3, 50, black)
	pge.gfx.drawrect(380, 172, 50, poke_height4, black)
	pge.gfx.drawrect(380, 50, poke_length4, 50, black)
	pge.gfx.drawrect(100, 100, 50, poke_height5, black)
	pge.gfx.drawrect(100, 122, poke_length5, 50, black)
	pge.gfx.drawrect(330, 122, 50, poke_height6, black)
	pge.gfx.drawrect(330, 72, poke_length6, 50, black)
	
	if poke_height1 < 272 then
	poke_height1 = poke_height1 + 50
	elseif poke_height1 > 272 then
	poke_height1 = 272
	end
	
	if poke_height1 == 272 then
		if poke_length1 < 480 then
		poke_length1 = poke_length1 + 50
		elseif poke_length1 > 480 then
		poke_length1 = 480
		end
	end
	
	if poke_length1 == 480 then
		if poke_height2 > -272 then
		poke_height2 = poke_height2 - 50
		elseif poke_height2 < -272 then
		poke_height2 = -272
		end
	end
	
	if poke_height2 == -272 then
		if poke_length2 > -480 then
		poke_length2 = poke_length2 - 50
		elseif poke_length2 < -480 then
		poke_length2 = -480
		end
	end
	
	if poke_length2 == -480 then
		if poke_height3 < 222 then
		poke_height3 = poke_height3 + 50
		elseif poke_height3 > 222 then
		poke_height3 = 222
		end
	end
	
	if poke_height3 == 222 then
		if poke_length3 < 430 then
		poke_length3 = poke_length3 + 50
		elseif poke_length3 > 430 then
		poke_length3 = 430
		end
	end
	
	if poke_length3 == 430 then
		if poke_height4 > -222 then
		poke_height4 = poke_height4 - 50
		elseif poke_height4 < -222 then
		poke_height4 = -222
		end
	end
	
	if poke_height4 == -222 then
		if poke_length4 > -430 then
		poke_length4 = poke_length4 - 50
		elseif poke_length4 < -430 then
		poke_length4 = -430
		end
	end
	
	if poke_length4 == -430 then
		if poke_height5 < 172 then
		poke_height5 = poke_height5 + 50
		elseif poke_height5 > 172 then
		poke_height5 = 172
		end
	end
	
	if poke_height5 == 172 then
		if poke_length5 < 380 then
		poke_length5 = poke_length5 + 50
		elseif poke_length5 > 380 then
		poke_length5 = 380
		end
	end
	
	if poke_length5 == 380 then
		if poke_height6 > -172 then
		poke_height6 = poke_height6 - 50
		elseif poke_height6 < -172 then
		poke_height6 = -172
		end
	end
	
	if poke_height6 == -172 then
		if poke_length6 > -380 then
		poke_length6 = poke_length6 - 50
		elseif poke_length6 < -380 then
		poke_length6 = -380
		end
	end
end

function intro1f()
	intro1:activate()
	intro1:draweasy(0, 0, 0, intro_alpha)
	
	intro_alpha = intro_alpha + amodifier
	
	if intro_alpha >= 600 then
	amodifier = -3
	end
	
	if intro_alpha <= 1 then
	intro1 = nil
	intro_alpha = nil
	amodifier = nil
	collectgarbage()
	collectgarbage()
	collectgarbage()
	whichfunction = 2
	end
	
	if pge.controls.pressed(PGE_CTRL_CROSS) then
	intro1 = nil
	intro_alpha = nil
	amodifier = nil
	collectgarbage()
	collectgarbage()
	collectgarbage()
	whichfunction = 2
	end	
end

ind_zoom_x = 100
ind_zoom_y = 67

function languagef()
	languagepic:activate()
	languagepic:draweasy(0, 0, 0, alpha)
	
	if alpha < 255 then
	alpha = alpha + 5
	end
	
	if lang_timer_deu < 25 then
	verdana24:activate()
	verdana24:print(200, 220, black, "LADEN")
	
	lang_timer_deu = lang_timer_deu + 1
	
	lang_deu:activate()
	lang_deu:draw(ind_x_middle - 120, ind_y_middle - 11, ind_zoom_x, ind_zoom_y, 0, 0, 100, 67, 0, ind_alpha)
	
		if ind_zoom_x < 200 then
		ind_zoom_x = ind_zoom_x + 4
		ind_x_middle = ind_x_middle - 2
		end
		
		if ind_zoom_x > 200 then
		ind_zoom_x = 200
		ind_x_middle = 0
		end
		
		if ind_zoom_y < 200 then
		ind_zoom_y = ind_zoom_y + 2.7
		ind_y_middle = ind_y_middle - 1.35
		end
		
		if ind_zoom_y > 200 then
		ind_zoom_y = 200
		ind_y_middle = 0
		end
	
		if ind_alpha <= 0 then
		ind_alpha = 255
		end
		
	ind_alpha = ind_alpha - 11
	elseif lang_timer_deu == 25 then
	languagepic = nil
	lang_deu = nil
	lang_eng = nil
	collectgarbage()
	collectgarbage()
	collectgarbage()
	initialsetup()
	gameoverpic = pge.texture.load("gameover_deu.png")
	helppic = pge.texture.load("help_deu.png")
	helppic2 = pge.texture.load("help2_deu.png")
	satan = pge.texture.load("satan_deu.png")
	michael = pge.texture.load("michael_deu.png")
	army1 = pge.texture.load("army1_deu.png")
	army2 = pge.texture.load("army2_deu.png")
	keanu = pge.texture.load("keanu_deu.png")
	con_or_new = pge.texture.load("con_or_new_deu.png")
	pge.mp3.play("menu_song.mp3")
	renewvars()
	renewindvars()
	whichfunction = 3
	end
	
	if lang_timer_eng < 25 then
	verdana24:activate()
	verdana24:print(185, 220, black, "LOADING")
	
	lang_timer_eng = lang_timer_eng + 1
	
	lang_eng:activate()
	lang_eng:draw(ind_x_middle + 20, ind_y_middle - 11, ind_zoom_x, ind_zoom_y, 0, 0, 100, 67, 0, ind_alpha)
	
		if ind_zoom_x < 200 then
		ind_zoom_x = ind_zoom_x + 4
		ind_x_middle = ind_x_middle - 2
		end
		
		if ind_zoom_x > 200 then
		ind_zoom_x = 200
		ind_x_middle = 0
		end
		
		if ind_zoom_y < 200 then
		ind_zoom_y = ind_zoom_y + 2.7
		ind_y_middle = ind_y_middle - 1.35
		end
		
		if ind_zoom_y > 200 then
		ind_zoom_y = 200
		ind_y_middle = 0
		end
	
		if ind_alpha <= 0 then
		ind_alpha = 255
		end
		
	ind_alpha = ind_alpha - 11
	elseif lang_timer_eng == 25 then
	languagepic = nil
	lang_deu = nil
	lang_eng = nil
	collectgarbage()
	collectgarbage()
	collectgarbage()
	initialsetup()
	gameoverpic = pge.texture.load("gameover.png")
	helppic = pge.texture.load("help.png")
	helppic2 = pge.texture.load("help2.png")
	satan = pge.texture.load("satan.png")
	michael = pge.texture.load("michael.png")
	army1 = pge.texture.load("army1.png")
	army2 = pge.texture.load("army2.png")
	keanu = pge.texture.load("keanu.png")
	con_or_new = pge.texture.load("con_or_new.png")
	pge.mp3.play("menu_song.mp3")
	renewvars()
	renewindvars()
	whichfunction = 3
	end
	
	if cursorx >= 120 and cursorx <= 219 and cursory >= 125 and cursory <= 191 and pge.controls.pressed(PGE_CTRL_CROSS) then
	lang_timer_deu = 0
	elseif cursorx >= 260 and cursorx <= 359 and cursory >= 125 and cursory <= 191 and pge.controls.pressed(PGE_CTRL_CROSS) then
	lang_timer_eng = 0
	end
end

pge.math.srand(os.time()*3.141)

function newchance()
	chance = pge.math.randfloat(0, 1)
	chance = pge.math.randfloat(0, 1)
	chance = pge.math.randfloat(0, 1)
	chance = pge.math.randfloat(0, 1)
	chance = pge.math.randfloat(0, 1)
end

newchance()

function newhellchance()
	hellchance = pge.math.randfloat(0, 1)
	hellchance = pge.math.randfloat(0, 1)
	hellchance = pge.math.randfloat(0, 1)
	hellchance = pge.math.randfloat(0, 1)
	hellchance = pge.math.randfloat(0, 1)
end

newhellchance()

function menu()
	if alpha < 255 then
	alpha = alpha + 5
	end
	
	if whichmenupic == 1 then
	hmenu:activate()
	hmenu:draw(x_middle, y_middle, hud_zoom_x, hud_zoom_y, 0, 0, 480, 272, 0, alpha)
	
	if hud_zoom_x < 480 then
	hud_zoom_x = hud_zoom_x + 20
	x_middle = x_middle - 10
	end
	
	if hud_zoom_x > 480 then
	hud_zoom_x = 480
	x_middle = 0
	end
	
	if hud_zoom_y < 270 then
	hud_zoom_y = hud_zoom_y + 10
	y_middle = y_middle - 5
	end
	
	if hud_zoom_y == 270 then
	hud_zoom_y = 272
	y_middle = 0
	end
	
	selpic:activate()
	selpic:draweasy(430, 230, selpicrot, alpha)
	
	selpicrot = selpicrot + 0.3
	
	menu_text:activate()
	menu_text:draw(x_middle, y_middle, hud_zoom_x, hud_zoom_y, 0, 0, 480, 272, 0, alpha)
	
	menu_overlay:activate()
	menu_overlay:draw(x_middle, y_middle, hud_zoom_x, hud_zoom_y, 0, 0, 480, 272, 0, alpha)
	
	sp_wheel:activate()
	sp_wheel:draweasy(380, -100, sp_wheelrot, alpha)
	
	sp_wheelrot = sp_wheelrot + 0.01
	
	sp_sign:activate()
	sp_sign:draweasy(5, 5, 0, alpha)
	
	if cursorx >= 150 and cursorx <= 300 and cursory >= 80 and cursory <= 110 and pge.controls.pressed(PGE_CTRL_CROSS) then
	renewvars()
	whichmenupic = 4
	end
	
	if cursorx >= 150 and cursorx <= 300 and cursory >= 115 and cursory <= 145 and pge.controls.pressed(PGE_CTRL_CROSS) then
	renewvars()
	whichmenupic = 2
	end
	
	if cursorx >= 150 and cursorx <= 300 and cursory >= 150 and cursory <= 180 and pge.controls.pressed(PGE_CTRL_CROSS) then
	msgsetup()
	credits_enabled = true
	end
	
	if cursorx >= 343 and cursorx <= 432 and cursory >= 98 and cursory <= 187 and pge.controls.pressed(PGE_CTRL_CROSS) then
	--Bonus
	renewvars()
	whichmenupic = 6
	end
	
	elseif whichmenupic == 2 then
	helppic:activate()
	helppic:draweasy(0, 0, 0, alpha)
	
	if cursorx >= 10 and cursorx <= 43 and cursory >= 227 and cursory <= 262 and pge.controls.pressed(PGE_CTRL_CROSS) then
	renewvars()
	whichmenupic = 1
	end
	
	if cursorx >= 437 and cursorx <= 470 and cursory >= 227 and cursory <= 262 and pge.controls.pressed(PGE_CTRL_CROSS) then
	renewvars()
	whichmenupic = 3
	end
	
	elseif whichmenupic == 3 then
	helppic2:activate()
	helppic2:draweasy(0, 0, 0, alpha)
	
	if cursorx >= 437 and cursorx <= 470 and cursory >= 227 and cursory <= 262 and pge.controls.pressed(PGE_CTRL_CROSS) then
	renewvars()
	whichmenupic = 1
	end
	
	if cursorx >= 10 and cursorx <= 43 and cursory >= 227 and cursory <= 262 and pge.controls.pressed(PGE_CTRL_CROSS) then
	renewvars()
	whichmenupic = 2
	end
	
	elseif whichmenupic == 4 then
	con_or_new:activate()
	con_or_new:draweasy(0, 0, 0, alpha)
	
	if cursorx >= 150 and cursorx <= 322 and cursory >= 88 and cursory <= 111 and pge.controls.pressed(PGE_CTRL_CROSS) then
	selpicx = 81
	verschieben = 0
	miss_timer = 999
	player_heal_timer = 999
	player_bow_timer = 999
	player_sap_timer = 999
	player_ax_timer = 999
	player_block_timer = 999
	hell_heal_timer = 999
	hell_bow_timer = 999
	hell_sap_timer = 999
	hell_ax_timer = 999
	hell_block_timer = 999
	whos_turn = 1
	whosturn_pfeil_y = 100
	delaytimer1 = 999
	delaytimer2 = 999
	levelup_timer = 999
	player_hp = 100
	hell_hp = 100
	army2_fade_alpha = 0
	loadinit()
	load_enabled = true
	renewvars()
	renewindvars()
	pge.mp3.stop()
	whichmenupic = 1
	whichintropic = 1
	whichfunction = 5
	end
	
	if cursorx >= 150 and cursorx <= 322 and cursory >= 132 and cursory <= 155 and pge.controls.pressed(PGE_CTRL_CROSS) then
	selpicx = 81
	verschieben = 0
	miss_timer = 999
	player_heal_timer = 999
	player_bow_timer = 999
	player_sap_timer = 999
	player_ax_timer = 999
	player_block_timer = 999
	hell_heal_timer = 999
	hell_bow_timer = 999
	hell_sap_timer = 999
	hell_ax_timer = 999
	hell_block_timer = 999
	whos_turn = 1
	whosturn_pfeil_y = 100
	delaytimer1 = 999
	delaytimer2 = 999
	levelup_timer = 999
	player_hp = 100
	hell_hp = 100
	army2_fade_alpha = 0
	level = 1
	score = 0
	renewvars()
	renewindvars()
	pge.mp3.stop()
	pge.mp3.play("intro_song.mp3")
	whichmenupic = 1
	whichintropic = 1
	whichfunction = 4
	end
	
	if cursorx >= 10 and cursorx <= 43 and cursory >= 227 and cursory <= 262 and pge.controls.pressed(PGE_CTRL_CROSS) then
	renewvars()
	whichmenupic = 1
	end
	
	elseif whichmenupic == 6 then
	hud_original_resized:activate()
	hud_original_resized:draweasy(0, 0, 0, alpha)
	
		if cursorx >= 10 and cursorx <= 43 and cursory >= 227 and cursory <= 262 and pge.controls.pressed(PGE_CTRL_CROSS) then
		renewvars()
		whichmenupic = 1
		end
	end
end

function game_intro()
	if whichintropic == 1 then
	satan:activate()
	satan:draweasy(0, 0, 0, alpha)
	
	if alpha < 255 then
	alpha = alpha + 5
	end
	
	if cursorx >= 437 and cursorx <= 470 and cursory >= 227 and cursory <= 262 and pge.controls.pressed(PGE_CTRL_CROSS) then
	renewvars()
	whichintropic = 2
	end
	
	elseif whichintropic == 2 then
	michael:activate()
	michael:draweasy(0, 0, 0, alpha)
	
	if alpha < 255 then
	alpha = alpha + 5
	end
	
	if cursorx >= 437 and cursorx <= 470 and cursory >= 227 and cursory <= 262 and pge.controls.pressed(PGE_CTRL_CROSS) then
	renewvars()
	whichintropic = 3
	end
	
	elseif whichintropic == 3 then
	army1:activate()
	army1:draweasy(0, 0, 0, alpha)
	
	if alpha < 255 then
	alpha = alpha + 5
	end
	
	if cursorx >= 437 and cursorx <= 470 and cursory >= 227 and cursory <= 262 and pge.controls.pressed(PGE_CTRL_CROSS) then
	renewvars()
	whichintropic = 4
	end
	
	elseif whichintropic == 4 then
	army2:activate()
	army2:draweasy(0, 0, 0, alpha)
	
	if alpha < 255 then
	alpha = alpha + 5
	end
	
	if cursorx >= 437 and cursorx <= 470 and cursory >= 227 and cursory <= 262 and pge.controls.pressed(PGE_CTRL_CROSS) then
	renewvars()
	whichintropic = 5
	end
	
	elseif whichintropic == 5 then
	army3:activate()
	army3:draweasy(0, 0, 0, alpha)
	
	if alpha < 255 then
	alpha = alpha + 5
	end
	
	if cursorx >= 437 and cursorx <= 470 and cursory >= 227 and cursory <= 262 and pge.controls.pressed(PGE_CTRL_CROSS) then
	pge.mp3.stop()
	pge.mp3.play("game_song.mp3")
	renewvars()
	whichintropic = 1
	whichfunction = 5
	end
	end
end

function game()
	army2_fade:activate()
	army2_fade:draweasy(x_fade, 0, 0.0001, army2_fade_alpha)
	
	if army2_fade_alpha < 60 then
	army2_fade_alpha = army2_fade_alpha + 1
	end
	
	if not load_enabled then
		if alpha < 255 then
		alpha = alpha + 5
		end
	
		if alpha >= 255 then
			if x_fade >= 70 then
			xmodifier = 0.3
			elseif x_fade <= -70 then
			xmodifier = -0.3
			end
		end
	
		x_fade = x_fade - xmodifier
	end
	
	hud:activate()
	hud:draweasy(0, 0, 0, alpha)
	
	if not load_enabled then
	if score < 10000 then
	verdana24:activate()
	verdana24:print(326, 238, blue, score)
	verdana24:print(325, 237, blue, score)
	verdana24:print(324, 236, blue, score)
	else
	verdana18:activate()
	verdana18:print(326, 241, blue, score)
	verdana18:print(325, 240, blue, score)
	verdana18:print(324, 239, blue, score)
	end
	end
	
	if chance_bar_timer < 99999 then
	
	bar_pfeil:activate()
	bar_pfeil:draweasy(bar_pfeil_x, 219, 0.000000000000000000000000000000000001)
	
	pge.gfx.drawrectoutline(74, 209, 331, 10, white)
	
		if verschieben == 1 then
		chance_bar_heal()
		elseif verschieben == 2 then
		chance_bar_bow()
		elseif verschieben == 3 then
		chance_bar_sap()
		elseif verschieben == 4 then
		chance_bar_ax()
		end
	end
	
	if pge.controls.pressed(PGE_CTRL_LTRIGGER) then
	score = score + 100
	end
	
	selpicrot = selpicrot + 0.3
	selpic:activate()
	selpic:draweasy(selpicx, 233, selpicrot, alpha)
	
	troopsf()
	
	if not load_enabled then
		if pge.controls.pressed(PGE_CTRL_SELECT) or pge.controls.pressed(PGE_CTRL_START) then
		hell_block_active = 0
		pge.mp3.stop()
		pge.mp3.play("menu_song.mp3")
		renewvars()
		renewindvars()
		whichfunction = 3
		end
	end
	
	whosturn_pfeil:activate()
	whosturn_pfeil:draweasy(355, whosturn_pfeil_y, 0, alpha)
	
	if whos_turn == 1 then
		if cursorx >= 75 and cursorx <= 117 and cursory >= 227 and cursory <= 269 and pge.controls.pressed(PGE_CTRL_CROSS) then
		verschieben = 1
		if hell_block_active == 1 then
		hell_block_active = 0
		end
		chance_bar_timer = 0
		bar_pfeil_accel = 0
		bar_pfeil_x = 75 - 9
		newchance()
		end
		
		if cursorx >= 123 and cursorx <= 165 and cursory >= 227 and cursory <= 269 and pge.controls.pressed(PGE_CTRL_CROSS) then
		verschieben = 2
		if hell_block_active == 0 then
		chance_bar_timer = 0
		bar_pfeil_accel = 0
		bar_pfeil_x = 75 - 9
		else
		hell_block_active = 0
		miss_timer = 0
		renewindvars()
		newchance()
		whos_turn = 0
		delaytimer2 = 0
		end
		end
		
		if cursorx >= 171 and cursorx <= 213 and cursory >= 227 and cursory <= 269 and pge.controls.pressed(PGE_CTRL_CROSS) then
		verschieben = 3
		if hell_block_active == 0 then
		chance_bar_timer = 0
		bar_pfeil_accel = 0
		bar_pfeil_x = 75 - 9
		else
		hell_block_active = 0
		miss_timer = 0
		renewindvars()
		newchance()
		whos_turn = 0
		delaytimer2 = 0
		end
		end
		
		if cursorx >= 219 and cursorx <= 261 and cursory >= 227 and cursory <= 269 and pge.controls.pressed(PGE_CTRL_CROSS) then
		verschieben = 4
		if hell_block_active == 0 then
		chance_bar_timer = 0
		bar_pfeil_accel = 0
		bar_pfeil_x = 75 - 9
		else
		hell_block_active = 0
		miss_timer = 0
		renewindvars()
		newchance()
		whos_turn = 0
		delaytimer2 = 0
		end
		end
		
		if cursorx >= 267 and cursorx <= 309 and cursory >= 227 and cursory <= 269 and pge.controls.pressed(PGE_CTRL_CROSS) then
		verschieben = 5
		if hell_block_active == 1 then
		hell_block_active = 0
		end
		player_hp = player_hp - 5
		player_block_timer = 0
		player_block_active = 1
		renewindvars()
		newchance()
		whos_turn = 0
		delaytimer2 = 0
		end
	end
	
	if whos_turn == 2 then
		if hellchance <= 0.2 then
		if hell_hp < 80 then
		verschieben = 1
		if player_block_active == 1 then
		player_block_active = 0
		end
		hell_hp = hell_hp + 25
		hell_heal_timer = 0
		renewindvars()
		end
		whos_turn = 0
		delaytimer1 = 0
		else
		newhellchance()
		end
		
		if hellchance > 0.2 and hellchance <= 0.4 then
		if player_hp > 5 then
		verschieben = 2
		if player_block_active == 0 then
		player_hp = player_hp - 30
		player_bow_timer = 0
		renewindvars()
		else
		player_block_active = 0
		miss_timer = 0
		renewindvars()
		end
		whos_turn = 0
		delaytimer1 = 0
		else
		newhellchance()
		end
		end
		
		if hellchance > 0.4 and hellchance <= 0.6 then
		verschieben = 3
		if player_block_active == 0 then
		player_hp = player_hp - 5
		player_sap_timer = 0
		renewindvars()
		else
		player_block_active = 0
		miss_timer = 0
		renewindvars()
		end
		whos_turn = 0
		delaytimer1 = 0
		end
		
		if hellchance > 0.6 and hellchance <= 0.8 then
		if player_hp > 30 then
		verschieben = 4
		if player_block_active == 0 then
		player_hp = player_hp - 40
		player_ax_timer = 0
		renewindvars()
		else
		player_block_active = 0
		miss_timer = 0
		renewindvars()
		end
		whos_turn = 0
		delaytimer1 = 0
		else
		newhellchance()
		end
		end
		
		if hellchance > 0.8 then
		if hell_hp > 5 then
		verschieben = 5
		if player_block_active == 1 then
		player_block_active = 0
		end
		hell_hp = hell_hp - 5
		hell_block_timer = 0
		hell_block_active = 1
		renewindvars()
		whos_turn = 0
		delaytimer1 = 0
		else
		newhellchance()
		end
		end
		
		newhellchance()
	end
	
	if delaytimer1 < 110 then
	delaytimer1 = delaytimer1 + 1
	if delaytimer1 >= 100 then
	whosturn_pfeil_hoch()
	end
	elseif delaytimer1 == 110 then
	whos_turn = 1
	delaytimer1 = delaytimer1 + 1
	end
	
	if delaytimer2 < 110 then
	delaytimer2 = delaytimer2 + 1
	if delaytimer2 >= 100 then
	whosturn_pfeil_runter()
	end
	elseif delaytimer2 == 110 then
	whos_turn = 2
	delaytimer2 = delaytimer2 + 1
	end
	
	if miss_timer < 30 then
	miss_timer = miss_timer + 1
	miss:activate()
	miss:draw(ind_x_middle, ind_y_middle, ind_zoom_x, ind_zoom_y, 0, 0, 480, 272, 0, 255)
	
		if ind_zoom_x < 480 then
		ind_zoom_x = ind_zoom_x + 40
		ind_x_middle = ind_x_middle - 20
		end
		
		if ind_zoom_x > 480 then
		ind_zoom_x = 480
		ind_x_middle = 0
		end
		
		if ind_zoom_y < 270 then
		ind_zoom_y = ind_zoom_y + 20
		ind_y_middle = ind_y_middle - 10
		end
		
		if ind_zoom_y == 270 then
		ind_zoom_y = 272
		ind_y_middle = 0
		end
	end
	
	if miss_timer >= 30 and miss_timer < 60 then
	miss_timer = miss_timer + 1
	miss:activate()
	miss:draw(ind_x_middle, ind_y_middle, ind_zoom_x, ind_zoom_y, 0, 0, 480, 272, 0, ind_alpha)
	
		if ind_zoom_x < 960 then
		ind_zoom_x = ind_zoom_x + 20
		ind_x_middle = ind_x_middle - 10
		end
		
		if ind_zoom_x > 960 then
		ind_zoom_x = 960
		ind_x_middle = 0
		end
		
		if ind_zoom_y < 540 then
		ind_zoom_y = ind_zoom_y + 10
		ind_y_middle = ind_y_middle - 5
		end
		
		if ind_zoom_y > 540 then
		ind_zoom_y = 540
		ind_y_middle = 0
		end
	
	ind_alpha = ind_alpha - 9
	end
	
	if levelup_timer < 30 then
	levelup_timer = levelup_timer + 1
	levelup:activate()
	levelup:draw(ind_x_middle, ind_y_middle, ind_zoom_x, ind_zoom_y, 0, 0, 480, 272, 0, 255)
	
		if ind_zoom_x < 480 then
		ind_zoom_x = ind_zoom_x + 40
		ind_x_middle = ind_x_middle - 20
		end
		
		if ind_zoom_x > 480 then
		ind_zoom_x = 480
		ind_x_middle = 0
		end
		
		if ind_zoom_y < 270 then
		ind_zoom_y = ind_zoom_y + 20
		ind_y_middle = ind_y_middle - 10
		end
		
		if ind_zoom_y == 270 then
		ind_zoom_y = 272
		ind_y_middle = 0
		end
	end
	
	if levelup_timer >= 30 and levelup_timer < 60 then
	levelup_timer = levelup_timer + 1
	levelup:activate()
	levelup:draw(ind_x_middle, ind_y_middle, ind_zoom_x, ind_zoom_y, 0, 0, 480, 272, 0, ind_alpha)
	
		pge.delay(4000)
		
		if ind_zoom_x < 960 then
		ind_zoom_x = ind_zoom_x + 20
		ind_x_middle = ind_x_middle - 10
		end
		
		pge.delay(4000)
		
		if ind_zoom_x > 960 then
		ind_zoom_x = 960
		ind_x_middle = 0
		end
		
		pge.delay(4000)
		
		if ind_zoom_y < 540 then
		ind_zoom_y = ind_zoom_y + 10
		ind_y_middle = ind_y_middle - 5
		end
		
		pge.delay(4000)
		
		if ind_zoom_y > 540 then
		ind_zoom_y = 540
		ind_y_middle = 0
		end
	
	ind_alpha = ind_alpha - 9
	end
	
	if player_heal_timer < 100 then
	player_heal_timer = player_heal_timer + 1
	heal:activate()
	heal:draweasy(90, 100)
	heal:draw(ind_x_middle - 135, ind_y_middle - 21, ind_zoom_x, ind_zoom_y, 0, 0, 30, 30, 0, ind_alpha)
	
		if ind_zoom_x < 60 then
		ind_zoom_x = ind_zoom_x + 1.25
		ind_x_middle = ind_x_middle - 0.625
		end
		
		if ind_zoom_x >= 60 then
		ind_zoom_x = 0
		ind_x_middle = 240
		end
		
		if ind_zoom_y < 60 then
		ind_zoom_y = ind_zoom_y + 1.25
		ind_y_middle = ind_y_middle - 0.625
		end
		
		if ind_zoom_y >= 60 then
		ind_zoom_y = 0
		ind_y_middle = 136
		end
	
		if ind_alpha <= 0 then
		ind_alpha = 255
		end
		
	ind_alpha = ind_alpha - 5
	end
	
	if player_bow_timer < 100 then
	player_bow_timer = player_bow_timer + 1
	bow:activate()
	bow:draweasy(90, 100)
	bow:draw(ind_x_middle - 135, ind_y_middle - 21, ind_zoom_x, ind_zoom_y, 0, 0, 30, 30, 0, ind_alpha)
	
		if ind_zoom_x < 60 then
		ind_zoom_x = ind_zoom_x + 1.25
		ind_x_middle = ind_x_middle - 0.625
		end
		
		if ind_zoom_x >= 60 then
		ind_zoom_x = 0
		ind_x_middle = 240
		end
		
		if ind_zoom_y < 60 then
		ind_zoom_y = ind_zoom_y + 1.25
		ind_y_middle = ind_y_middle - 0.625
		end
		
		if ind_zoom_y >= 60 then
		ind_zoom_y = 0
		ind_y_middle = 136
		end
	
		if ind_alpha <= 0 then
		ind_alpha = 255
		end
		
	ind_alpha = ind_alpha - 5
	end
	
	if player_sap_timer < 100 then
	player_sap_timer = player_sap_timer + 1
	sap:activate()
	sap:draweasy(90, 100)
	sap:draw(ind_x_middle - 135, ind_y_middle - 21, ind_zoom_x, ind_zoom_y, 0, 0, 30, 30, 0, ind_alpha)
	
		if ind_zoom_x < 60 then
		ind_zoom_x = ind_zoom_x + 1.25
		ind_x_middle = ind_x_middle - 0.625
		end
		
		if ind_zoom_x >= 60 then
		ind_zoom_x = 0
		ind_x_middle = 240
		end
		
		if ind_zoom_y < 60 then
		ind_zoom_y = ind_zoom_y + 1.25
		ind_y_middle = ind_y_middle - 0.625
		end
		
		if ind_zoom_y >= 60 then
		ind_zoom_y = 0
		ind_y_middle = 136
		end
	
		if ind_alpha <= 0 then
		ind_alpha = 255
		end
		
	ind_alpha = ind_alpha - 5
	end
	
	if player_ax_timer < 100 then
	player_ax_timer = player_ax_timer + 1
	ax:activate()
	ax:draweasy(90, 100)
	ax:draw(ind_x_middle - 135, ind_y_middle - 21, ind_zoom_x, ind_zoom_y, 0, 0, 30, 30, 0, ind_alpha)
	
		if ind_zoom_x < 60 then
		ind_zoom_x = ind_zoom_x + 1.25
		ind_x_middle = ind_x_middle - 0.625
		end
		
		if ind_zoom_x >= 60 then
		ind_zoom_x = 0
		ind_x_middle = 240
		end
		
		if ind_zoom_y < 60 then
		ind_zoom_y = ind_zoom_y + 1.25
		ind_y_middle = ind_y_middle - 0.625
		end
		
		if ind_zoom_y >= 60 then
		ind_zoom_y = 0
		ind_y_middle = 136
		end
	
		if ind_alpha <= 0 then
		ind_alpha = 255
		end
		
	ind_alpha = ind_alpha - 5
	end
	
	if player_block_timer < 100 then
	player_block_timer = player_block_timer + 1
	block:activate()
	block:draweasy(90, 100)
	block:draw(ind_x_middle - 135, ind_y_middle - 21, ind_zoom_x, ind_zoom_y, 0, 0, 30, 30, 0, ind_alpha)
	
		if ind_zoom_x < 60 then
		ind_zoom_x = ind_zoom_x + 1.25
		ind_x_middle = ind_x_middle - 0.625
		end
		
		if ind_zoom_x >= 60 then
		ind_zoom_x = 0
		ind_x_middle = 240
		end
		
		if ind_zoom_y < 60 then
		ind_zoom_y = ind_zoom_y + 1.25
		ind_y_middle = ind_y_middle - 0.625
		end
		
		if ind_zoom_y >= 60 then
		ind_zoom_y = 0
		ind_y_middle = 136
		end
	
		if ind_alpha <= 0 then
		ind_alpha = 255
		end
		
	ind_alpha = ind_alpha - 5
	end
	
	if hell_heal_timer < 100 then
	hell_heal_timer = hell_heal_timer + 1
	heal:activate()
	heal:draweasy(90, 150)
	heal:draw(ind_x_middle - 135, ind_y_middle + 29, ind_zoom_x, ind_zoom_y, 0, 0, 30, 30, 0, ind_alpha)
	
		if ind_zoom_x < 60 then
		ind_zoom_x = ind_zoom_x + 1.25
		ind_x_middle = ind_x_middle - 0.625
		end
		
		if ind_zoom_x >= 60 then
		ind_zoom_x = 0
		ind_x_middle = 240
		end
		
		if ind_zoom_y < 60 then
		ind_zoom_y = ind_zoom_y + 1.25
		ind_y_middle = ind_y_middle - 0.625
		end
		
		if ind_zoom_y >= 60 then
		ind_zoom_y = 0
		ind_y_middle = 136
		end
	
		if ind_alpha <= 0 then
		ind_alpha = 255
		end
		
	ind_alpha = ind_alpha - 5
	end
	
	if hell_bow_timer < 100 then
	hell_bow_timer = hell_bow_timer + 1
	bow:activate()
	bow:draweasy(90, 150)
	bow:draw(ind_x_middle - 135, ind_y_middle + 29, ind_zoom_x, ind_zoom_y, 0, 0, 30, 30, 0, ind_alpha)
	
		if ind_zoom_x < 60 then
		ind_zoom_x = ind_zoom_x + 1.25
		ind_x_middle = ind_x_middle - 0.625
		end
		
		if ind_zoom_x >= 60 then
		ind_zoom_x = 0
		ind_x_middle = 240
		end
		
		if ind_zoom_y < 60 then
		ind_zoom_y = ind_zoom_y + 1.25
		ind_y_middle = ind_y_middle - 0.625
		end
		
		if ind_zoom_y >= 60 then
		ind_zoom_y = 0
		ind_y_middle = 136
		end
	
		if ind_alpha <= 0 then
		ind_alpha = 255
		end
		
	ind_alpha = ind_alpha - 5
	end
	
	if hell_sap_timer < 100 then
	hell_sap_timer = hell_sap_timer + 1
	sap:activate()
	sap:draweasy(90, 150)
	sap:draw(ind_x_middle - 135, ind_y_middle + 29, ind_zoom_x, ind_zoom_y, 0, 0, 30, 30, 0, ind_alpha)
	
		if ind_zoom_x < 60 then
		ind_zoom_x = ind_zoom_x + 1.25
		ind_x_middle = ind_x_middle - 0.625
		end
		
		if ind_zoom_x >= 60 then
		ind_zoom_x = 0
		ind_x_middle = 240
		end
		
		if ind_zoom_y < 60 then
		ind_zoom_y = ind_zoom_y + 1.25
		ind_y_middle = ind_y_middle - 0.625
		end
		
		if ind_zoom_y >= 60 then
		ind_zoom_y = 0
		ind_y_middle = 136
		end
	
		if ind_alpha <= 0 then
		ind_alpha = 255
		end
		
	ind_alpha = ind_alpha - 5
	end
	
	if hell_ax_timer < 100 then
	hell_ax_timer = hell_ax_timer + 1
	ax:activate()
	ax:draweasy(90, 150)
	ax:draw(ind_x_middle - 135, ind_y_middle + 29, ind_zoom_x, ind_zoom_y, 0, 0, 30, 30, 0, ind_alpha)
	
		if ind_zoom_x < 60 then
		ind_zoom_x = ind_zoom_x + 1.25
		ind_x_middle = ind_x_middle - 0.625
		end
		
		if ind_zoom_x >= 60 then
		ind_zoom_x = 0
		ind_x_middle = 240
		end
		
		if ind_zoom_y < 60 then
		ind_zoom_y = ind_zoom_y + 1.25
		ind_y_middle = ind_y_middle - 0.625
		end
		
		if ind_zoom_y >= 60 then
		ind_zoom_y = 0
		ind_y_middle = 136
		end
	
		if ind_alpha <= 0 then
		ind_alpha = 255
		end
		
	ind_alpha = ind_alpha - 5
	end
	
	if hell_block_timer < 100 then
	hell_block_timer = hell_block_timer + 1
	block:activate()
	block:draweasy(90, 150)
	block:draw(ind_x_middle - 135, ind_y_middle + 29, ind_zoom_x, ind_zoom_y, 0, 0, 30, 30, 0, ind_alpha)
	
		if ind_zoom_x < 60 then
		ind_zoom_x = ind_zoom_x + 1.25
		ind_x_middle = ind_x_middle - 0.625
		end
		
		if ind_zoom_x >= 60 then
		ind_zoom_x = 0
		ind_x_middle = 240
		end
		
		if ind_zoom_y < 60 then
		ind_zoom_y = ind_zoom_y + 1.25
		ind_y_middle = ind_y_middle - 0.625
		end
		
		if ind_zoom_y >= 60 then
		ind_zoom_y = 0
		ind_y_middle = 136
		end
	
		if ind_alpha <= 0 then
		ind_alpha = 255
		end
		
	ind_alpha = ind_alpha - 5
	end
	
	if player_hp >= 80 then
	player_hp_color = green
	if player_hp > 100 then
	player_hp = 100
	end
	elseif player_hp >= 30 and player_hp < 80 then
	player_hp_color = yellow
	elseif player_hp < 30 then
	player_hp_color = red
	if player_hp <= 0 then
	player_hp = 0
	if whos_turn == 1 then
	renewindvars()
	renewvars()
	pge.mp3.stop()
	---
	---
	---GAMEOVER MUSIK
	---
	---
	army2_fade_alpha = 0
	whichfunction = 6
	end
	end
	end
	
	if not load_enabled then
	if level <= 9 then
	
	pge.gfx.drawrectoutline(139, 192, 200, 10, white)
	pge.gfx.drawrectoutline(139, 82, 200, 10, white)
	
	if hell_hp >= 80 then
	hell_hp_color = green
	if hell_hp > 100 then
	hell_hp = 100
	end
	elseif hell_hp >= 30 and hell_hp < 80 then
	hell_hp_color = yellow
	elseif hell_hp < 30 then
	hell_hp_color = red
	end
	if hell_hp <= 0 then
	hell_hp = 0
	if whos_turn == 2 then
	hell_hp = 100
	player_hp = 100
	levelup_timer = 0
	renewindvars()
	level = level + 1
	score = score + 1000
	whos_turn = 0
	delaytimer1 = 0
	saveinit()
	save_enabled = true
	end
	end
	end
	
	if level == 10 and hell_hp_correction == 1 then
	hell_hp = 110
	hell_hp_correction = 0
	end
	
	if level == 11 then
	hell_hp_correction = 1
	end
	
	if level <= 19 and level > 9 then
	
	pge.gfx.drawrectoutline(129, 192, 220, 10, white)
	pge.gfx.drawrectoutline(139, 82, 200, 10, white)
	
	if hell_hp >= 80 then
	hell_hp_color = green
	if hell_hp > 110 then
	hell_hp = 110
	end
	elseif hell_hp >= 30 and hell_hp < 80 then
	hell_hp_color = yellow
	elseif hell_hp < 30 then
	hell_hp_color = red
	end
	if hell_hp <= 0 then
	hell_hp = 0
	if whos_turn == 2 then
	hell_hp = 110
	player_hp = 100
	levelup_timer = 0
	renewindvars()
	level = level + 1
	score = score + 1000
	whos_turn = 0
	delaytimer1 = 0
	saveinit()
	save_enabled = true
	end
	end
	end
	
	if level == 20 and hell_hp_correction == 1 then
	hell_hp = 120
	hell_hp_correction = 0
	end
	
	if level == 21 then
	hell_hp_correction = 1
	end
	
	if level <= 29 and level > 19 then
	
	pge.gfx.drawrectoutline(119, 192, 240, 10, white)
	pge.gfx.drawrectoutline(139, 82, 200, 10, white)
	
	if hell_hp >= 80 then
	hell_hp_color = green
	if hell_hp > 120 then
	hell_hp = 120
	end
	elseif hell_hp >= 30 and hell_hp < 80 then
	hell_hp_color = yellow
	elseif hell_hp < 30 then
	hell_hp_color = red
	end
	if hell_hp <= 0 then
	hell_hp = 0
	if whos_turn == 2 then
	hell_hp = 120
	player_hp = 100
	levelup_timer = 0
	renewindvars()
	level = level + 1
	score = score + 1000
	whos_turn = 0
	delaytimer1 = 0
	saveinit()
	save_enabled = true
	end
	end
	end
	
	if level == 30 and hell_hp_correction == 1 then
	hell_hp = 130
	hell_hp_correction = 0
	end
	
	if level == 31 then
	hell_hp_correction = 1
	end
	
	if level <= 39 and level > 29 then
	
	pge.gfx.drawrectoutline(109, 192, 260, 10, white)
	pge.gfx.drawrectoutline(139, 82, 200, 10, white)
	
	if hell_hp >= 80 then
	hell_hp_color = green
	if hell_hp > 130 then
	hell_hp = 130
	end
	elseif hell_hp >= 30 and hell_hp < 80 then
	hell_hp_color = yellow
	elseif hell_hp < 30 then
	hell_hp_color = red
	end
	if hell_hp <= 0 then
	hell_hp = 0
	if whos_turn == 2 then
	hell_hp = 130
	player_hp = 100
	levelup_timer = 0
	renewindvars()
	level = level + 1
	score = score + 1000
	whos_turn = 0
	delaytimer1 = 0
	saveinit()
	save_enabled = true
	end
	end
	end
	
	if level == 40 and hell_hp_correction == 1 then
	hell_hp = 140
	hell_hp_correction = 0
	end
	
	if level == 41 then
	hell_hp_correction = 1
	end
	
	if level <= 49 and level > 39 then
	
	pge.gfx.drawrectoutline(99, 192, 280, 10, white)
	pge.gfx.drawrectoutline(139, 82, 200, 10, white)
	
	if hell_hp >= 80 then
	hell_hp_color = green
	if hell_hp > 140 then
	hell_hp = 140
	end
	elseif hell_hp >= 30 and hell_hp < 80 then
	hell_hp_color = yellow
	elseif hell_hp < 30 then
	hell_hp_color = red
	end
	if hell_hp <= 0 then
	hell_hp = 0
	if whos_turn == 2 then
	hell_hp = 140
	player_hp = 100
	levelup_timer = 0
	renewindvars()
	level = level + 1
	score = score + 1000
	whos_turn = 0
	delaytimer1 = 0
	saveinit()
	save_enabled = true
	end
	end
	end
	
	if level == 50 and hell_hp_correction == 1 then
	hell_hp = 150
	hell_hp_correction = 0
	end
	
	if level == 51 then
	hell_hp_correction = 1
	end
	
	if level <= 58 and level > 49 then
	
	pge.gfx.drawrectoutline(89, 192, 300, 10, white)
	pge.gfx.drawrectoutline(139, 82, 200, 10, white)
	
	if hell_hp >= 80 then
	hell_hp_color = green
	if hell_hp > 150 then
	hell_hp = 150
	end
	elseif hell_hp >= 30 and hell_hp < 80 then
	hell_hp_color = yellow
	elseif hell_hp < 30 then
	hell_hp_color = red
	end
	if hell_hp <= 0 then
	hell_hp = 0
	if whos_turn == 2 then
	hell_hp = 150
	player_hp = 100
	levelup_timer = 0
	renewindvars()
	level = level + 1
	score = score + 1000
	whos_turn = 0
	delaytimer1 = 0
	saveinit()
	save_enabled = true
	end
	end
	end
	
	if level == 59 then
	
	pge.gfx.drawrectoutline(89, 192, 300, 10, white)
	pge.gfx.drawrectoutline(139, 82, 200, 10, white)
	
	if hell_hp >= 80 then
	hell_hp_color = green
	if hell_hp > 150 then
	hell_hp = 150
	end
	elseif hell_hp >= 30 and hell_hp < 80 then
	hell_hp_color = yellow
	elseif hell_hp < 30 then
	hell_hp_color = red
	end
	if hell_hp <= 0 then
	hell_hp = 0
	player_hp = 0.01
	if whos_turn == 2 then
	levelup_timer = 0
	renewindvars()
	score = score + 1000
	whos_turn = 0
	delaytimer1 = 0
	swirltimer = -70
	pge.mp3.stop()
	pge.mp3.play("satan_appears.mp3")
	saveinit()
	save_enabled = true
	end
	end
	end
	
	if swirltimer < 500 then
	swirltimer = swirltimer + 1
	if swirltimer >= 0 then
	pokemonswirl()
	end
	elseif swirltimer == 500 then
	swirltimer = 501
	resetpokevars()
	alpha = 0
	
	hell_hp = 1000
	player_hp = 100
	
	pge.mp3.stop()
	pge.mp3.play("satan_fight.mp3")
	
	level = level + 1
	end
	
	if level == 60 then
	
	if alpha < 255 then
	alpha = alpha + 5
	end
	
	pge.gfx.drawrectoutline(139, 192, 200, 10, white)
	pge.gfx.drawrectoutline(139, 82, 200, 10, white)
	
	if hell_hp >= 800 then
	hell_hp_color = green
	if hell_hp > 1000 then
	hell_hp = 1000
	end
	elseif hell_hp >= 300 and hell_hp < 800 then
	hell_hp_color = yellow
	elseif hell_hp < 300 then
	hell_hp_color = red
	end
	if hell_hp <= 0 then
	hell_hp = 0
	if whos_turn == 2 then
	hell_hp = 100
	player_hp = 100
	levelup_timer = 0
	renewindvars()
	level = level + 1
	score = score + 1000
	whos_turn = 0
	delaytimer1 = 0
	saveinit()
	save_enabled = true
	end
	end
	end
	
	if level == 60 and hell_hp_correction == 1 then
	hell_hp = 1000
	hell_hp_correction = 0
	end
	
	if level == 61 then
	hell_hp_correction = 1
	renewvars()
	army2_fade_alpha = 0
	pge.mp3.stop()
	pge.mp3.play("satan_victory.mp3")
	whichfunction = 7
	end
	end
	
	--[[ CHEATS (remove square brackets to activate)
	
	if pge.controls.pressed(PGE_CTRL_CIRCLE) then
	level = level + 1
	elseif pge.controls.pressed(PGE_CTRL_TRIANGLE) then
	level = level - 1
	end
	
	if pge.controls.pressed(PGE_CTRL_SQUARE) then
	hell_hp = 0
	end
	
	if pge.controls.held(PGE_CTRL_RTRIGGER) then
	player_hp = 100
	hell_hp = 100
	verdana24:activate()
	verdana24:print(180, 130, white, "REFRESH!")
	end
	
	]]-- CHEATS (remove square brackets to activate)
	
	if not load_enabled then
		pge.gfx.drawline(240 - player_hp, 84, 240 + player_hp, 84, player_hp_color)
		pge.gfx.drawline(240 - player_hp, 86, 240 + player_hp, 86, player_hp_color)
		pge.gfx.drawline(240 - player_hp, 88, 240 + player_hp, 88, player_hp_color)
		pge.gfx.drawline(240 - player_hp, 90, 240 + player_hp, 90, player_hp_color)
		
		if level < 60 then
		pge.gfx.drawline(240 - hell_hp, 194, 240 + hell_hp, 194, hell_hp_color)
		pge.gfx.drawline(240 - hell_hp, 196, 240 + hell_hp, 196, hell_hp_color)
		pge.gfx.drawline(240 - hell_hp, 198, 240 + hell_hp, 198, hell_hp_color)
		pge.gfx.drawline(240 - hell_hp, 200, 240 + hell_hp, 200, hell_hp_color)
		else
		pge.gfx.drawline(240 - hell_hp/10, 194, 240 + hell_hp/10, 194, hell_hp_color)
		pge.gfx.drawline(240 - hell_hp/10, 196, 240 + hell_hp/10, 196, hell_hp_color)
		pge.gfx.drawline(240 - hell_hp/10, 198, 240 + hell_hp/10, 198, hell_hp_color)
		pge.gfx.drawline(240 - hell_hp/10, 200, 240 + hell_hp/10, 200, hell_hp_color)
		end
	end
	
	if verschieben == 1 then
		if selpicx < 81 then
		selpicx = 81
		elseif selpicx > 81 then
		selpicx = selpicx - 8
		end	
	end
	
	if verschieben == 2 then
		if selpicx == 124 then
		selpicx = 129
		elseif selpicx == 125 then
		selpicx = 129
		elseif selpicx == 126 then
		selpicx = 129
		elseif selpicx == 127 then
		selpicx = 129
		elseif selpicx == 128 then
		selpicx = 129
		elseif selpicx < 129 then
		selpicx = selpicx + 8
		elseif selpicx > 129 then
		selpicx = selpicx - 8
		elseif selpicx == 130 then
		selpicx = 129
		elseif selpicx == 131 then
		selpicx = 129
		elseif selpicx == 132 then
		selpicx = 129
		elseif selpicx == 133 then
		selpicx = 129
		elseif selpicx == 134 then
		selpicx = 129
		end
	end
	
	if verschieben == 3 then
		if selpicx == 172 then
		selpicx = 177
		elseif selpicx == 173 then
		selpicx = 177
		elseif selpicx == 174 then
		selpicx = 177
		elseif selpicx == 175 then
		selpicx = 177
		elseif selpicx == 176 then
		selpicx = 177
		elseif selpicx < 177 then
		selpicx = selpicx + 8
		elseif selpicx > 177 then
		selpicx = selpicx - 8
		elseif selpicx == 178 then
		selpicx = 177
		elseif selpicx == 179 then
		selpicx = 177
		elseif selpicx == 180 then
		selpicx = 177
		elseif selpicx == 181 then
		selpicx = 177
		elseif selpicx == 182 then
		selpicx = 177
		end
	end
	
	if verschieben == 4 then
		if selpicx == 220 then
		selpicx = 225
		elseif selpicx == 221 then
		selpicx = 225
		elseif selpicx == 222 then
		selpicx = 225
		elseif selpicx == 223 then
		selpicx = 225
		elseif selpicx == 224 then
		selpicx = 225
		elseif selpicx < 225 then
		selpicx = selpicx + 8
		elseif selpicx > 225 then
		selpicx = selpicx - 8
		elseif selpicx == 226 then
		selpicx = 225
		elseif selpicx == 227 then
		selpicx = 225
		elseif selpicx == 228 then
		selpicx = 225
		elseif selpicx == 229 then
		selpicx = 225
		elseif selpicx == 230 then
		selpicx = 225
		end
	end
	
	if verschieben == 5 then
		if selpicx < 273 then
		selpicx = selpicx + 8
		elseif selpicx > 273 then
		selpicx = 273
		end
	end
	
	if not load_enabled then
	verdana12:activate()
	verdana12:print(65, 1, black, "Level: "..level.."          Heaven HP: "..player_hp.."          Hell HP: "..hell_hp)
	end
end

function troopsf()
	angel:activate()
	angel:draweasy(x_1, y_angel, 0, alpha)
	angel:draweasy(x_2, y_angel, 0, alpha)
	angel:draweasy(x_3, y_angel, 0, alpha)
	angel:draweasy(x_4, y_angel, 0, alpha)
	angel:draweasy(x_5, y_angel, 0, alpha)
	devil:activate()
	devil:draweasy(x_1, y_devil, 0, alpha)
	devil:draweasy(x_2, y_devil, 0, alpha)
	devil:draweasy(x_3, y_devil, 0, alpha)
	devil:draweasy(x_4, y_devil, 0, alpha)
	devil:draweasy(x_5, y_devil, 0, alpha)
	
	x_timer = x_timer + 1
	
	if x_timer > 20 then
	x_1 = x_1 + 5
	x_2 = x_2 + 5
	x_3 = x_3 + 5
	x_4 = x_4 + 5
	x_5 = x_5 + 5
	x_timer = 0
	end
	
	if x_1 == 140 then
	x_1 = 130
	x_2 = 178
	x_3 = 225
	x_4 = 273
	x_5 = 320
	end
end

function game_over()
	gameoverpic:activate()
	gameoverpic:draweasy(0, 0, 0, alpha)
	
	if alpha < 255 then
	alpha = alpha + 5
	end
	
	if cursorx >= 150 and cursorx <= 322 and cursory >= 218 and cursory <= 242 and pge.controls.pressed(PGE_CTRL_CROSS) then
	
	if level < 10 then
	hell_hp = 100
	elseif level < 20 and level > 9 then
	hell_hp = 110
	elseif level < 30 and level > 19 then
	hell_hp = 120
	elseif level < 40 and level > 29 then
	hell_hp = 130
	elseif level < 50 and level > 39 then
	hell_hp = 140
	elseif level < 60 and level > 49 then
	hell_hp = 150
	elseif level == 60 then
	hell_hp = 1000
	end
	
	player_hp = 100
	renewvars()
	pge.mp3.stop()
	pge.mp3.play("menu_song.mp3")
	whichfunction = 3
	end
	
	if cursorx >= 150 and cursorx <= 322 and cursory >= 245 and cursory <= 269 and pge.controls.pressed(PGE_CTRL_CROSS) then
	
	if level < 10 then
	hell_hp = 100
	elseif level < 20 and level > 9 then
	hell_hp = 110
	elseif level < 30 and level > 19 then
	hell_hp = 120
	elseif level < 40 and level > 29 then
	hell_hp = 130
	elseif level < 50 and level > 39 then
	hell_hp = 140
	elseif level < 60 and level > 49 then
	hell_hp = 150
	elseif level == 60 then
	hell_hp = 1000
	end
	
	player_hp = 100
	renewvars()
	pge.mp3.stop()
	if level < 60 then
	pge.mp3.play("game_song.mp3")
	else
	pge.mp3.play("satan_fight.mp3")
	whichfunction = 5
	end
	
	end
end

function game_win()
	keanu:activate()
	keanu:draweasy(0, 0, 0, alpha)
	
	if alpha < 255 then
	alpha = alpha + 5
	end
	
	if cursorx >= 437 and cursorx <= 470 and cursory >= 227 and cursory <= 262 and pge.controls.pressed(PGE_CTRL_CROSS) then
	renewvars()
	pge.mp3.stop()
	pge.mp3.play("menu_song.mp3")
	whichfunction = 3
	end
end

while pge.running() do
	pge.controls.update()
	pge.gfx.startdrawing()
	pge.gfx.clearscreen()
	
	if whichfunction == 1 then
	intro1f()
	elseif whichfunction == 2 then
	languagef()
	elseif whichfunction == 3 then
	menu()
	elseif whichfunction == 4 then
	game_intro()
	elseif whichfunction == 5 then
	game()
	elseif whichfunction == 6 then
	game_over()
	elseif whichfunction == 7 then
	game_win()
	end
	
	cursorf()
	
	pge.gfx.enddrawing()
	
		if credits_enabled then
			msgupdate_pressed = pge.utils.msgupdate()
			if msgupdate_pressed == PGE_UTILS_MSG_DIALOG_RESULT_BACK then
			credits_enabled = false
			end
		end
		
		if save_enabled then
		save_state = pge.utils.savedataupdate()
		
			if save_state == 0 then
			save_enabled = false
			elseif save_state == 1 then
			save_enabled = false
			pge.mp3.stop()
			pge.mp3.play("menu_song.mp3")
			renewvars()
			renewindvars()
			whichfunction = 3
			elseif save_state ~= PGE_UTILS_DIALOG_RUNNING then
			save_enabled = false
			pge.mp3.stop()
			pge.mp3.play("menu_song.mp3")
			renewvars()
			renewindvars()
			whichfunction = 3
			end
		end
		
		if load_enabled then
		load_state, data = pge.utils.savedataupdate()
		
			if load_state == 0 then
			level = tonumber(data:sub(1, string.find(data, "!") - 1))
			score = tonumber(data:sub(string.find(data, "!") + 1))
				if level < 10 then
				hell_hp = 100
				elseif level < 20 and level > 9 then
				hell_hp = 110
				elseif level < 30 and level > 19 then
				hell_hp = 120
				elseif level < 40 and level > 29 then
				hell_hp = 130
				elseif level < 50 and level > 39 then
				hell_hp = 140
				elseif level < 60 and level > 49 then
				hell_hp = 150
				elseif level == 60 then
				hell_hp = 1000
				end
			load_enabled = false
			pge.mp3.stop()
			pge.mp3.play("game_song.mp3")
			elseif load_state == 1 then
			load_enabled = false
			pge.mp3.stop()
			pge.mp3.play("menu_song.mp3")
			renewvars()
			renewindvars()
			whichfunction = 3
			elseif load_state ~= PGE_UTILS_DIALOG_RUNNING then
			load_enabled = false
			pge.mp3.stop()
			pge.mp3.play("menu_song.mp3")
			renewvars()
			renewindvars()
			whichfunction = 3
			end
		end
	
	pge.gfx.swapbuffers()
end