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

#1 2010-05-08 22:37:56

4lover
Scratcher
Registered: 2010-04-24
Posts: 500+

how do you make guys shoot?

how do you make guys shoot when you press a button.


Check out this awesome new zombie-cod type of game: http://scratch.mit.edu/projects/4lover/1975649

Offline

 

#2 2010-05-09 00:03:49

frozenveinz
Scratcher
Registered: 2010-04-24
Posts: 28

Re: how do you make guys shoot?

Umm, heres the code that ive used in the past. It's not that good but it works atleast:

So you make a sprite for your bullet or whateve. Laser, something like  that. Then you make a sprite for who you wasnt to shoot it.

Now add these codes to the gun/shooter/persoon/cat with laser eyes:

<when[ space ]key pressed>
<broadcast[ shoot
<wait( 0.3 )secsc>   This is your shot delay. change it to how fast you want to shoot.

<when green flag clicked>
<forever>
     <if> <( <direction> <=> 90 )>
     <set{ x1 }to( (( <x position> <+> 5 ))      tweak it to get the right amount of buffer
     <end>
     <if> <( <direction> <=> -90 )>
     <set{ <{ x1 }> }to( (( <x position> <-> 5 ))
     <end>
     <set{ <{ y1 }> }to( (( <y position> <+> 5 ))  tweak this 1 to (u might need to change + to -
     <set{ dir1 }to( <direction>
<end>

Now.. add this code to the bullet:

<when I receive[ shoot
<show>
<go to x sad  <{ x1 }> )y sad  <{ y1 }>
<point in direction( <{ dir1 }>
<move( 480 )steps>
<hide>
<go to x sad  x1 )y sad  y1


Once your done with that, make three variables called x1, y1, and dir1. make sure theyre set to "for all sprites.

Last edited by frozenveinz (2010-05-09 00:09:40)


http://i970.photobucket.com/albums/ae184/frozenveinz/RickRoll.gif

Offline

 

Board footer