Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » how to make a bomb?
- Ducky0112
-
Scratcher
6 posts
how to make a bomb?
when green flag clickedI want to make a bomb that kills anything close to it.
say [bomb does nothing]
Last edited by Ducky0112 (Sept. 21, 2022 00:12:17)
- legendary34678
-
Scratcher
1000+ posts
how to make a bomb?
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
-
Scratcher
1000+ posts
how to make a bomb?
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
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
-
Scratcher
6 posts
how to make a bomb?
Hi Ducky0112,Ok Thank you
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
-
Scratcher
6 posts
how to make a bomb?
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
Last edited by Ducky0112 (Sept. 21, 2022 15:39:11)
- pearldealer
-
Scratcher
28 posts
how to make a bomb?
So make a variable an have it be the area and have it hide specific sprites within the areaWhat 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
- RT_Borg
-
Scratcher
1000+ posts
how to make a bomb?
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
- SMGHecTa
-
Scratcher
3 posts
how to make a bomb?
Everything that the bomb touch
G O N E
G O N E
Last edited by SMGHecTa (March 5, 2023 04:30:13)
- WsDanzel
-
Scratcher
52 posts
how to make a bomb?
Everything that the bomb touchEverything that the bomb touch:
G O N E
explode
- MrKingofScratch
-
Scratcher
100+ posts
how to make a bomb?
You can put this code in the sprite that will have the destroy-able objects.
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:
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_
-
Scratcher
13 posts
how to make a bomb?
when green flag clickedI want to make a bomb that kills anything close to it.
say [bomb does nothing]
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
-
Scratcher
3 posts
how to make a bomb?
Nobody cares, asked, and smelledEverything that the bomb touchEverything that the bomb touch:
G O N E
explode
- froggyhatto
-
Scratcher
1 post
how to make a bomb?
when green flag clicked
glide () secs to x: (0) y: (-190)
switch costume to [explosion]
if <touching [anything] ?> then
broadcast [ dead]
end
- Norse7
-
Scratcher
100+ posts
how to make a bomb?
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
-
Scratcher
1000+ posts
how to make a bomb?
Please stop necroposting, this topic is several years old.
- Discussion Forums
- » Help with Scripts
-
» how to make a bomb?











