Rainbow Car


Fancy Shmancy! I like the changing colors!

1 Like

I like the idea that the car is moving through traffic. I can’t help myself but when I see a great game, I just want to tweak it a little bit. :face_with_hand_over_mouth:

To make it look like the car is travelling over a road, I removed the stripes from the background and added them as two sprites that span the entire width of the screen (160 pixels; background1 & background2). The first is positioned to the left of the screen and the second to just outside to the right of the screen.

I noticed that you set the velocity of the projectiles to -45 (pixels per second), so I set that to a variable ‘gameSpeed’. That way I could move the background sprites to the same speed. In the game update I check if they have left the screen (on the left) and place back over to the other side.

I hope you enjoy this version.

1 Like

It looks the same, can you tell me what you did to it

He did this.

1 Like

In my previous screen shot from yesterday, all code highlighted in yellow is what I changed. Short version.

In your game the background has three stripes, which do not move. In my game you should see four stripes appear, because there are two sprites that move behind each other.

A - - - B - - -

[A = background1 B = background2]

When sprite A (background1) leaves the screen, I put it back to the right of the screen. Meanwhile, while A is moving left, so is B.

B - - - A - - -


This code just says:
“if the right side of the sprites is less than 0” (it is no longer visible on the screen)
“set the left side of the sprite to appear at the width of the screen” (so it is now on the right side of the screen).

I hope I haven’t confused you too much.