Exit Donjon (Assets)

Retourner au jeu

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

La cartouche
Les sprites

Code


--exit the donjon (1hgj)
--by bigaston

function _init()
	px=60
	py=60
	
	blind=true
	
	doorx=flr(rnd(118))+1
	doory=flr(rnd(113))+1
	s=1
	
	ftime=-1
	
	btime=flr(time())
	
	tic=15
	c=5
end

function _update()
	test_win()
	couleur()
	
	if blind then
		if btn(0) then
			px-=1
		elseif btn(1) then
			px+=1
		end
	
		if btn(2) then
			py-=1
		elseif btn(3) then
			py+=1	
		end
	else
		if btnp(5) then _init() end
	end
	
	if px<1 then px=1 end
	if px>119 then px=119 end
	if py<1 then py=1 end
	if py>114 then py=114 end
		
end

function _draw()
	cls(0)
	spr(3,doorx,doory)
	spr(1,px,py)
	
	if blind then
		rectfill(0,0,px-8,127,0)
		rectfill(px+15,0,127,127,0)
		rectfill(0,0,127,py-8,0)
		rectfill(0,py+15,127,127,0)
		rect(px-7,py-7,px+14,py+14,7)
		fleche()
	else
		rectfill(0,0,127,12,0)
		
		print("gg! you return to exit in    s",4,1,7)
		print(ftime,108,1,c)
		
		print("press ❎ to restart",30,7,c)
	end
	
	print("create in 1h for the 147th 1hgj",3,122,7)	
end

function test_win()
	if (px<=doorx+3) and (px+7>=doorx+3) then
		if (py<=doory+4) and (py+7>=doory+4) then
			blind=false
			if ftime==-1 then
				ftime=""..flr(time())-btime
				
				if #ftime<2 then
					ftime="0"..ftime
				end
			end
		end
	end
end

function fleche()
	if (px-doorx<0) then --plus a droite
		if (py-doory<0) then --plus bas
			spr(7,1,1)
		elseif (py-doory>0) then --plus haut
			spr(5,1,1)
		else --meme ligne
			spr(6,1,1)
		end
		
	elseif (px-doorx>0) then --plus a gauche
		if (py-doory<0) then --plus bas
			spr(9,1,1)
		elseif (py-doory>0) then --plus haut
			spr(11,1,1)
		else
			spr(10,1,1)
		end
		
	else --meme colonne
		if (py-doory<0) then --plus bas
			spr(8,1,1)
		elseif (py-doory>0) then --plus haut
		 spr(4,1,1)		
		end
	end
end

function couleur()
	tic-=1
	
	if tic==0 then
		tic=15
		
		if c==5 then
			c=6
		else
			c=5
		end
	end
end