Hi folks,
I'm playing around with a little 2d space game and I've got stuck on some maths -- can anyone help?
I'm trying to include a background image that moves at a slower speed that the foreground objects (1/4 speed).
It's a space image that I've tiled to always fill the screen.
That works fine as far as it goes but...
Because my camera has a zoom function (press =/- keys) it quickly looks wrong on other zoom settings, as if objects are moving away from you in relation to the background.
I suspect I also need to draw my background image zoomed but by how much? It's supposed to be a long, long way in the distance.
Maths fail.
The project is attached.
Controls:
Move: Arrows
Fire weapon: Space
Toggle Local Map: L
Zoom in: = key
Zoom out: - key
(zoom map using [ and ])
[SOLVED] Top Down Parallax scrolling and a zoomable camera
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Party member
- Posts: 126
- Joined: Sat May 09, 2015 9:15 pm
[SOLVED] Top Down Parallax scrolling and a zoomable camera
- Attachments
-
- Cosmos.love
- (13.57 MiB) Downloaded 122 times
Last edited by randomnovice on Fri Nov 15, 2019 2:35 pm, edited 1 time in total.
Re: Top Down Parallax scrolling and a zoomable camera
When you zoom the camera you multiply all values by the zoom factor, in foreground and in background.
-
- Party member
- Posts: 126
- Joined: Sat May 09, 2015 9:15 pm
Re: [SOLVED] Top Down Parallax scrolling and a zoomable camera
Okay - I've tweaked it a bit and I think it's okay. Thanks.
Re: [SOLVED] Top Down Parallax scrolling and a zoomable camera
There are two types of zoom. One consists of bringing the camera closer to the target; some 3D design programs do this when you zoom. The other consists of magnifying a small angle of view so it looks bigger; that's what zoom lenses and telescopes do. Playing with both in a real camera, you can get effects such as this one: http://www.formauri.es/personal/pgimeno ... -demo2.jpg
With the first type of zoom, the background would not be altered. With the second, it would. It's a question of choosing the one that looks right, which is something you seem to have managed
With the first type of zoom, the background would not be altered. With the second, it would. It's a question of choosing the one that looks right, which is something you seem to have managed
Who is online
Users browsing this forum: Google [Bot] and 52 guests