àofföofföofföofföÏlÆüÏoöüðffÿÿofföofföofföofföofföofföofföofföðoöðffðffofföofföofföofföðÿõ/ò/ò/,"ò/""òð""ÿÿðÿðofoffðfffðfffofffofffofföððooföðfföðfföofföofföoffö >Â,ÿÿÌÌ ðÿõðffÀ /ò/òÏoöüÌ/,"òÏlÆüÀ /""òofföÌð""offöÿÿofföofföofföofföofföofföofföofföofföofföofföofföofföofföofföofföofföofföofföÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿofffffffffffffffffffffÿoffffffffffffffffffffffðfffffffffffffffffffffföðfffffffffffffffffffffföofffffffffffffffffffffðofffffffffffffffffffÿðÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ2 -- title: Snake -- author: fizzii01 -- desc: It's snake. -- site: https://fizzii01.itch.io -- license: MIT License (change this to your license of choice) -- version: uwu -- script: lua -- 30x17 mode=0 function TIC() if mode==0 then reset() end cls() t=t+1 if t==8 then t=0 end game_loop() end function reset() t=0 dir={0,-1} rot=2 x,px=15 y,py=8 ax=math.random(0,29) ay=math.random(0,16) tl=1 tail={{15,9,2}} turns={} mode=1 end function game_loop() if btnp(0) then add_turn();dir={0,-1};rot=2 end if btnp(1) then add_turn();dir={0,1};rot=0 end if btnp(2) then add_turn();dir={-1,0};rot=1 end if btnp(3) then add_turn();dir={1,0};rot=3 end if t==7 then px=x py=y x=x+dir[1] y=y+dir[2] if x<0 or x>29 or y<0 or y>16 then mode=0 end end spr(1,x*8,y*8,-1,1,0,rot) for i=tl,1,-1 do if t==7 then if i==1 then tail[i][1]=px tail[i][2]=py tail[i][3]=rot else tail[i][1]=tail[i-1][1] tail[i][2]=tail[i-1][2] tail[i][3]=tail[i-1][3] end end if i~=tl then spr(2,tail[i][1]*8,tail[i][2]*8,-1,1,0,tail[i][3]) else spr(3,tail[i][1]*8,tail[i][2]*8,-1,1,0,tail[i][3]) end if x==tail[i][1] and y==tail[i][2] then mode=0 end end for i=1,#turns do if t==7 then turns[i][5]=turns[i][5]-1 end if turns[i][5]==0 then table.remove(turns,i);break end spr(5,turns[i][1]*8,turns[i][2]*8,-1,1,turns[i][3],turns[i][4]) if turns[i][1]==tail[tl][1] and turns[i][2]==tail[tl][2] then spr(6,turns[i][1]*8,turns[i][2]*8,-1,1,turns[i][3],turns[i][4]) if t==7 then table.remove(turns,i);break end end end if x==ax and y==ay then ax=math.random(0,29) ay=math.random(0,16) new={} if tail[tl][3]==2 then new={tail[tl][1],tail[tl][2]+1,tail[tl][3]} elseif tail[tl][3]==0 then new={tail[tl][1],tail[tl][2]-1,tail[tl][3]} elseif tail[tl][3]==1 then new={tail[tl][1]+1,tail[tl][2],tail[tl][3]} elseif tail[tl][3]==3 then new={tail[tl][1]-1,tail[tl][2],tail[tl][3]} end tl=tl+1 table.insert(tail,new) end print(tl-1,14*8,8*8,12) spr(4,ax*8,ay*8) end function add_turn() --going right, turning up if rot==3 and btn(0) then table.insert(turns,{x,y,0,2,tl});return --going left, turning up elseif rot==1 and btn(0) then table.insert(turns,{x,y,1,2,tl});return --going right, turning down elseif rot==3 and btn(1) then table.insert(turns,{x,y,0,1,tl});return --going left, turning down elseif rot==1 and btn(1) then table.insert(turns,{x,y,0,0,tl});return --going up, turning left elseif rot==2 and btn(2) then table.insert(turns,{x,y,0,1,tl});return --going up, turning right elseif rot==2 and btn(3) then table.insert(turns,{x,y,0,0,tl});return --going down, turning left elseif rot==0 and btn(2) then table.insert(turns,{x,y,2,1,tl});return --going down, turning right elseif rot==0 and btn(3) then table.insert(turns,{x,y,2,0,tl});return end end