Sign in to follow this  
Firestar_Jes

Help with 2D World and Screen unit with camera

Recommended Posts

Firestar_Jes    100
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 this post


Link to post
Share on other sites
mososky    100
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this