how to make a bomb?

id: 630584

category: Help with Scripts

posts: 18

Ducky0112 Ducky0112 loading
when green flag clicked
say [bomb does nothing]
I want to make a bomb that kills anything close to it.
What do you mean by a bomb? You can make sprites hide when they're touching the bomb sprite I suppose, but you weren't too clear with your question.
RT_Borg RT_Borg loading
Hi Ducky0112,

Something like this?

Demo: Explosion
https://scratch.mit.edu/projects/734784484

If you use the explosion costumes or sound, don't forget to copy the Notes and Credits into your project.

– RT_Borg
Ducky0112 Ducky0112 loading

RT_Borg wrote:

Hi Ducky0112,

Something like this?

Demo: Explosion
https://scratch.mit.edu/projects/734784484

If you use the explosion costumes or sound, don't forget to copy the Notes and Credits into your project.

– RT_Borg
Ok Thank you
Ducky0112 Ducky0112 loading

legendary34678 wrote:

What do you mean by a bomb? You can make sprites hide when they're touching the bomb sprite I suppose, but you weren't too clear with your question.
I mean that any clone would be destroyed if near the bomb when exploding.
when green flag clicked
if <near bomb> then
explode and be gone
end
pearldealer pearldealer loading

Ducky0112 wrote:

legendary34678 wrote:

What do you mean by a bomb? You can make sprites hide when they're touching the bomb sprite I suppose, but you weren't too clear with your question.
I mean that any clone would be destroyed if near the bomb when exploding.
when green flag clicked
if <near bomb> then
explode and be gone
end
So make a variable an have it be the area and have it hide specific sprites within the area
RT_Borg RT_Borg loading

pearldealer wrote:

So make a variable an have it be the area and have it hide specific sprites within the area

Hi pearldealer, you almost never want to hide clones. Unless a clone is being hidden briefly to be shown again later, you generally want to “delete this clone”. The danger is using up your 300 clone limit. I've seen so many projects here on Help with Scripts with strange bugs caused when clones were hidden instead of deleted.

– RT_Borg
Jereb-co7 Jereb-co7 loading
Are you trying to anger the scratch lords?
SMGHecTa SMGHecTa loading
Everything that the bomb touch
G O N E
WsDanzel WsDanzel loading

SMGHecTa wrote:

Everything that the bomb touch
G O N E
Everything that the bomb touch:
explode
You can put this code in the sprite that will have the destroy-able objects.

when I receive [bomb exploded v]
if ((distance to [bomb v]) < (30)) then
//"bomb" refers to the bomb sprite. If it's named something else, change this code.
delete this clone
//this is where you put the code that destroys the object. if it's not a clone, you can use "hide" block
end

This will detect if the object is within 30 units (I think it's measured In pixels but i'm not sure) of the bomb when it explodes. If it is, it destroys the object. You can make the number “30” bigger or smaller if you want the explosion radius to be bigger or smaller.

Then put this code in the explosion script in the bomb sprite:
broadcast [bomb exploded v]
This just triggered the script that's responsible for destroying the objects in range of the bomb.
Potahtoe_ Potahtoe_ loading

Ducky0112 wrote:

when green flag clicked
say [bomb does nothing]
I want to make a bomb that kills anything close to it.

ig you could make a “bomb sprite” and after a set amount of time (or if a condition is met), if the player is in the range (you could do this with hitboxes maybe? or you can compare the different x and y values) it'll detonate and do you what you want it to do

not the most helpful post but it should hopefully give you a simple understanding of how you can implement it.
SMGHecTa SMGHecTa loading

WsDanzel wrote:

SMGHecTa wrote:

Everything that the bomb touch
G O N E
Everything that the bomb touch:
explode
Nobody cares, asked, and smelled
SMGHecTa SMGHecTa loading
darn it i was sayin about the virsu
froggyhatto froggyhatto loading
when green flag clicked
glide () secs to x: (0) y: (-190)
switch costume to [explosion]
if <touching [anything] ?> then
broadcast [ dead]
end
JIM-13 JIM-13 loading
is there anything to make a falling bomb?
Norse7 Norse7 loading
you could add gravity like so:

set [ gravityIncrement] to [2]
set [ gravity] to [0]
forever
change [ gravity] by ((0) - (gravityIncrement))
change y by (gravity)
end
Malicondi Malicondi loading
Please stop necroposting, this topic is several years old.