I am just starting in game development (with web programming background). I want to know how to create 2D game with camera that can zoom in/out and can be moved like map in Google Maps. Could you help me with advise where to look for this, please? Thank you
|
closed as not a real question by Yannbane, Trevor Powell, Byte56, Josh Petrie, bummzack Dec 16 '12 at 13:18
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ.
|
If you have have a way of resizing your canvas, you can implement this easily. Create a camera class (or constructor function, in the case of JavaScript), and make it have properties like zoom, position, maybe even speed and acceleration. Then, when you are rendering it, call this:
You can now move your camera around the world, without actually moving the world. And for zooming... You must have a way of scaling your entire canvas, before/after of rendering anything:
There are different implementations of the In most implementations, though, you'd want to save the state of the canvas, scale, render, and then load the state back. Why? Because scaling with a factor of 0.5 two times in a row wouldn't give you a picture two times larger, but a picture 4 times larger. You're not setting a constant scaling factor by calling Notice how I suggest you don't scale every frame though. Scale only if the |
||||
|
|