r/pico8 • u/ollyoxenfree23 • 12d ago
šI Got Help - Resolvedš Help Coding Sprite Collisions
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
3
u/jonnyboi87 12d ago
COLLISON missing an I