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

#1 2007-05-25 10:46:08

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

Dying, Health, and Mana

How do I make it so that the character will die when its health goes below a certain number?  Also, how do I restrict actions based on the value of a variable?

Offline

 

#2 2007-05-25 11:50:58

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

Re: Dying, Health, and Mana

In both cases you can check the value of a variable using an <if> block from the Control blocks. You can then grab a number comparison from the Numbers blocks and grab your variable from Variables. For example, you could do something like this:

If (Health < 1 )
  Do whatever you need to kill the character

If you want the program to end at that point, add a Stop All Scripts block from Control.

Offline

 

#3 2007-05-27 17:42:02

AlexMitchell
Scratcher
Registered: 2007-05-27
Posts: 1

Re: Dying, Health, and Mana

how would you make it go to a "game over" screen though???

Offline

 

#4 2007-05-27 18:46:20

paulmedwal
Scratcher
Registered: 2007-03-09
Posts: 100+

Re: Dying, Health, and Mana

You can make a game over screen multiple ways.

1. You can make a "Game Over" sprite, and have that show up.
Example: Deep Sea Treasure http://scratch.mit.edu/projects/paulmedwal/2717 , look in Sprite6's scripts, it says "When I receive Game Over" to show itself. Game Over is broadcast when a bomb hits the boat.

2. You can change the background and have it say Game Over.
Example: Stop the Invasion http://scratch.mit.edu/projects/paulmedwal/547 If you look at the Stage's Script (yes, there are a lot) there is one that says, "When I receive Game Over" and it changes the background.

I know my games are complicated, but the concept is pretty easy. Just use the broadcast/when I receive blocks to tell the game "Game Over" and have it do the stuff you want.

Paulmedwal


clutter.scratch.mit.edu Visit the Clutter site to create multi-scene stories and multi-level games with Scratch.

Offline

 

#5 2007-05-27 21:33:23

dmagee
Scratcher
Registered: 2007-05-17
Posts: 13

Re: Dying, Health, and Mana

Just to pimp my own work I'll point out my asteroids game has life, and a game over screen. Download it and check out the code.

http://scratch.mit.edu/projects/dmagee/5670

Offline

 

Board footer