# Help with 2D World and Screen unit with camera

This topic is 3052 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi I have started working on my own game, a game similar to the old classic Master of Orion. Currently have run into a few problems i hope some of you can help with. When creating my universe i would like to specify it in my own unit system like a universe is 50x100 units (HxW), numbers are just an example. And then place objects in this coordinate system, say a planet at 2,10 and so on. My problem then is with rendering and different resolutions. I want the camera to always show lets say 10x10 at zoom level 1 (different zoom levels are handled via transformations to the camera). How would you go about doing this with different resolutions. My current idea was calculating how many pixels a 10x10 would be at any given resolution, but i feel like i'm missing something here, and that it can be done more simple. My next is i'd like a background consisting of different layeres that scrolls when moving the screen (like a distant starfield, each layer scrolling at a different) i've got this working in the x-direction right now, by looping the texture around. it currently just scales to fill the height of the screen, but i would like to implement it in the y-direction too, but i'm a bit stuck on that. I'm currently using XNA and it is a 2D game using the XNA spritebatch. I've though about moving to 3D if that would make it easier. [Edited by - Firestar_Jes on February 15, 2010 4:19:48 AM]

##### Share on other sites
It sounds like for what you are doing you dont need to worry about this. You can program you game completely in you own space / coordinate system and not worry about the resolution, as long as you are always working in a 3D camera space. The DX will rasterize the picture for you, dont worry about the number is pixels.

However it IS a problem for two things.

One, the apect ratio of the projection matrix can cause differences for resolutions of difference aspect rations. If you always use 45' then the rasterized image will contain more image (from you world space) on a wider aspect ration than a thiner one. You can fix this by dynamically setting the aspect ration for the view project based on the aspect ration of the resolution in use.

Two, if you are using a vertex shader that renders directly to screen coodinates, which you would probably do in rendering 2D images. In this case the coordinates you using to place your geometry are subject to whatever the resolution is at. You can fix this problem by using directly normalized screen coordinates.

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 13
• 9
• 12
• 9
• ### Forum Statistics

• Total Topics
631438
• Total Posts
3000073
×