so i want to shoot something repeatedly. i tried doing a broadcast and go to function so that the bullet would go to the person then shoot in the direction he is shooting. problem is when i try shooting fast, the bullet that is flying is deleted to make room for the new one that is shot. does anyone know how to make it so that i can shoot something alot without interfering with something else?
Offline
Well your bullet sprites are not really being deleted. It is just whenever you shoot the bullet sprite goes back to the player and it may not have had enough time to hit its target. Try to make it so it can't be shot when it is moving towards a target.
Offline
The only way to have multiple shots on screen is by creating multiple bullet sprites, and you need a means of control to make checks to see which bullets are available and only fires one of them.
Each bullet would likely need a global variable e.g. firing1, firing2... which is zero by default but is set to 1 whilst the bullet is in motion.
Each bulletcwould have a "When I Recieve" block at the start of its firing routine.
Then on your firebutton you check each bullet sequentially, and broadcast the appropriate firing message as soon as you find a bullet that isn't firing.
Then your firing script
Offline
similar to mayhems idea i think you could have one variable called whichbullet.
the first bullet has a script like this.
when key space pressed: if whichbullet=1 carry out fire routine set which bullet to 2
each bullet has a similar script but the last one sets the variable back to 1.
Offline
You can make the scripts more similar by using
whichbullet = (whichbullet +1) mod num_bullets
in each sprite, giving values from 0 to num_bullets-1
The only difference between sprites is what number they compare whichbullet to.
I used this in my polyphonic piano:
http://scratch.mit.edu/projects/kevin_karplus/2160
to have 4 arrows
Offline
bigB wrote:
similar to mayhems idea i think you could have one variable called whichbullet.
the first bullet has a script like this.
when key space pressed: if whichbullet=1 carry out fire routine set which bullet to 2
each bullet has a similar script but the last one sets the variable back to 1.
The difficulty here is that if the 1st bullet has hit an enemy and is therefore theoretically available, but 2 is still in flight, you can either not fire 1, or if it has reset to "bullet 1" you can fire 1, set whichbullet to 2, only to find that bullet 2 hasn't hit anything yet and so isn't available.
Hence my preference for checking for the availability of individual bullets, sequentially.
Offline
I think bigB's idea was to have enough bullets that the first one would have gone off screen, timed-out, or in some other way become available before it is requested again.
This is simpler than having each bullet keep track of its availability, but does require having enough bullet sprites.
Offline