Now that i have finished my animation code (finally...lol) I am going to make a collision code.
Now, i know how to do the map collision (stopping player falling of the screen) but am wondering about the best and easyest to add to way of doing things such as object and enemy ai collision.
If you have any advice on the best way to approach it, that would be great.
BTW, this isn't for Future-Resurection, It's for a secret game im coding!
No details on it yet, but expect it to be big!
hopefully it will be out in about 1 or 2 months! And fully playable
Falling off the edge of the map or edge of the physical screen?
The easiest method for the latter is to set a bounding area:
if sprite.x < 0 then
sprite.x = 0
elseif (sprite.x + sprite.width) > screen.width then
sprite.x = screen.width - sprite.width
end
if sprite.y < 0 then
sprite.y = 0
elseif (sprite.y + sprite.height) > screen.height then
sprite.y = screen.height - sprite.height
end
Edit: misread post. for the enemy to player, box collision will suffice. See my example code in the Dev forums.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks