I want to draw some vectors and few sprites in a 2D world.Problem is that they should be precise. For example a vector has position (5000000.65,556666). That depends on user. He might want to add something at 10,5 or 5000000.65,556666 !

Using a viewport with proper transform I can draw these on screen. However GDI+ I use works with floats. In case I zoom eg: 2x viewport's translate will be 5000000.65 *2 which wont fit into a float. It gets worse with larger zooms.

Approach 1
One solution seems a write custom matrix with doubles to perform transform from and to screen coords. The downside is that when panning/moving I have to recaclulate all vectors positions

Approach 2 Divide the world in smaller parts. However this complex to me and seems to not take care of all cases.
Is there any better solution ?

  • \$\begingroup\$ what do you mean "It gets worse with larger zooms" ? if your world is larger than 10.000.000 pixels, you could simply divide it into smaller parts as you said, so that it barely fits into a vector2 (float,float). I don't understand how your world could possibly be that big though. \$\endgroup\$ – dimitris93 Mar 17 '15 at 23:31
  • \$\begingroup\$ If it relates to real world it is. eg GIS stuff \$\endgroup\$ – GorillaApe Mar 17 '15 at 23:32
  • 1
    \$\begingroup\$ so you are saying you have created a game map by single handedly placing textures, on static 2D positions, that could fill up a 10.000.000,10.000.000 pixel range ? even so, why don't you just split the map in half then ? if it was something that relates to real world, you could group the world in countries, where each country would have a position a width and a height, instead of just randomly splitting the map in N smaller maps that don't share anything in common, and your player position would be like (Country,X,Y) \$\endgroup\$ – dimitris93 Mar 17 '15 at 23:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.