Archived

This topic is now archived and is closed to further replies.

Metroid-like Tile Game

This topic is 5504 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am working on a game whose gameplay should resemble a metroid-style game. You can read all about it and my updates at http://www.personal.psu.edu/djp211/rnm_web That''s beside the point; in working with my tile engine, I am attempting to develop a way to solve collisions between objects in the game and the map in the game. Presently my method is this: Each frame, the objects are updated and moved. If they are placed in a position that is within a tile on the map, they are adjusted backwards in unit increments until they are not within a tile. This method works so far, but I am planning on implementing objects that are larger than others, so for purposes of map collision every object has an arbitrarily sized bounding box. But this addition has made the process a little trickier (and the game is actually 3D, as described on the site, making things slightly more challenging) and I''ve yet to add to my system to get successful results in all test cases I''ve thrown. All the while, I can''t help but think that this seems too intense to have been used in platform games since the beginning of time. Am I overlooking a simple method of collision detection for a tile based game?

Share this post


Link to post
Share on other sites
Yes, if you just check for a collision between bounding boxes you can''t get enough information from that. What you can do is break it up into separate cases and use collision detection with a point you designate and the map. Like if you want to bounce you players head of the ceiling when he jumps, psuedocode: when moving up check point x,y (which is the top of his head) for collision with ceiling tile.

I got good use from this method in my last game.

Share this post


Link to post
Share on other sites
That''s pretty much what I''m doing

move the object
for(each extreme of the bounding box)
if this point is within a wall
resolve the collision by moving the object back until the point is free

It just seems like a lot of hoopla for something that''s been around for years.

Share this post


Link to post
Share on other sites
quote:

move the object
for(each extreme of the bounding box)
if this point is within a wall
resolve the collision by moving the object back until the point is free


Your method won''t work properly for all cases.

What happens if you have a large bounding box but a part of the level (say, a ledge, or something) intersects the very middle of one of your bounding box sides. Testing the 4 corners won''t do anything.

If it''s a simple tile-based engine, you have to check along the entire side of the bounding box in the direction you are moving. So, start at the level tile at the top-right corner when moving right and go downwards to the bottom-right to make sure there were no intersections.

Something like that should work well -- I remember using it in a simple side scroller I once wrote.

Also, backing up in 1 pixel increments is wasteful and overly complex. If you know which tile you collided with, moving back should be nothing more than a simple subtraction operation. You should be able to do it in 1 fixed set of calculations.

Something like x = tile_x - obj_width

---
Bart

Share this post


Link to post
Share on other sites
Yes, I saw the shortcoming you mentioned about large bounding boxes and small areas a while back but was trying to jump one hurdle at a time.

I will look into implementing the suggestions I have received so far, thanks for them and please let me know how it (my project) looks so far!

Share this post


Link to post
Share on other sites
This might be overkill, but you can get really cool collision detection/responce very easily using ODE (open dynamics engine) It''s an open source project to bring dynamics capabilities to games. I''ve started to use it on my recent project, and things are going well, so maybe it could work for you.

Share this post


Link to post
Share on other sites