Top Down Collision
How would I make a top down collision detection. I want the init() function to be called whenever the player touches the white. How would i go about doing this? Here is a link of the project below
https://microstudio.io/Hehefunnyboi2/learningmicroscript/2UPMMBNN/
The link doesn't work...
also I wouldn't call init()
I would rather make a separate function that has code needed and call that function also call that function from init()
so effect is the same but this way you preserve init
function purpose.
@AsianJake sorry I was absent...
You know you cannot make collision if your level is an image not map not set of images but one big image...
It will be like.. well you will get collision all the time.
this is collision like in 'Super Mario Brothers' I don't think you will need more advanced one...
AABB = function(a,b)
if abs(a.x-b.x)<(a.width+b.width)/2 and
abs(a.y-b.y)<(a.height+b.height)/2 then
return true
else
return false
end
end
and your objects will need to have width and height parameters you will check for collision like this for example...
if AABB(player,key) then
//some code
end
And yes there is some sprite collision code but I recommend doing map approach..