this post was submitted on 06 Sep 2023
5 points (100.0% liked)

Godot

5840 readers
6 users here now

Welcome to the programming.dev Godot community!

This is a place where you can discuss about anything relating to the Godot game engine. Feel free to ask questions, post tutorials, show off your godot game, etc.

Make sure to follow the Godot CoC while chatting

We have a matrix room that can be used for chatting with other members of the community here

Links

Other Communities

Rules

We have a four strike system in this community where you get warned the first time you break a rule, then given a week ban, then given a year ban, then a permanent ban. Certain actions may bypass this and go straight to permanent ban if severe enough and done with malicious intent

Wormhole

!roguelikedev@programming.dev

Credits

founded 1 year ago
MODERATORS
 

I'm trying to make something in 2d where once the player reaches the end of the level, they're back at the beginning and it just keeps going like that. I could imagine how this could be done in terms of setting the player position, but if I have a scrolling parallax background, how would I make that match up reliably?

top 2 comments
sorted by: hot top controversial new old
[โ€“] Ogeon@programming.dev 2 points 1 year ago

Do you want the background to have looped back to the start after one cycle? If so, you probably have to make it repeat N times more than the foreground, and move by a factor of 1/N in comparison to the foreground. Or put another way, have 1/N times the length. That means that after one cycle, the background has moved a distance of 1/N, but also repeated exactly once.

I hope this makes sense...

[โ€“] bstix@feddit.dk 1 points 1 year ago* (last edited 1 year ago)

Either have the background sync up with the level at the place where the level loops, or don't sync at all, by keeping two sets of player positions. One for the level, which you can reset when you want the player to restart and then one for the background which is reset/looped separately and independent on the level position.