Sure , btnp(0) - Up ( dir = 0 ) btnp(1) - Down ( dir = 1 ) btnp(2) - Left ( dir = 2) btnp(3) - Right ( dir = 3 ) Now , dir_x={ [0] =0 , 0 , -1 , 1 } dir_y = { [0] = -1 , 1 ,0 ,0 } Now x=x + dir_x[dir] y=y + dir_y[dir] -- UP dir =0 -> x=x+dir_x[0] -> x=x -> y=y+dir_y[0] -> y=y - 1 -- DOWN dir =1 -> x=x+dir_x[1] -> x=x -> y=y+dir_y[1] -> y=y + 1 -- LEFT dir=2 -> x=x+dir_x[2] -> x=x-1 -> y=y+dir_y[2] -> y=y -- RIGHT dir=3 -> x=x+dir_x[3] -> x=x+1 -> y=y+dir_y[3] -> y=y Now , if btnp(0) then dir=0 elseif btnp(1) then dir=1 elseif btnp(2) then dir=2 elseif btnp(3) then dir=3 end if dir~= -1 then ( that is dir =0 , 1 , 2 , 3 ) x=x+dir_x[dir] y=y+dir_y[dir] end dir = -1 ( If no button is pressed )
Thought I'd play around with TIC80 and this was a great tutorial, thank you!.
Sure , Thanks :)
Thank you so much for this tutorial.
I am really struggling with collisions for my game, and this really helps
Thanks!!!!!
Sure , thanks :)
There are other videos like this
banger tutorial my good lad
Thanks :)
Very good
Thanks :)
is so good!
Thanks !
Master :)
Haha , Thanks :)
I didn't understand the dir value can you help?
Sure ,
btnp(0) - Up ( dir = 0 )
btnp(1) - Down ( dir = 1 )
btnp(2) - Left ( dir = 2)
btnp(3) - Right ( dir = 3 )
Now , dir_x={ [0] =0 , 0 , -1 , 1 }
dir_y = { [0] = -1 , 1 ,0 ,0 }
Now
x=x + dir_x[dir]
y=y + dir_y[dir]
-- UP
dir =0 -> x=x+dir_x[0] -> x=x
-> y=y+dir_y[0] -> y=y - 1
-- DOWN
dir =1 -> x=x+dir_x[1] -> x=x
-> y=y+dir_y[1] -> y=y + 1
-- LEFT
dir=2 -> x=x+dir_x[2] -> x=x-1
-> y=y+dir_y[2] -> y=y
-- RIGHT
dir=3 -> x=x+dir_x[3] -> x=x+1
-> y=y+dir_y[3] -> y=y
Now ,
if btnp(0) then
dir=0
elseif btnp(1) then
dir=1
elseif btnp(2) then
dir=2
elseif btnp(3) then
dir=3
end
if dir~= -1 then ( that is dir =0 , 1 , 2 , 3 )
x=x+dir_x[dir]
y=y+dir_y[dir]
end
dir = -1 ( If no button is pressed )
Hi
Hello :)