Can someone please tell me how to change a map tile with a sprite over it because I can't figure it out

heres my code

--player

function make_player()

p={}

p.h=10

p.a=3

p.d=1

p.dead = false

p.x=8

p.y=8

p.tx=1

p.ty=1

end

function player_move()

p.tx = p.x/8

p.ty = p.y/8

if (btn(0)) then p.x = p.x - 8 end

if (btn(1)) then p.x = p.x + 8 end

if (btn(2)) then p.y = p.y - 8 end

if (btn(3)) then p.y = p.y + 8

end

end

function overlap(x,y)

if (btn(5)) and fget == 3 then mset(p.tx,p.ty,4)

end

end

fget is a function which takes, at a minimum, a tile index and is usually used in conjunction with mget. Try something like this:

function overlap(x, y) if btn(5) and fget(mget(p.x/8, p.y/8), 3) then mset(p.tx, p.ty, 4) end end |

Or maybe since you're passing an x and y coordinate into the function, this:

function overlap(x, y) if btn(5) and fget(mget(x/8, y/8), 3) then mset(p.tx, p.ty, 4) end end |

'fget == 3' does not really make sense; fget is a function that you need to call in a specific way (see any tutorial about collision, for example pico8 top-down adventure game). It should be something like 'if fget(mget(p.tx/8,p.ty/8),3)' to check if the tile under the player has flag 3 active.

[Please log in to post a comment]