Submarins (Assets)

Retourner au jeu

Vous pouvez utiliser ces fichiers mais pensez à me créditer :p

La cartouche
Les sprites

Code


--submarins (1hgj)
--by bigaston

function _init()
	player={}
	player.x=56
	player.y=20
	player.score=0
	
	coraux={}
	coraux.vide=-1
	coraux.vide2=-1
	coraux.y=128
	coraux.speed=0.5
	
	make_coraux()
	game_over=false
end

function _update()
	if not game_over then
		if (btn(0)) then
			player.x-=2
		elseif (btn(1)) then
			player.x+=2
		end
		up_coraux()
		test_death()
	end

	if game_over then
		if (btnp(5)) then
		 _init()
		end
	end
	if (player.x<8) then
		player.x=8
	end
	
	if (player.x>111) then
		player.x=111
	end
end

function _draw()
	cls()
	spr(1,player.x,player.y)
	rectfill(0,0,7,127,5)
	rectfill(119,0,127,127,5)
	draw_coraux()
	rectfill(44,1,87,10,0)
	print("★score:"..player.score,47,4,5)
	print("★score:"..player.score,46,3,7)
	rect(44,1,87,10,7)
	rectfill(0,121,128,128,5)
	print("create in 1h for the 142nd 1hgj",3,122,7)
	
	if (game_over) then
		print("press ❎ for restart",27,61,5)
		print("press ❎ for restart",26,60,7)
	end
end

function make_coraux()
	coraux.vide=flr(rnd(14))
	
	local random=flr(rnd(1))
	
	if random==0 then
		coraux.vide2=coraux.vide-1
	elseif random==1 then
		coraux.vide2=coraux.vide+1
	end
	
	coraux.y=128
end

function up_coraux()
	coraux.y-=coraux.speed
	
	if (coraux.y<-7) then
		make_coraux()
		player.score+=1
		coraux.speed+=0.25
		sfx(1)
	end
end

function draw_coraux()
	for i = 1,14 do
 	if not (coraux.vide==i) then
 		if not (coraux.vide2==i) then
 			spr(2,i*8,coraux.y)
 		end
 	end
 end
end

function test_death()
	if (pget(player.x,player.y)==8) then
		game_over=true
	end
end