Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

continuous scrolling background image #19

Open
chjno opened this issue Dec 9, 2017 · 1 comment
Open

continuous scrolling background image #19

chjno opened this issue Dec 9, 2017 · 1 comment

Comments

@chjno
Copy link
Owner

chjno commented Dec 9, 2017

Posting from email @eclipsate

Hi Chino,

I remember you gave me a suggestion for how to make a smoother transition for the background in my game. This is the code for my background, I think I said I should have the same image twice so it doesn’t skip when it rotates through? How would I do that?

image(bgImg, bgX, 0);
bgX -= 2;
if (bgX < -width) {
bgX = 0;
}

Thanks!

@chjno
Copy link
Owner Author

chjno commented Dec 9, 2017

Say I'm using this image for my background:

First, I'll draw the same image twice side by side - one at (0,0) and one at (width,0). Then I'll have them both scroll at the same speed. Once the image on the left leaves the screen completely, I can have it jump to the right of the image that is currently on the screen.

http://alpha.editor.p5js.org/chjno/sketches/ByZlypKWM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant