Zooming Control with a 2D Camera
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
. I've tried a few other cominations, but no luck.
Does anyone have any advice?
Thanks in advance
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
. 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
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."
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!
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."
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
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
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

