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?
Offline
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
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.
Good luck!
~Tony
Last edited by infinitum3d (2010-03-16 16:38:49)
Offline
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
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
<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
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
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.
Offline
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.
Offline
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
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)
Offline