Code Failure (Assets)

Retourner au jeu

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

La cartouche
Les sprites

Code


--code failure (1hgj)
--by bigaston

function _init()
	player={}
	player.x=60
	player.y=60
	
	score=0
	game_over=false
	
	enemy={}
	--num=1
	add_enemy()
end

function _update()
	if not game_over then
		if btn(0) then
			player.x-=1
		elseif btn(1) then
			player.x+=1
		end
	
		if btn(2) then
			player.y-=1
		elseif btn(3) then
			player.y+=1
		end
		
		if player.x<0 then
			player.x=0
		elseif player.x>120 then
			player.x=120
		end
	
		if player.y<7 then
			player.y=7
		elseif player.y>113 then
			player.y=113
		end
	
		move_enemy()
		test_player()
	end
	
	if game_over and btnp(5) then
		_init()
	end
end

function _draw()
	cls(5)
	rectfill(0,121,128,128,8)
	print("create in 1h for the 149th 1hgj",3,122,2)
	rectfill(0,0,127,7,8)
	map(0,0,87,1,5,1)
	--[[for i=1, #enemy do
		draw_enemy(enemy[i])
	end]]
	
	print("score: "..score,1,1,2)
	
	if not game_over then
		print("!",enemy.x,enemy.y,8)
		spr(6,player.x,player.y)
	end
	
	if game_over then
		print("oh non! you have a failure!",10,60,8)
		print("press ❎ to restart",30,66,8)
	end
	
end

function add_enemy()
	--local sens=flr(rnd(2))
	--local enter_y=flr(rnd(107))+8
	
	--enemy.sens=flr(rnd(1.9))
	enemy.sens=1
	enemy.y=flr(rnd(107))+8
	if sens==0 then
		--add(enemy,{x=60,y=enter_y,sens=0,nb=num})
		--num+=1
		enemy.x=-11
	else
		--add(enemy,{x=60,y=enter_y,sens=1,nb=num})
		--num+=1
		enemy.x=127
	end
end

function draw_enemy(table)
	print("!",table[x],table[y],5)
	
	if table[sens]==0 then
		enemy[table[nb]].x+=1
	elseif table[sens]==1 then
		enemy[table[nb]].x-=1
	end
end

function move_enemy()
	if enemy.sens<1 then
		enemy.x+=1
	else
		enemy.x-=1
	end
	
	if enemy.x<0 then
		game_over=true
	end
end

function test_player()
	if enemy.x+1>=player.x and enemy.x+1<=player.x+7 then
		if enemy.y+3>=player.y and enemy.y+3<=player.y+6 then
			score+=1
			add_enemy()
			sfx(0)
		end
	end
end