Log In  

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

P#97529 2021-09-19 05:24 ( Edited 2021-09-19 05:32)

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
P#97559 2021-09-19 19:41

'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.

P#97560 2021-09-19 19:43 ( Edited 2021-09-19 19:44)

thanks for the help

P#97772 2021-09-25 03:19

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-04-19 20:37:16 | 0.006s | Q:13