Discuss Scratch

nighthawk075
Scratcher
18 posts

How to make a sprite shoot projectiles

In the final level of my most recent game I was wondering how to make a sprite shoot projectiles like bullets. I've thought of things like making the projectile part of the sprites costume but I am sure that wont work. thanks for helping
rollercoasterfan
Scratcher
1000+ posts

How to make a sprite shoot projectiles

Well, you could make a seperate sprite which would be the projectile. It would be located in the barrel of the weapon. When the sprite (which will shoot) wants to shoot, you could broadcast a message. When the projectile receives the message, it would move an infinite amount of steps and would hide when it touches the enemy. Something like this:

For sprite that will shoot:
when green flag clicked
if <key [ v] pressed?> then

broadcast [Shoot! v]
end

For bullet:
when I receive [Shoot! v]
move (1000000...) steps
forever

if <touching [enemy v] ?> then

hide
end

end
Hope I helped!
CatsUnited
Scratcher
1000+ posts

How to make a sprite shoot projectiles

You can create a costume in the sprite that's firing it, then you can do this….

when green flag clicked
forever

if <key [ v] pressed?> then

create clone of [myself v]
end

end
when I start as a clone
switch costume to [bullet v]
point towards [mousepointer v]
repeat until <touching [ v] ?>
move (22) steps

wait (0) secs
end
delete this clone
I recommend a variable that restrics firing bullets to avoid lag.
EndermanLife
Scratcher
13 posts

How to make a sprite shoot projectiles

Here : http://scratch.mit.edu/projects/53008220/ : You're welcome to use any scripts inside
nighthawk075
Scratcher
18 posts

How to make a sprite shoot projectiles

Thanks guys you were a big help.
Aquaventurer
Scratcher
9 posts

How to make a sprite shoot projectiles

Thank you so much..
SolarFlame-
Scratcher
19 posts

How to make a sprite shoot projectiles

CatsUnited wrote:

You can create a costume in the sprite that's firing it, then you can do this….

when green flag clicked
forever

if <key [ v] pressed?> then

create clone of [myself v]
end

end
when I start as a clone
switch costume to [bullet v]
point towards [mousepointer v]
repeat until <touching [ v] ?>
move (22) steps

wait (0) secs
end
delete this clone
I recommend a variable that restrics firing bullets to avoid lag.

That could miss it though. I would recommend this:

when green flag clicked
forever
if <key [ v] pressed?> then

create clone of [myself v]
end

end

when I start as a clone
switch costume to [bullet v]
point towards [mousepointer v]
bullet detection
Edit this block to “Run without screen refresh”:
define bullet detection
repeat until <touching [enemy v] ?>
move (1) steps
end
delete this clone
Ventor_10
Scratcher
2 posts

How to make a sprite shoot projectiles

Hey guys!

I just want to know how to make sprites shoot diagonally and forward for my game that i am making called “Bit Wars”.

So, if anyone knows, PLEASE TELL ME!!

Cheers!
fudgeman126
New Scratcher
1 post

How to make a sprite shoot projectiles

How do i make an ENEMY sprite shoot tho?

Powered by DjangoBB