Pages: 1 2
Topic closed
How could you make something like a machine gun shoot multiple bullets one after another with only using 1 sprite for the bullet. Is there a way? I dont care if its complicated or not just tell me if its possible. Thanks
Offline
not as far as i know.
maybe w/ some really complicated script set using the stamp thing.
but not anyway simple at least.
Offline
if there were all to go in the same direction and were equally spaced, you could concievably do something with costumes to make it look like more than one bullet, but otherwise, no - every independent object on screen will need its own sprite
Offline
In response to your comment on my project:
For the basic ammo, I have two sprites. Each sprite's costume shows two bullets. When space is pressed, one sprite (two bullets) is shot. When it is held, the other sprite also is shot. But notice that there is only ever a maximum of four bullets-two from each sprite. The plane cannot shoot until one of the sprites finishes its trajectory after being shot. try downloading the project and looking at the plane's script for shooting- it should have shoot broadcasts separated by wait blocks (so that it waits for the earlier shot to hit the edge of the screen before reusing it)
Your machine gun problem is one that I have noticed on scratch. You have to program almost every single bullet. To make your gun, I would reccomend making a single bullet sprite and copying it many times, programing each copy to shoot a moment after the precious. That is, have the second bullet wait .1 seconds before begining its script, have the third wait .2, etc. There is really no easy way to have many bullets in scratch. The best you can do is to have many sprites and to have them be reussed after they hit an enemy or exit the screen.
Offline
Insteda of glide, I usually use:
Point in direction (main sprite direction)
Repeat until touching edge
>>Move 10
>>Wait 0.05
Offline
I made a scratche project fairly fast called "Making a "machine gun" shoot multiple bullets with one bullet" it shoots one bullet and looks like about 6 you can use it for everything you want feel free to download it its fairly simple too! No mind blowing equations:)
Offline
Mayhem wrote:
Insteda of glide, I usually use:
Point in direction (main sprite direction)
Repeat until touching edge
>>Move 10
>>Wait 0.05
It looks better if you take away the wait and change the move steps to you liking. And if you made a good use of variables, you can use the stamping. Or in a game I am making, I wanted to do this to, so I used a costume for the gun, and a little math about the directions to make them hide (I used 183 for the sum/difference if you wanna try something like this. Like for if it has a positive X coordinate, it would be direction of gun-direction (or
(( Direction of gun <-> <direction> ))
And reversed for a negative X (direction minue direction of gun)
Offline
Mayhem wrote:
no - every independent object on screen will need its own sprite
it may actually be possible to do using stamping so that one sprite acts like many. this would not be ideal though as it is likely to be more stuttery and fairly complex.
Offline
lilhd wrote:
How could you make something like a machine gun shoot multiple bullets one after another with only using 1 sprite for the bullet. Is there a way? I dont care if its complicated or not just tell me if its possible. Thanks
just make alought of costumes. it is simple=)
Offline
My Tank game might (dunno if I uploaded the effect) be a good example. If I did upload it, I made it seem like a bunch were shooting using stamp/clear blocks
Offline
lilhd wrote:
How could you make something like a machine gun shoot multiple bullets one after another with only using 1 sprite for the bullet. Is there a way? I dont care if its complicated or not just tell me if its possible. Thanks
You can do it with any bullets. first, go to the sprite in his shooting position (without his bullets) and hit copy. now edit the sprite, and draw or import the sprite of you bullet(s) in the picture.
Offline
On the Stage:
When flag clicked:
Set bulletCount to 0
Broadcast countBullets and wait
//start game with next broadcast
Broadcast startGame
//space to shoot
When I receive startGame
set bulletCall# to 1
Forever
If (key space pressed?) and (bulletsAvaliable>0)
change bulletCall# by 1
if bulletCall#>countBullets
bulletCall#=1
endIf
broadcast callBullet
endIf
EndForever
Create a bullet sprite with the following code, then copy as many times as you'd like:
When I receive countBullets
change countBullets by 1
set myBullet# to countBullets
//myBullet# is a local variable, each bullet has its own
When I receive callBullet
if bulletCall#=myBullet#
change bulletsAvaliable by -1
//Do the shooting script here
change bulletsAvalaible by 1
endIf
Tell me if this works, since I'm not quite sure. Or look at this project.
Last edited by fullmoon (2008-08-30 15:15:29)
Offline
Mayhem wrote:
Insteda of glide, I usually use:
Point in direction (main sprite direction)
Repeat until touching edge
>>Move 10
>>Wait 0.05
Im not sure which blocks to use for the "repeat until touching edge"
can you please use the blocks to show me
Last edited by Asimo (2009-03-30 06:08:14)
Offline
Asimo wrote:
Mayhem wrote:
Insteda of glide, I usually use:
Point in direction (main sprite direction)
Repeat until touching edge
>>Move 10
>>Wait 0.05Im not sure which blocks to use for the "repeat until touching edge"
can you please use the blocks to show me
<repeat until><touching[ edge
Offline
This is easy!! =~D just go to http://scratch.mit.edu/projects/Marine43753/657539(this)
project by me,(p.s. I know that the dynamics ar'nt there yet but the shootings fine.)
Download it and use that script for the bullets. And I know the shootings * online
but when you download it it works fine.
Offline
Topic closed
Pages: 1 2