Hello!
I am new to the world of Scratch game making and I was hoping that one of you might be willing to help me script two things in my game. First, I need help making an enemy disappear after being hit with a weapon - basically coding it so that the enemy recognizes that its "dead." Secondly, generating a score for each enemy death; and lastly, creating waves of enemies for each level at different speed intervals - like in Plants vs Zombies how there are a few zombies here and there and when they are all defeated, a huge horde attacks the hero. Any help would be very much appreciated!! Thanks!!
Offline
The first two questions are simple and can be attempted using these blocks.
First create a variable called health.
You will also need a variable called xp.
[scratchblocks]
when gf clicked
set [health] to (5)
when gf clicked
forever if < touching [weapon] >
change [health] by (-1)
end
when gf clicked
if < (health) < [1] >
hide
change [xp] by (1)
end
// the last one is the hardest. To make them move faster at different intervals, make a //variable called round number. This would be the number for the wave.
When gf clicked
set [round number] to (1)
When gf clicked
show
forever
change x by (round number)
wait (0.1) sec.
end
// this will make the enemies move faster with each round.
// these scripts are general, so don't copy them exactly, but edit them to your liking.
Offline
Wow!! Thank you so much!! You've been a huge help!
I do have one more question - is there a way to script an enemy to regenerate at random time intervals after dying?
Offline
AliensFTW wrote:
The first two questions are simple and can be attempted using these blocks.
First create a variable called health.
You will also need a variable called xp.when gf clicked set [health] to (5) when gf clicked forever if < touching [weapon] > change [health] by (-1) end when gf clicked if < (health) < [1] > hide change [xp] by (1) end // the last one is the hardest. To make them move faster at different intervals, make a //variable called round number. This would be the number for the wave. When gf clicked set [round number] to (1) When gf clicked show forever change x by (round number) wait (0.1) sec. end // this will make the enemies move faster with each round. // these scripts are general, so don't copy them exactly, but edit them to your liking.
fixed scratchblocks
Offline
marieawhit wrote:
Wow!! Thank you so much!! You've been a huge help!
I do have one more question - is there a way to script an enemy to regenerate at random time intervals after dying?
when gf clicked forever wait until <(health) = [0]> hide wait (pick random (1) to (10)) secs go to [spawnpoint v]
Offline
berberberber wrote:
when gf clicked forever wait until <(health) = [0]> hide wait (pick random (1) to (10)) secs set [health v] to (5) go to [spawnpoint v]
I added a "set health" block.
Alternatively:
when gf clicked forever wait (pick random (1) to (10)) secs set [health v] to (5) go to [spawnpoint v] repeat until <(health) < (1)> be alive end hide
Last edited by MoreGamesNow (2012-05-02 11:25:05)
Offline
zammer990 wrote:
AliensFTW wrote:
The first two questions are simple and can be attempted using these blocks.
First create a variable called health.
You will also need a variable called xp.when gf clicked set [health] to (5) when gf clicked forever if < touching [weapon v]? > change [health] by (-1) end when gf clicked if < (health) < [1] > hide change [xp] by (1) end // the last one is the hardest. To make them move faster at different intervals, make a //variable called round number. This would be the number for the wave. When gf clicked set [round number] to (1) When gf clicked show forever change x by (round number) wait (0.1) secs end // this will make the enemies move faster with each round. // these scripts are general, so don't copy them exactly, but edit them to your liking.fixed scratchblocks
now they're fixed!
Offline
You guys are amazing! Thank you so much for helping me out on my game!
Offline
marieawhit wrote:
You guys are amazing! Thank you so much for helping me out on my game!
Then, you should request for this topic to be closed by clicking the "Report" button and say that you want this thread closed.
Offline