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

Started by
2 comments, last by GroZZleR 21 years, 3 months ago
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?
Advertisement
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.
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.
Thanks guys.

Can you point me at an article / tutorial on per pixel collision?

It seems like something I''d need but I haven''t heard of it.

This topic is closed to new replies.

Advertisement