# Rainbow Car

**URL:** <https://forum.makecode.com/t/rainbow-car/4348>\
**Category:** Arcade\
**Tags:** game\
**Created:** [November 9, 2020, 10:59pm UTC](https://forum.makecode.com/t/rainbow-car/4348 "2020-11-09T22:59:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![MopishCobra75](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/mopishcobra75/32/2992_2.png) [@MopishCobra75](https://forum.makecode.com/u/MopishCobra75)\
**Post date:** [November 9, 2020, 10:59pm UTC](https://forum.makecode.com/t/rainbow-car/4348/1 "2020-11-09T22:59:36Z")

</div>

> **[Rambow Car](https://arcade.makecode.com/28248-81456-05450-78945)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![Kat](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kat/32/2596_2.png) [@Kat](https://forum.makecode.com/u/Kat)\
**Post date:** [November 10, 2020, 4:27pm UTC](https://forum.makecode.com/t/rainbow-car/4348/2 "2020-11-10T16:27:13Z")

</div>

Fancy Shmancy! I like the changing colors!

---

<div class="post-metadata">

**Author:** ![cosmoscowboy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/cosmoscowboy/32/1718_2.png) [@cosmoscowboy](https://forum.makecode.com/u/cosmoscowboy)\
**Post date:** [November 11, 2020, 11:06pm UTC](https://forum.makecode.com/t/rainbow-car/4348/3 "2020-11-11T23:06:16Z")

</div>

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. 🤭

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.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/1/12f635a433a18787deaf3ab8a992e8fc601dc47a.png)  

> **[Rambow Car (cosmos)](https://arcade.makecode.com/67909-95094-96641-40285)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

I hope you enjoy this version.

---

<div class="post-metadata">

**Author:** ![MopishCobra75](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/mopishcobra75/32/2992_2.png) [@MopishCobra75](https://forum.makecode.com/u/MopishCobra75)\
**Post date:** [November 12, 2020, 2:25am UTC](https://forum.makecode.com/t/rainbow-car/4348/4 "2020-11-12T02:25:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![GameGod](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/gamegod/32/2756_2.png) [@GameGod](https://forum.makecode.com/u/GameGod)\
**Post date:** [November 12, 2020, 2:55am UTC](https://forum.makecode.com/t/rainbow-car/4348/5 "2020-11-12T02:55:08Z")

</div>

> [@cosmoscowboy](#):
>
> 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.

He did this.

---

<div class="post-metadata">

**Author:** ![cosmoscowboy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/cosmoscowboy/32/1718_2.png) [@cosmoscowboy](https://forum.makecode.com/u/cosmoscowboy)\
**Post date:** [November 12, 2020, 7:27pm UTC](https://forum.makecode.com/t/rainbow-car/4348/6 "2020-11-12T19:27:24Z")

</div>

> [@MopishCobra75](#):
>
> It looks the same, can you tell me what you did to it

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 - - -

![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/a/a1cf7f900ad986b36e12d8e9ad815c9b148dd7e0.png)

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.
