2D Zooming and Scrolling

Started by
2 comments, last by AvengerDr 18 years, 7 months ago
Hello there! I'm looking for advices on how to implement 2d zooming and scrolling, like it was done in Master of Orion 3. Basically I (will) have a background texture will be the starfield. On top of these textures I have several sun icons. I'm thinking of implementing this via sprite objects. Since the galaxy could be very big and it would become too crowded if it were to be shown in a single screen, I need some zooming. But since I've never done something like that in 2D I'm looking for advices. What is the best practice for zooming and scrolling? For zooming I thought that I could just make the sun icons bigger/smaller depending on the zoom factor. While for scrolling... well obviously I'll need to change the screen coordinates of those icons. But I was wondering if there was a better way! Thanks in advance.
--Avengers UTD Chronicles - My game development blog
Advertisement
If I'm getting what you're saying right...

why not make a big background sprite (check for bounds on this) and place the other sprites on top of it? Then, code the camera so as only to render sprites whose location is within the camera's point of view, and implement code to move the camera instead. That way, you don't actually have to code for the possibility of moving all the sprites around themselves - you just call a camera update to get the pov you need to render.

Join us at: http://www.blade2k.net/piracysucks/to help stop game piracy!
I'm using DirectX's sprite class. One its methods is Draw which accepts several parameters, one of these is a vector3. If I want to draw something at x,y , where x and y are screen coordinates I pass it a (x,y, 0) vector.

This makes all sprites be overlayed on the 3d scene and when I move the camera they stay on top (like a HUD). If I change the z-coordinate they disappear.

What do I have to do in order to make them be affected by the camera?
--Avengers UTD Chronicles - My game development blog
(bump)
So is anyone able to explain me the correct usage of the method "draw" of Managed DirectX? In particular, how can I use the Vector3 parameter to make a sprite appear further away from the camera and not superimposed on the 3d scene?
--Avengers UTD Chronicles - My game development blog

This topic is closed to new replies.

Advertisement