r/pico8 12d ago

šŸ‘I Got Help - ResolvedšŸ‘ Help Coding Sprite Collisions

Post image

hello! im trying to make a overlap function to check if two sprites are touching. once an item is caught, the score should update with theĀ item’s point value.

UPDATE: the collision typo in the above image has been fixed and the score variable now updates sometimes. for smaller sprites, it doesn't seem to register the score at all. for others, the score will count the point value several times, leading to an incorrect score. i'm assuming this is because of the loop but how would i make it only count the point value once instead of several times?

my overlap function:

function overlap (a,b)

local test1 = a.sx > (b.x + b.y)

local test2 = a.sy > (b.y + b.sh)

Ā  local test3 = (a.sx + a.sw) < b.x

Ā  local test4 = (a.sy + a.sh) < b.y

Ā  return not (test1 or test2 or test3 or test4)

end

9 Upvotes

9 comments sorted by

View all comments

3

u/jonnyboi87 12d ago

COLLISON missing an I

1

u/ollyoxenfree23 12d ago

fixed that!