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

[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: []
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.

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.

Hi @melodi_kunn,

I think you are off to a good start. I like to show this example 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!


Oh wow! In my head it was simpler. :slight_smile: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

THANK YOU! I had that epiphany during my sleep last night! Thank you for the reminder. :slight_smile:
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.

Thank you for your help!

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?

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

1 Like

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


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