-- Where Am I ? v2.0 -- by Purobaz local wait=misc.wait local text=graydraw.text local rect=graydraw.rect local level={ {1,1,1,1,1,1,1,1,1,1,0,1,1,1,1}, {1,0,0,0,0,0,0,0,4,0,0,0,0,0,1}, {1,0,3,3,3,3,0,0,3,3,3,3,3,0,1}, {1,0,3,0,0,0,0,0,0,0,0,0,3,0,1}, {1,0,3,0,0,0,0,0,0,0,0,0,3,0,1}, {1,0,3,0,2,2,2,2,2,2,2,2,2,0,1}, {1,0,3,0,2,0,0,0,0,0,0,0,2,0,1}, {1,0,3,0,2,1,1,0,1,1,0,0,2,0,1}, {1,0,3,0,0,1,0,0,0,1,0,0,2,0,1}, {1,0,3,0,0,1,0,0,0,1,0,0,2,0,1}, {1,0,3,0,0,1,0,0,0,1,0,0,2,0,1}, {1,0,3,0,0,1,1,1,1,1,0,0,2,0,1}, {1,0,3,0,0,0,0,0,0,0,0,0,2,0,1}, {1,0,2,2,2,2,2,2,2,2,2,2,2,0,1}, {1,0,3,0,0,0,0,0,0,0,0,0,3,0,1}, {1,0,3,0,0,0,0,0,0,0,0,0,0,0,1}, {1,0,3,0,0,0,0,0,0,0,0,0,3,0,1}, {1,0,3,3,3,3,0,0,3,3,3,3,3,0,1}, {1,0,0,0,0,0,0,0,4,0,0,0,0,0,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1} } local perso="\000\000@@\000àà\000@@\000\000" local xperso,yperso=64,32 -- coordonees du perso local dx,dy=0,0 -- deplacement du perso local efface=26 -- compteur avant d'effacer les murs local code=0 -- code du mur detecte function resetecran() -- on reinitialise la memoire d'ecran clear nil state false end function image() -- on charge les murs detectes dans la memoire d'ecran clear nil for i1=1,20,1 do for i2=1,15,1 do if level[i1][i2]==code then rect(6*i1,64-4*i2,6*i1+5,67-4*i2,4,4) end -- dessine un rectangle noir aux endroits indiques dans la map end end state false end function detection() -- detection des murs code=level[1+int((xperso+dx-5)/6)][15-int((yperso+dy-3)/4)] if code~=0 then dx,dy=0,0 -- on annule le deplacement efface=0 -- on initialise le compteur image() -- chargement des murs end end function affiche() -- affichage de la memoire ecran + du perso clear nil state true pushxspr xperso drawspr yperso,perso -- affichage du perso refresh end function fin() -- fin du programme clear nil text(20,30,"GAGNE") refresh repeat wait(2) until key(36) or key(5) misc.exit() end graydraw.setcolor(true) resetecran() affiche() repeat if key(37) then dx=-1 end if key(38) then dy=1 end if key(39) then dy=-1 end if key(40) then dx=1 end if dx~=0 or dy~=0 -- si une touche est pressee then if xperso+dy<=5 then fin() end -- fin du niveau 1 detection() xperso,yperso=xperso+dx,yperso+dy dx,dy=0,0 affiche() end efface=efface+1 if efface==25 -- on efface l'image then resetecran() affiche() end if key(45) then misc.contrast(1) affiche() wait(10) end-- augmente le contraste wait(2) until key(36)