Discuss Scratch

player_4534
Scratcher
100+ posts

Bullet Hell Help.

I am making a Touhou Bullet Hell, but, I just cannot figure out HOW to get each bullet a hitbox, of, their own….
Could anybody help?
dem_bot
Scratcher
1000+ posts

Bullet Hell Help.

do all bullets need to collide with all bullets?
the fastest option is to give them square hitboxes defined by four lists: HX1, HX2, HY1, HY2 and use simple logic to determine if two of these overlap.
a slightly more realistic option is to give them round hitboxes, defined by three lists: HX, HY, HR with hr being the radius. Then you can compute the distance between two bullets and see if they're more or less than their total r away from each other. (Pythagoras')
An option that's easier to code is the touching block, but that doesn't tell you which are touching and it is far less computationally efficient (unless the bullets have very simple costumes)
awesome-llama
Scratcher
1000+ posts

Bullet Hell Help.

If using touching blocks, you can make the sprites switch to hitbox costumes, check touching, then switch to the display costume. For clones especially you can use broadcasts to make these happen at the right time and in the right order.

forever
broadcast [switch to hitbox costume v]
broadcast [collision detection v]
broadcast [switch to display costume v]
end


The alternative to touching blocks is to calculate intersections with primitive geometric shapes such as circles and rectangles. For example, two circles are touching if the distance between their centers is less than the sum of their radii. Usually you would store the objects in lists (bullets in your case), and then loop over the items as needed. The lists contain information like positions and dimensions of the hitboxes.


Relevant articles:
https://en.scratch-wiki.info/wiki/Hitbox
https://en.scratch-wiki.info/wiki/Pen_Particles
10goto10
Scratcher
1000+ posts

Bullet Hell Help.

player_4534 wrote:

… I just cannot figure out HOW to get each bullet a hitbox, of, their own….

Sounds like you want some way for each clone to create a hit box and then have it follow that clone. I made a case study where each cat clone causes a hit box be created and then it follows the cat when the cat is clicked.

https://scratch.mit.edu/projects/1378810260

This is not a simple as just switching to a hit box costume but maybe you want the bullets to have different hit boxes so other sprites can detect them differently. For example, one type of hit box might cause 1 point of damage but another type may cause 2 points of damage. Anyway, this is something else to look at.

Last edited by 10goto10 (Sept. 7, 2026 16:23:16)

player_4534
Scratcher
100+ posts

Bullet Hell Help.

awesome-llama wrote:

If using touching blocks, you can make the sprites switch to hitbox costumes, check touching, then switch to the display costume. For clones especially you can use broadcasts to make these happen at the right time and in the right order.

forever
broadcast [switch to hitbox costume v]
broadcast [collision detection v]
broadcast [switch to display costume v]
end


The alternative to touching blocks is to calculate intersections with primitive geometric shapes such as circles and rectangles. For example, two circles are touching if the distance between their centers is less than the sum of their radii. Usually you would store the objects in lists (bullets in your case), and then loop over the items as needed. The lists contain information like positions and dimensions of the hitboxes.


Relevant articles:
https://en.scratch-wiki.info/wiki/Hitbox
https://en.scratch-wiki.info/wiki/Pen_Particles
OMG THANK YOU @awesome_llama !!

Powered by DjangoBB