[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] 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
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. 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.
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.
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!
Michelle