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

#1 2009-02-05 07:58:32

matthewlowery
Scratcher
Registered: 2009-02-05
Posts: 1

How Do I Make The Score Not Go Below 0?

I have a shooter game I'm making. And I have an Ammo variable. I'm trying to make it so that when the score reaches 0, you can't shoot and the score can't go below 0.
Anybody know how I can do this?

Offline

 

#2 2009-02-05 08:10:14

technoguyx
Scratcher
Registered: 2008-10-18
Posts: 1000+

Re: How Do I Make The Score Not Go Below 0?

matthewlowery wrote:

I have a shooter game I'm making. And I have an Ammo variable. I'm trying to make it so that when the score reaches 0, you can't shoot and the score can't go below 0.
Anybody know how I can do this?

[blocks]<when green flag clicked>
<forever if><( <{ AMMO }> <<> 0 )>
<set{ AMMO }to( 0
<end>

<when[ shoot key ]key pressed>
<if><( <{ AMMO }> <>> 0 )>
[insert shooting scripts here]
<end>[/blocks]

Last edited by technoguyx (2009-02-05 08:10:35)


http://getgnulinux.org/links/en/linuxliberated_4_78x116.png

Offline

 

#3 2009-02-05 08:11:00

dsdude10
Scratcher
Registered: 2007-09-22
Posts: 500+

Re: How Do I Make The Score Not Go Below 0?

all  you have to do is


<when green flag clicked>
<forever if> <( <{ score  }> <<> 0  )>
<set{ ammo  }to( 0
<end>

Offline

 

#4 2009-02-05 12:17:14

Zelda123
Scratcher
Registered: 2007-11-21
Posts: 1000+

Re: How Do I Make The Score Not Go Below 0?

If using space to shoot, use this:

<when green flag clicked>
<forever>
<if> <key[ Space ]pressed?>
Change Ammo by -1
<if> <( Ammo <>> 0  )>
Do Shoot Actions
<end>
<end>
<end>

You can replace the When Flag Clicked, Forever, If with a When Space Key Pressed if you want.

Last edited by Zelda123 (2009-02-05 12:17:50)

Offline

 

Board footer