How can i make a machine gun that continually shoots bullets if i hold down a button?
Thanks
Offline
Either have lots of bullet sprites, work out how long each one will be visible for (lets say 2 seconds) and work out what firing rate you want (lets say one every 0.1 seconds). So make 20 bullets and 20 broadcast messages (fire 1, fire 2 e.t.c.) and have a script on your machine gun which makes it point towards the mouse and one that says (Sorry no scratchblocks)
forever
if mouse down
broadcast fire 1
wait 0.1 seconds
if mouse down
broadcast fire 2
e.t.c.
Makea bullet that has scripts that go something like
when I recieve fire (whichever number the bullet is)
set fired (a local variable) to 1
repeat 100
move 10 steps
end
set fired to 0
and
when gf clicked
forever
repeat until fired = 1
point towards mouse pointer
end
end
copy this sprite 20 times (the local variables stay individual and this should work. If it doesn't there will only be a small mistake because this is basically the script that I used for a very similair game. That was option 1, option 2 is wait until scratch 2.0 is out and then use teh clone feature and a similair script but have one bullet that always sits in the machine gun and points towards the mouse, then when it is clicked it creates a clone which moves forwards then disappears. If you don't understand look a my project called turret game.
Offline
Is there a way to make it like that if i hold a button down such as "A" ?
Offline