What coordinate system do u use in ur game?
so do you use a mixture of coordinate systems, or jut one, and which one and why?
What coordinate system do u use in ur game?
so do you use a mixture of coordinate systems, or jut one, and which one and why?
Actually, we have made classes specifically for supporting different coordinate systems at the same time, in our current project, which is a real-time strategy game.
We have one base class, CoordinateSystem, which can manage some transformations. Then there is a subclass, TileMap, which makes it possible to store different kinds of objects at each location.
At the lowest level we use a very fine resolution - a game world of several million units on each side (which are integers, not floating point, since this among other things makes the interoperability with other maps somewhat simpler). We can “nest” other coordinate systems, such as the screen pixel coordinate system, wich is more coarse. We use a TileMap of something like 64x64 tiles to store terrain tiles, and another TileMap to manage collision detection efficiently. Last, we have a somewhat low-res coordinate system to manage a small overview map.
Yes, you usually need more than just one type of coordinates:
-overview map
-regular map
-OpenGL coordinates
-…
But you should only define the coordinates once though. I would suggest
you have some sort of master coordinates, from which you derive the other
coordinates. Use “meter” or something, so you know what the meaning of
your master coordinates are. E.g.
public class Coordinates {
// master coordinates in METERS!
private float x;
private float y;
private float z; // height (if you don't need it, just leave it at 0)
+setter/getters for x, y and z
+getter for overview map:
public Point getOverviewCoordinates() {
Point point = new Point();
point.setX(x * "some scale factor");
point.setY(y * "some scale factor");
return point
}
+getters for other maps
}