hey guys, can you please explain the hit function in my code. I used a tutorial for it but i want to understand it.
x = 63
y = 35
dx = 0
dy = 0
grid_x = 0
grid_y = 0
map_tile = 0
flag_tile = 0
function _update()
dx = 0
dy = 0
grid_x = flr(x/8)
grid_y = flr(y/8)
flag_tile = fget(mget(grid_x,grid_y))
if btn(⬅️) then dx = -1 end
if btn(➡️) then dx = 1 end
if btn(⬆️) then dy = -1 end
if btn(⬇️) then dy = 1 end
if hit(x+dx,y,7,7) then
dx = 0
end
if hit(x,y+dy,7,7) then
dy = 0
end
x += dx
y += dy
end
function _draw()
cls()
map(0,0,0,0,16,16)
spr(2,x,y)
end
function hit(x,y,w,h)
collide = false
for i=x,x+w,w do
if fget(mget(i/8,y/8))>0 or
fget(mget(i/8,(y+h)/8))>0 then
collide = true
end
end
return collide
end

