how do you make guys shoot when you press a button.
Offline
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 <{ x1 }> )y
<{ y1 }>
<point in direction( <{ dir1 }>
<move( 480 )steps>
<hide>
<go to x x1 )y
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)
Offline