# Merging Games/Level Up (Hopper, Flyer, and Platform games into one game.)

**URL:** https://forum.code.org/t/merging-games-level-up-hopper-flyer-and-platform-games-into-one-game/33728
**Category:** Coding and Debugging Help
**Tags:** csd-unit-3
**Created:** [November 14, 2020, 3:41am UTC](https://forum.code.org/t/merging-games-level-up-hopper-flyer-and-platform-games-into-one-game/33728 "2020-11-14T03:41:44Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![melodi\_kunn](https://avatars.discourse-cdn.com/v4/letter/m/b5a626/32.png) [@melodi\_kunn](https://forum.code.org/u/melodi_kunn)
#### Post date: [November 14, 2020, 3:41am UTC](https://forum.code.org/t/merging-games-level-up-hopper-flyer-and-platform-games-into-one-game/33728/1 "2020-11-14T03:41:44Z")

</div>

[We are trying to combine the three games we created in CS Discoveries Unit 3 into a level up type game. We have tried numerous math statements to only have one appear at a time, but they all just appear simultaneously. Suggestions? .]

**Link to the project or level:** [[https://studio.code.org/projects/gamelab/pa5aVNmnizfUlHaEpS1VfvK3ee88HpLZ9gJDYOuBf7M](https://studio.code.org/projects/gamelab/pa5aVNmnizfUlHaEpS1VfvK3ee88HpLZ9gJDYOuBf7M)]  
**What I expect to happen:** [One game will appear at a time until a certain score is reached and then another game will appear (Hopper - Flyer - Platform]  
**What actually happens:** [All three games are appearing at once.]  
**What I’ve tried:** [We have tried IFs in IFs, IFs in Else If, Sepeater Ifs - but I believe it is our Math statement in the if that is incorrect. We have tried && || what I feel like we need is If the score is between 0 and 5 do this . . . Then when the score is between 6 and 10 do this…]

Thank you for any help you anyone has to offer.  
Melodi

---

<div class="post-metadata">

### Author: ![infinitestasis](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/infinitestasis/32/5047_2.png) [@infinitestasis](https://forum.code.org/u/infinitestasis)
#### Post date: [November 14, 2020, 4:14am UTC](https://forum.code.org/t/merging-games-level-up-hopper-flyer-and-platform-games-into-one-game/33728/2 "2020-11-14T04:14:07Z")

</div>

Merging games is actually kind of difficult. You are going to have to do a lot of editting to your code to make it happen. A lot of simple if statements won’t work. [https://studio.code.org/projects/gamelab/75HxN2zFXQFjQVUmIwLHOji5DZjFb7XKr2FfEgxbtK8](https://studio.code.org/projects/gamelab/75HxN2zFXQFjQVUmIwLHOji5DZjFb7XKr2FfEgxbtK8)

---

<div class="post-metadata">

### Author: ![melynn](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/melynn/32/4925_2.png) [@melynn](https://forum.code.org/u/melynn)
#### Post date: [November 14, 2020, 4:06pm UTC](https://forum.code.org/t/merging-games-level-up-hopper-flyer-and-platform-games-into-one-game/33728/3 "2020-11-14T16:06:02Z")

</div>

Hi @melodi_kunn,

I think you are off to a good start. I like to show [this example](https://studio.code.org/projects/gamelab/m-QrBbYrbwyk2J44ejx33ymBkE15CEgWY5VW37VqkOE) from one of my students when talking about scenes or levels. This technique turns off all the sprites until they are needed. So, the visibility is turned off and then when a conditional statement (which you have built) calls the function, the sprites are made visible and the ones no longer needed are made turned off (visible = false). I know that is a simple explanation but I think you are further along than you think;) Hope this helps! Good luck!

Michelle

---

<div class="post-metadata">

### Author: ![melodi\_kunn](https://avatars.discourse-cdn.com/v4/letter/m/b5a626/32.png) [@melodi\_kunn](https://forum.code.org/u/melodi_kunn)
#### Post date: [November 14, 2020, 5:13pm UTC](https://forum.code.org/t/merging-games-level-up-hopper-flyer-and-platform-games-into-one-game/33728/4 "2020-11-14T17:13:52Z")

</div>

Oh wow! In my head it was simpler. 🙂We don’t have this statements in our Game Lab. Did you create this in Game Lab? Should I have them move their items to a different platform or do we just need to type this statements?  
Thank you -Melodi

---

<div class="post-metadata">

### Author: ![melodi\_kunn](https://avatars.discourse-cdn.com/v4/letter/m/b5a626/32.png) [@melodi\_kunn](https://forum.code.org/u/melodi_kunn)
#### Post date: [November 14, 2020, 5:20pm UTC](https://forum.code.org/t/merging-games-level-up-hopper-flyer-and-platform-games-into-one-game/33728/5 "2020-11-14T17:20:06Z")

</div>

THANK YOU! I had that epiphany during my sleep last night! Thank you for the reminder. 🙂  
Do you know how I can make the other games STOP during a certain score time frame?  
For instance "When the score is between 0 and 10, only the hopper game will respond and the flyer and platform games are dormant. Then when we reach 11, hopper game becomes dormant, platform games remains dormant and flyer game becomes active until the score reaches 20. . . " It is like they are running in the background and depleting our health. I tried a while statement but the screen went blank.

> **[Check out what I made](https://studio.code.org/projects/gamelab/pa5aVNmnizfUlHaEpS1VfvK3ee88HpLZ9gJDYOuBf7M)**
>
> I wrote the code myself with Code.org

  
Thank you for your help!  
Melodi

---

<div class="post-metadata">

### Author: ![infinitestasis](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/infinitestasis/32/5047_2.png) [@infinitestasis](https://forum.code.org/u/infinitestasis)
#### Post date: [November 15, 2020, 3:31am UTC](https://forum.code.org/t/merging-games-level-up-hopper-flyer-and-platform-games-into-one-game/33728/6 "2020-11-15T03:31:00Z")

</div>

The way I did it was really bad implementation and I was still learning javascript’s Object system. this keywords are actually nothing special. It was just to define a local environment so the ‘virtual game’ wouldn’t modify the global environment.

This relates to a topic about virtual machines. In an ideal implementation, you wouldn’t want the virtual machine to be able to write files to your computer would you?

---

<div class="post-metadata">

### Author: ![melynn](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/melynn/32/4925_2.png) [@melynn](https://forum.code.org/u/melynn)
#### Post date: [November 15, 2020, 2:41pm UTC](https://forum.code.org/t/merging-games-level-up-hopper-flyer-and-platform-games-into-one-game/33728/7 "2020-11-15T14:41:20Z")

</div>

There is more than one way to render the sprites “dormant” so they don’t impact health. You could physically move them (the x and y) off the screen and have them stay there until the conditional states they should be part of the game again. You can also [destroy them](https://studio.code.org/docs/gamelab/destroy/) and then recreate them based on the conditional statement. There are probably other ways but those come to mind as fairly easy ways based on your game.  
I see you have questions about this game [on another post](https://forum.code.org/t/possible-bug-game-works-when-it-is-played-outside-of-the-merged-games/33730/2). It is probably best to focus all questions on one post so information is streamlined. To best help you, let’s move all questions to the other post. Good luck!  
Michelle

---

<div class="post-metadata">

### Author: ![melodi\_kunn](https://avatars.discourse-cdn.com/v4/letter/m/b5a626/32.png) [@melodi\_kunn](https://forum.code.org/u/melodi_kunn)
#### Post date: [November 18, 2020, 5:00pm UTC](https://forum.code.org/t/merging-games-level-up-hopper-flyer-and-platform-games-into-one-game/33728/8 "2020-11-18T17:00:04Z")

</div>

Success!! Thank you to everyone that helped.  
If you are looking for an example to share with your class:

> **[Check out what I made](https://studio.code.org/projects/gamelab/pa5aVNmnizfUlHaEpS1VfvK3ee88HpLZ9gJDYOuBf7M)**
>
> I wrote the code myself with Code.org

---

<div class="post-metadata">

### Author: ![melynn](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/melynn/32/4925_2.png) [@melynn](https://forum.code.org/u/melynn)
#### Post date: [November 20, 2020, 11:47pm UTC](https://forum.code.org/t/merging-games-level-up-hopper-flyer-and-platform-games-into-one-game/33728/9 "2020-11-20T23:47:27Z")

</div>

Glad you were successful. Thanks for sharing the final project.
