Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / [SOLVED] Parallax and player synchronization

Author
Message
Azamaticon
3
Years of Service
User Offline
Joined: 1st Oct 2021
Location:
Posted: 4th Jan 2024 19:51 Edited at: 4th Jan 2024 19:56
Good time of the day! Tell me please. I'm making a side view game, a player on a bus. There is a Parallax Background() function that is responsible for parallax. How can I synchronize it with the movement of the bus? I tried to call the function when the player presses on the gas, but it looks terrible, because when the player releases the gas, and the bus is still going, and the background immediately stops. I want the background to smoothly gain momentum and stop smoothly, depending on the player's speed. I am attaching an archive with a level.

The author of this post has marked a post as an answer.

Go to answer

Azamaticon
3
Years of Service
User Offline
Joined: 1st Oct 2021
Location:
Posted: 4th Jan 2024 20:12
Here is the archive with the level

Attachments

Login to view attachments
hendron
8
Years of Service
User Offline
Joined: 20th Dec 2015
Location:
Posted: 5th Jan 2024 17:18
you would need to multiply each background layer's scrolling speed by the player's current speed
Azamaticon
3
Years of Service
User Offline
Joined: 1st Oct 2021
Location:
Posted: 5th Jan 2024 19:10
Quote: "you would need to multiply each background layer's scrolling speed by the player's current speed"

Please tell me how to find out the player's speed?
hendron
8
Years of Service
User Offline
Joined: 20th Dec 2015
Location:
Posted: 5th Jan 2024 20:10 Edited at: 5th Jan 2024 20:16
This post has been marked by the post author as the answer.
Since it looks like you're using physics, you could probably use GetSpritePhysicsVelocityX(). Alternatively, you could get the player's speed by subtracting the player's x position at the last frame from the player's x position at the current frame, IE



Just note that the 2 methods will return different values, since GetSpritePhysicsVelocityX() returns units (pixels) per second and the alternative method would return units per frame.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 20th Sep 2024 06:15 Edited at: 20th Sep 2024 06:42
not a lot of experience with shifting sprite UV but since i don't see the effect in the release, play with the attached?

note that images need to be power of 2.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-11-21 09:58:31
Your offset time is: 2024-11-21 09:58:31