Have created a first person shooter game in which sprites appear, glide across the screen, and hide if not clicked.
Each time it is clicked, a sprite will appear again randomly until the shooter misses it on an appearance.
If it is not clicked, it will not appear again.
The game will end when no more sprites appear... and that is the catch. I don't know how to alert the program that the sprite was NOT clicked. There is no "When Not Clicked" block.
As such, now the game simply goes on with nothing left to shoot at. I've considered a number of options, but all seem stymied by the inability to indicate that something didn't happen (sprite clicked).
Thoughts?
Thanks in advance...
Offline
One method you could use is using a variable. Once a sprite gets shot, it'll set the variable to 1, and once it reappears, it'll reset the variable to 0. When you do this, just make sure that each shootable object gets their own variable. And if you want, you could create a twist off of this to give objects health so that they survive more than 1 shot, or you could use a list instead of several variables.
I hope that this helps, and welcome to the Scratch forums!
Offline
ErnieParke wrote:
One method you could use is using a variable. Once a sprite gets shot, it'll set the variable to 1, and once it reappears, it'll reset the variable to 0. When you do this, just make sure that each shootable object gets their own variable. And if you want, you could create a twist off of this to give objects health so that they survive more than 1 shot, or you could use a list instead of several variables.
I hope that this helps, and welcome to the Scratch forums!
I thought about that, but then what?
The sprite appears in its first iteration. Variable Sprite1Alive = 0
From there, there are two options:
1) Sprite is not shot and disappears. Then variable still = 0
2) Sprite is shot and disappears. Variable set to 1. Sprite reappears and sets variable to 0. Repeat until sprite is not shot.
So, what do you do next? That is where I am stuck...
If variable = 0 what? And what do you do when there are 4 or 5 other sprites?
If Sprite1Alive = 0 and Sprite2Alive = 0, etc, then Game Over?
Offline
jamroller wrote:
ErnieParke wrote:
One method you could use is using a variable. Once a sprite gets shot, it'll set the variable to 1, and once it reappears, it'll reset the variable to 0. When you do this, just make sure that each shootable object gets their own variable. And if you want, you could create a twist off of this to give objects health so that they survive more than 1 shot, or you could use a list instead of several variables.
I hope that this helps, and welcome to the Scratch forums!I thought about that, but then what?
The sprite appears in its first iteration. Variable Sprite1Alive = 0
From there, there are two options:
1) Sprite is not shot and disappears. Then variable still = 0
2) Sprite is shot and disappears. Variable set to 1. Sprite reappears and sets variable to 0. Repeat until sprite is not shot.
So, what do you do next? That is where I am stuck...
If variable = 0 what? And what do you do when there are 4 or 5 other sprites?
If Sprite1Alive = 0 and Sprite2Alive = 0, etc, then Game Over?
It doesn't need to be between 1 & 0.
you could have it kind of like this.
when gf clicked set [time v] to [0] forever set [time v] to (timer) wait (0.2) secs when gf clicked set [checking v] to [0] set [variable v] to [1] forever reset timer repeat until <<(time) > (time you want it to show up for per iteration)> or <(checking)=[1]>> if <(variable)=[1]> show and move scripts if (shot?) //whatever scripts you have for shot set [variable v] to [0] hide set [checking v] to [1] end end if <(variable)=[0]> set [variable v] to [1] //have it show up again set [checking v] to [0] else set [variable v] to [2] //to have it not show up again set [checking v] to [1] //just incase setting variable to 2 doesn't work endI'm almost completely sure this will work, if not, please post what's wrong.
Offline