This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2007-05-23 12:33:57

Klinkin
Scratcher
Registered: 2007-05-23
Posts: 2

Life/Mana/Kill limiting

Ok, so far I have a pretty decent game for my first try.  The black mage moves back and forth and shoots fireballs at monsters.  I have three variables, Life, Mana, and Kills.  They should all be self-explanatory.  I can't figure out how to make the game end when Life hits zero or how to stop the monsters coming at 100 kills.  Any help?

Offline

 

#2 2007-05-23 13:56:51

weissjd
Scratcher
Registered: 2007-05-16
Posts: 64

Re: Life/Mana/Kill limiting

Somewhere you must be decrementing the Life variable. Right after you do that you can add a block that looks like this:

If Life=0
  Stop All Scripts

You could do something similar after incrementing the kills variable.

Offline

 

#3 2007-05-23 22:17:56

mungojelly
Scratcher
Registered: 2007-05-19
Posts: 35

Re: Life/Mana/Kill limiting

For a long time, as a matter of habit, for situations like this I've used greater than (>) and less than (<).  Often it does exactly the same thing as saying "= 0" or "= whatever the max is," but there are a few situations where > & < work better.  For instance, imagine if the life was at 1, and before you got a chance to check it, 2 life was subtracted.  Then you'd be at -1 life, and your sprite would have morphed into an undead zombie sprite. 8D

So this is what I'd say:

If life < 1
   (do whatever happens at the end of the game)

One thing you could do is put this somewhere:

If life < 1
    Broadcast DEAD!

And then you can write a "When I Receive Message DEAD!" on any sprite saying what that sprite does when the game ends.

I hope that helps!

<3

Offline

 

Board footer