Zooming Control with a 2D Camera

Member
Posts: 78
Joined: 2004.06
Post: #1
I'm using a camera control in my 2D platformer game (using BlitzMax if that matters) to 'handle' my image drawing; ie drawing images at (image.x - camera.x),(image.y - camera.y).

Then I had the idea to use layers, which also works OK; drawing to ((image.x*image.layer) - camera.x),((image.y*image.layer) - camera.y)

Now I'd like to add in zooming, and I seem to have hit a brick wall. I thought it would be something like (((image.x*image.layer) - camera.x)*size),(((image.y*image.layer) - camera.y)*size), but that doesn't seem to work right Cry . I've tried a few other cominations, but no luck.

Does anyone have any advice?

Thanks in advance

When in doubt ... read the Read Me
10.5.6 | MacBook Pro 2.5x2 | 4 GB RAM | GeForce 8600M GT
Quote this message in a reply
Moderator
Posts: 529
Joined: 2003.03
Post: #2
So things on layer 2 are to be twice as big, for example?

"Yes, well, that's the sort of blinkered, Philistine pig-ignorance I've come to expect from you non-creative garbage."
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #3
Do an OpenGL and use 3x3 matrices for everything, you can do rotation, translation and scaling with it no problem.

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Moderator
Posts: 529
Joined: 2003.03
Post: #4
If you don't know OpenGL, use the math from here for now: http://easyweb.easynet.co.uk/~mrmeanie/persp/persp.htm

"Yes, well, that's the sort of blinkered, Philistine pig-ignorance I've come to expect from you non-creative garbage."
Quote this message in a reply
Member
Posts: 78
Joined: 2004.06
Post: #5
Aye, that's a good tutorial; I'll look into it thanks.

When in doubt ... read the Read Me
10.5.6 | MacBook Pro 2.5x2 | 4 GB RAM | GeForce 8600M GT
Quote this message in a reply
Member
Posts: 749
Joined: 2003.01
Post: #6
I'd use

apparentX=window.width/2.0+(image.x - camera.x)/distance
apparentY=window.height/2.0+(image.y - camera.y)/distance

where distance is the distance between the camera and the object (which changes depending on the "layer" and if you zoom in-out)

Also you will have to scale the objects inversely to the distance

©h€ck øut µy stuƒƒ åt ragdollsoft.com
New game in development Rubber Ninjas - Mac Games Downloads
Quote this message in a reply
Post Reply