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

#1 2010-03-16 16:13:12

Aloys1320
Scratcher
Registered: 2010-03-12
Posts: 23

Making ammo work

If any one knows how to, or has any idea how to make ammo work please tell me. I want it so that when I have 0 ammo something cant shoot. Please rely. Thnxs.

Offline

 

#2 2010-03-16 16:20:21

GurkinC
Scratcher
Registered: 2009-11-30
Posts: 100+

Re: Making ammo work

Aloys1320 wrote:

If any one knows how to, or has any idea how to make ammo work please tell me. I want it so that when I have 0 ammo something cant shoot. Please rely. Thnxs.

What scripts are you using for shooting?


Try my latest game, Rolling 2, a 10-level platform game based around the gravity marble.

Offline

 

#3 2010-03-16 16:26:10

Aloys1320
Scratcher
Registered: 2010-03-12
Posts: 23

Re: Making ammo work

GurkinC wrote:

Aloys1320 wrote:

If any one knows how to, or has any idea how to make ammo work please tell me. I want it so that when I have 0 ammo something cant shoot. Please rely. Thnxs.

What scripts are you using for shooting?

ummm i dont know how to show the blocks sooo here it is...

When Z key is pressed
Go to _________
show
play sound
If { direction of ______ = 90
point in direction 90
Repeat 50 { move 20 }

ect for all directions


oh and how do you use the blocks

Offline

 

#4 2010-03-16 16:35:28

infinitum3d
Scratcher
Registered: 2009-05-10
Posts: 100+

Re: Making ammo work

For ammo counting, you need to create a variable called something like "ammoAmount".

   <{   ammoAmount  }>
   <set{  ammoAmount  }to(  100

<when[  space ]key pressed>  <-- in this example SPACE fires a bullet.
<change{  ammoAmount  }by(  -1


This is just an example. If you need specific help, ask and we'll work with you on it.



As for Scratch blocks, look at the Quick Post area below. There are buttons for the various Scratch coding pieces. Click one and it works like smileys. It will be curly brackets like {  }, or < >.   Put the words in between these, with a few spaces around them for legibility.

It takes practice.   smile

Good luck!

~Tony

Last edited by infinitum3d (2010-03-16 16:38:49)

Offline

 

#5 2010-03-16 16:37:08

Aloys1320
Scratcher
Registered: 2010-03-12
Posts: 23

Re: Making ammo work

I have a variable for ammo i just need it so that when ammo reaches 0 than the gun will not shoot.

Offline

 

#6 2010-03-16 16:40:24

infinitum3d
Scratcher
Registered: 2009-05-10
Posts: 100+

Re: Making ammo work

If ammoAmount less than one, stop script?

<when[  SPACE  ]key pressed>
<if>  <(  <{  ammoAmount   }> <<>  1  )>
<stop script>  ?



Or better yet...

<when[  SPACE  ]key pressed>
<if>  <(  <{  ammoAmount   }> <>>  1  )>
SHOOT THE GUN

<else>
<stop script>  ?

Last edited by infinitum3d (2010-03-16 16:42:56)

Offline

 

#7 2010-03-16 16:41:44

GurkinC
Scratcher
Registered: 2009-11-30
Posts: 100+

Re: Making ammo work

Basically just add a script saying "if ammo=0 wait until ammo>0"


Try my latest game, Rolling 2, a 10-level platform game based around the gravity marble.

Offline

 

#8 2010-03-16 16:43:15

Aloys1320
Scratcher
Registered: 2010-03-12
Posts: 23

Re: Making ammo work

infinitum3d wrote:

If ammoAmount less than one, stop script?

<when[  SPACE  ]key pressed>
<if>  <(  <{  ammoAmount   }> <<>  1  )>
<stop script>  ?

Right now i have that and my gun still shoots. Oh and thnxs with the blocks.

Offline

 

#9 2010-03-16 16:44:19

infinitum3d
Scratcher
Registered: 2009-05-10
Posts: 100+

Re: Making ammo work

It usually better to put

< 1

rather than

= 0

just in case the math gets messed up and it goes to -1 for some reason.

Just my opinion.


OK, are you SURE that it's decreasing the ammo count when the gun fires? Set your starting ammo count to a low number, like three, and have the variable displaying when you're testing it (check the box next to it). See if it goes down.

Last edited by infinitum3d (2010-03-16 16:47:15)

Offline

 

#10 2010-03-16 16:48:26

Aloys1320
Scratcher
Registered: 2010-03-12
Posts: 23

Re: Making ammo work

<when[   X   ]key pressed>
<if> <(  ammo  <=>  0  )>
<hide>
<go to[ Human
<stop script>
<else>
<go to[  Human
<show>
<play sound[  gunshot
<if> <(  direction of human  <=>  90  )>
<point in direction(  90
<repeat(  50
<move(  20  )steps>

etc a for all directions.

Offline

 

#11 2010-03-16 16:52:45

Aloys1320
Scratcher
Registered: 2010-03-12
Posts: 23

Re: Making ammo work

infinitum3d wrote:

It usually better to put

< 1

rather than

= 0

just in case the math gets messed up and it goes to -1 for some reason.

Just my opinion.


OK, are you SURE that it's decreasing the ammo count when the gun fires? Set your starting ammo count to a low number, like three, and have the variable displaying when you're testing it (check the box next to it). See if it goes down.

Yes i did all of that and it is still shouting a ghost bullet. The bullet appears but doesn't hurt anything. Its just a black bullet moving across the screen.

Offline

 

#12 2010-03-16 16:53:03

GurkinC
Scratcher
Registered: 2009-11-30
Posts: 100+

Re: Making ammo work

infinitum3d wrote:

It usually better to put

< 1

rather than

= 0

just in case the math gets messed up and it goes to -1 for some reason.

Just my opinion.

Yeah, good point - it can easily have problems if you do something twice in a row really quickly.


Try my latest game, Rolling 2, a 10-level platform game based around the gravity marble.

Offline

 

#13 2010-03-16 16:54:45

GurkinC
Scratcher
Registered: 2009-11-30
Posts: 100+

Re: Making ammo work

Aloys1320 wrote:

Yes i did all of that and it is still shouting a ghost bullet. The bullet appears but doesn't hurt anything. Its just a black bullet moving across the screen.

That`s more likely to be something with the scripts involved when the sprite makes contact with another sprite, not the shooting itself.


Try my latest game, Rolling 2, a 10-level platform game based around the gravity marble.

Offline

 

#14 2010-03-16 16:55:47

Aloys1320
Scratcher
Registered: 2010-03-12
Posts: 23

Re: Making ammo work

Ok i did all of that and it didnt work. I checked over my scripts and found the problem. I have 3 bullet sprites for that gun and on one of the sprites the < 1 was an = 1   thnxs allot for your help.

Offline

 

#15 2010-03-16 16:56:55

infinitum3d
Scratcher
Registered: 2009-05-10
Posts: 100+

Re: Making ammo work

You may want to get rid of the GoTo -Human directly under the HIDE ?


Congrats on finding/fixing the problem!

Last edited by infinitum3d (2010-03-16 16:57:43)

Offline

 

#16 2010-03-16 17:00:42

Aloys1320
Scratcher
Registered: 2010-03-12
Posts: 23

Re: Making ammo work

Thanks but i like the go to human because if one of the other go to humans doesn't work than there is a back up and it is working now .... thanks allot for all of your help.

Offline

 

#17 2010-03-19 12:02:28

Stickman704
Scratcher
Registered: 2009-01-31
Posts: 1000+

Re: Making ammo work

When Z key is pressed
<--------------------------------------- change ammo by -1
Go to _________
show
play sound
If { direction of ______ = 90
point in direction 90
Repeat 50 { move 20 }

Just make a varible called ammo.


Simplese

Edit: Did I write that? Somebody must of been on my account.

Last edited by Stickman704 (2010-05-01 16:23:40)


Dun dun dun dun dun dun.... dun dun dun dun dun dun...  tongue

Offline

 

#18 2010-05-01 16:07:22

Ziggy215
Scratcher
Registered: 2010-04-28
Posts: 9

Re: Making ammo work

when ___ key is pressed
forever--------
|if-- Ammo<1---
|stop script----
------------------
You'll have to create a variable called ammo, if you want a clearer tutorial just ask!

Offline

 

Board footer