metiscus / derpy

0 stars 0 forks source link

TMX Coordinate System #1

Open metiscus opened 9 years ago

metiscus commented 9 years ago

The coordinate system from the TMX files appears to be upside down and backwards. It requires some mathematical gymnastics to get objects positioned properly between physics and the rendering engine.

As an example,

            //\Note: these need converted by /32?
            //HACK!! flipping due to coordinate issues
            float x, y, width, height;
            x = rectPtr->getX() / 64.f - 1;
            y = rectPtr->getY() / 64.f - 1;
            width = rectPtr->getW() / 64.f; 
            height = rectPtr->getH() / 64.f;

This code is required as part of the map_physics demonstration in order to have the physics debug rectangles actually appear where they are supposed to be. The TMX parser should take care of these issues and not require the application to handle it. A standard definition of coordinate systems would make this easier.

metiscus commented 9 years ago

So these numbers are actually correct if the map is taken to be in pixels. The demo was previously using tile based coordinates.