Archived

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

GroZZleR

Collision in a 2D Overhead Game (with a twist!)

Recommended Posts

Hey all, How do you do collision in a 2D overhead game (something like the old Secret of Mana / Chrono Trigger games), where your tile size differents from your player sprite size. Tiles are 32x32 and player sprites are slightly larger at 64x64. The problem is, I can''t do good tile collision because I can''t keep track of what tile the player is on (free movement around the screen). Anyone have any ideas?

Share this post


Link to post
Share on other sites
Well you have tiles which are simply squares so you should be able to use 2d collisions for the big stuff (walls colliding with player). And you can calculate which squares the player would occupy which would allow you to do per pixel collsion if you need it. But more detail would be needed on what you are trying to do to give you a better idea of what you could do.

You should be able to keep track of which tiles the player is on (it could be on up to what.. maybe 6 tiles at once?) just take your tile 0,0 coordinate, translate that to your worldspace then find out how many tiles (and which ones) are 64 pixels away in either direction.

Share this post


Link to post
Share on other sites
I''m pretty sure to find a tile a given point is on, it''s simply position/tile_size, assuming both are integer values. You can do checks based on the four corners of the sprite, or a predefined rectangle representing their feet. If the movement rate and rectangles are small, you can just check the corners. There are some good tutorials on this site for tile based engines if you need more help.

Share this post


Link to post
Share on other sites