Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Currently in my game I handle the logic (collisions, movement) using pixels but I find it very limiting espiecially when thinking about variable speed.

For example Box2D requires you to use coordinates in metres instead of pixels (for example 50 pixels = 1 metr). Also using normal cartesian coordinates would allow me to use trygonometry etc.

Should I use in my logic code coordinates not bound to pixels (ie metres)? Is it a better approach?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

This depends on the combination of frameworks you are using. Sometimes a 2D game framework makes it very difficult to work with coordinates that are not bound to pixels because they were designed specifically for designers to think about their game world in pixel units.

However, it's not a requirement. A game I'm currently working on relies on Box2D units being 1 unit in world coordinates, with each 1 unit grid in world coordinates being able to generally contain one tiled sprite, which is 128x128 pixels. This is strictly by our convention though, as you could simply scale the quad on which the sprite is rendered up or down to your desired size in screen and world coordinates.

Regardless of how your sprites are rendered, you should have a matrices for transforming your sprites' world/rendering coordinates to Box2D coordinates and back. Even if 1 meter == 1 world unit, if you make this flexible from the outset (not that difficult), you'll appreciate the flexibility.

share|improve this answer
    
I use SFML for drawing and the engine itself is being written by me so I have no design limits. So if I make functions for translating between world and screen coords, and use world coords for everything and translate to screen for drawing, will it be a good thing? –  user1873947 Feb 14 '13 at 16:17
    
That sounds like a good thing to me. I can't really oversell the flexibility aspect. –  michael.bartnett Feb 14 '13 at 17:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.