Hit boxes on oblong/shaped shots?

This is the main shmups forum. Chat about shmups in here - keep it on-topic please!
Post Reply
User avatar
Pixel_Outlaw
Posts: 2646
Joined: Sun Mar 26, 2006 3:27 am

Hit boxes on oblong/shaped shots?

Post by Pixel_Outlaw »

Does anyone know what the standard hitbox is like for the oblong bullets?
I know in rRootage you can see them as squares but I'm not sure about the games with hidden hitboxes like those offered in the arcades.

I assume they just use a square hitbox the same width as the narrowest part of the shaped bullet?
I can't imagine doing pixel perfect collision for shaped bullets back in the early Cave days.
Most people would not try to fly between oblong shots if they overlap visually maybe they get away with squares there.

Any information might be helpful, thinking about adding oblong shots in a game of mine.
From a programming perspective rectangle hitboxes are the easiest collision test on the CPU in most cases.
Some of the best shmups don't actually end in a vowel.
No, this game is not Space Invaders.
User avatar
Shepardus
Posts: 3505
Joined: Sat Dec 13, 2014 10:01 pm
Location: Ringing the bells of fortune

Re: Hit boxes on oblong/shaped shots?

Post by Shepardus »

I remember seeing an image showing hitboxes for various bullet types in Touhou (anybody got a link to it?) - they were all squares including the knife bullets.
Image
NTSC-J: You know STGs are in trouble when you have threads on how to introduce them to a wider audience and get more people playing followed by threads on how to get its hardcore fan base to play them, too.
1CCs | Twitch | YouTube
User avatar
ciox
Posts: 1008
Joined: Sun Feb 12, 2012 5:29 pm
Location: Romania

Re: Hit boxes on oblong/shaped shots?

Post by ciox »

Most oblong shots just have a small circular or square or pixel-sized hitbox right in the middle from what I've seen, this makes it annoying (but still sort of fun in a weird way) to dodge through very slow oblong shots since most of their sprite is a "fake threat" and their oblong shape doesn't help you quickly judge their direction anymore which is the original purpose of oblong shots.

There's still some anomalies, like Pink Sweets had some very large oblong bullets and used multiple small squares for their collision, looked really odd since the two squares were so far apart it seemed you could fly between them.
User avatar
Sumez
Posts: 8825
Joined: Fri Feb 18, 2011 10:11 am
Location: Denmarku
Contact:

Re: Hit boxes on oblong/shaped shots?

Post by Sumez »

Anything other than squares, lines or single pixels would be way too heavy to calculate for any shoot'em up running on old school 2D hardware, or even bullet hell shooters running on somewhat newer hardware. Remember they have to check if every single bullet or obstacle hits the player on every single frame.
User avatar
Shepardus
Posts: 3505
Joined: Sat Dec 13, 2014 10:01 pm
Location: Ringing the bells of fortune

Re: Hit boxes on oblong/shaped shots?

Post by Shepardus »

Circle-to-circle collision detection is also cheap, as that's just a distance check. But yes, there's little reason for shmups to use more than rectangles and/or circles. Players aren't going to mind if the hitbox is a little more forgiving than it looks. There's a lot you can do with just rectangles. IIRC "Taito lasers" in games like RayForce are made of a string of rectangles.
Image
NTSC-J: You know STGs are in trouble when you have threads on how to introduce them to a wider audience and get more people playing followed by threads on how to get its hardcore fan base to play them, too.
1CCs | Twitch | YouTube
User avatar
ciox
Posts: 1008
Joined: Sun Feb 12, 2012 5:29 pm
Location: Romania

Re: Hit boxes on oblong/shaped shots?

Post by ciox »

Shepardus wrote: There's a lot you can do with just rectangles. IIRC "Taito lasers" in games like RayForce are made of a string of rectangles.
Looking through the test mode in Batrider is pretty fun, you can find all orientations of Envy's giant blue scream attack there and each has its collision done separately with lots of small rectangles, presumably hand-placed.
User avatar
Sumez
Posts: 8825
Joined: Fri Feb 18, 2011 10:11 am
Location: Denmarku
Contact:

Re: Hit boxes on oblong/shaped shots?

Post by Sumez »

Shepardus wrote:Circle-to-circle collision detection is also cheap, as that's just a distance check. But yes, there's little reason for shmups to use more than rectangles and/or circles.
A 2 dimensional distance check requires trigonometry though. Not a problem on modern hardware, but definitely a lot more expensive than simple additions and subtractions. :)
User avatar
Shepardus
Posts: 3505
Joined: Sat Dec 13, 2014 10:01 pm
Location: Ringing the bells of fortune

Re: Hit boxes on oblong/shaped shots?

Post by Shepardus »

Not between two circles, unless you count squaring numbers and using the Pythagorean Theorem as trigonometry. Maybe the multiplication's more expensive than addition, but it's not like you're taking sines or cosines. It should be negligible even on old processors.
Image
NTSC-J: You know STGs are in trouble when you have threads on how to introduce them to a wider audience and get more people playing followed by threads on how to get its hardcore fan base to play them, too.
1CCs | Twitch | YouTube
User avatar
ciox
Posts: 1008
Joined: Sun Feb 12, 2012 5:29 pm
Location: Romania

Re: Hit boxes on oblong/shaped shots?

Post by ciox »

Circle collision is pretty efficient, some devs like it so much, they use it even on bosses, not exactly where you'd expect to see it

Image
User avatar
Squire Grooktook
Posts: 5997
Joined: Sat Jan 12, 2013 2:39 am

Re: Hit boxes on oblong/shaped shots?

Post by Squire Grooktook »

Hishouzame uses circles, and that games pretty ancient.
Sumez wrote:Remember they have to check if every single bullet or obstacle hits the player on every single frame.
As I understand it, the generally accepted method is to divide the screen into a grid and then only check for collisions within the sector that the player currently occupies. So, IIRC you're not doing checks on things outside a certain range of the player.
RegalSin wrote:Japan an almost perfect society always threatened by outsiders....................

Instead I am stuck in the America's where women rule with an iron crotch, and a man could get arrested for sitting behind a computer too long.
Aeon Zenith - My STG.
User avatar
Sumez
Posts: 8825
Joined: Fri Feb 18, 2011 10:11 am
Location: Denmarku
Contact:

Re: Hit boxes on oblong/shaped shots?

Post by Sumez »

Yeah, that's pretty much the 101 on collision detection. That said, without having done the actual math, and assuming you only have basic CPU opcodes to work with (no GPU to help you do complex math), checking an axis aligned box should always be several times as fast as a circular hitbox, meaning you can afford as many more hitboxes on screen.

I'm sure a ton of shmups use circular hitboxes, especially newer games, just like there are probably a lot that use slanted boxes, etc., I'm just outlining the advantage to "faking out" and sticking to square hitboxes that I'm sure a lot of games in the genre still does. If you go all the way back to the NES you'll probably find a bunch of games that will occasionally allow you to pass directly through a bullet without being detected, as the game may not check for bullet collisions on every single frame.
User avatar
Some-Mist
Posts: 1676
Joined: Fri Aug 13, 2010 1:20 am
Location: Chicago

Re: Hit boxes on oblong/shaped shots?

Post by Some-Mist »

I'd be curious to see the hitbox for the long bullets in muchi muchi pork since a lot of those hitboxes seem very large.
a creature... half solid half gas
User avatar
Shepardus
Posts: 3505
Joined: Sat Dec 13, 2014 10:01 pm
Location: Ringing the bells of fortune

Re: Hit boxes on oblong/shaped shots?

Post by Shepardus »

Sumez wrote:the game may not check for bullet collisions on every single frame.
DOJ does this too - I tink it checks half the bullets every frame.
Image
NTSC-J: You know STGs are in trouble when you have threads on how to introduce them to a wider audience and get more people playing followed by threads on how to get its hardcore fan base to play them, too.
1CCs | Twitch | YouTube
User avatar
Pixel_Outlaw
Posts: 2646
Joined: Sun Mar 26, 2006 3:27 am

Re: Hit boxes on oblong/shaped shots?

Post by Pixel_Outlaw »

Some-Mist wrote:I'd be curious to see the hitbox for the long bullets in muchi muchi pork since a lot of those hitboxes seem very large.
Me too, especially the big green shot in the middle there. Don't recall if they have rotated versions of those or not. If not you could use a tall rectangle and be good to go.

Image


I recall Cardinal Sins/Judgement Silversword and V-V/Grindstormer both having some rotating enemy shots too. That spin as they move.
They have odd pill shaped shots. Like em stylistically though.
Image
Image

Would be cool if anyone has a way to dig some hitboxes out of some classic games.
Some of the best shmups don't actually end in a vowel.
No, this game is not Space Invaders.
User avatar
Sumez
Posts: 8825
Joined: Fri Feb 18, 2011 10:11 am
Location: Denmarku
Contact:

Re: Hit boxes on oblong/shaped shots?

Post by Sumez »

As someone else said, those are most likely just made of two boxes or two circles - or maybe even just one (with the visual effect just there to indicate its direction) Anything more complex really wouldn't be worth the effort. Video game programming is full of stuff like that.
User avatar
trap15
Posts: 7835
Joined: Mon Aug 31, 2009 4:13 am
Location: 東京都杉並区
Contact:

Re: Hit boxes on oblong/shaped shots?

Post by trap15 »

The spinning bullets only have a hitbox in the middle. The large "bullet" bullets in most YGW games are two hitboxes placed depending on the frame. Generally most "long" bullets only have a hitbox in the middle.

Hitcircles are generally performing similarly to hitboxes, it depends on your CPU. A very large number of shooters actually don't divide the screen into buckets, because doing the adjustments for sorting/resorting every frame generally manages to take more time than just doing all the possible collision checks anyways.
@trap0xf | daifukkat.su/blog | scores | FIRE LANCER
<S.Yagawa> I like the challenge of "doing the impossible" with older hardware, and pushing it as far as it can go.
User avatar
Shepardus
Posts: 3505
Joined: Sat Dec 13, 2014 10:01 pm
Location: Ringing the bells of fortune

Re: Hit boxes on oblong/shaped shots?

Post by Shepardus »

With axis-aligned (non-slanted) rectangles the process of classifying the boxes into their regions and choosing the player hitbox's region is pretty much the same logic as the collision checks themselves, just expressed differently, and circles are similar, so as trap15 said partitioning doesn't really help. It's more useful when you've got complex geometry with expensive collision tests that you want to avoid running if possible, which happens a lot more in 3D games than 2D.

Shmups can get away with relatively simple collision detection - they're 2D, deal with small areas (the play area is only the size of the screen or slightly larger), and usually only require a simple binary check (did you get hit or not), as opposed to figuring out the angle and depth of the collision or trying to resolve it. None of the algorithms should be very demanding unless you're doing something silly like Sand Scorpion with its destructible bullets.
Image
NTSC-J: You know STGs are in trouble when you have threads on how to introduce them to a wider audience and get more people playing followed by threads on how to get its hardcore fan base to play them, too.
1CCs | Twitch | YouTube
User avatar
trap15
Posts: 7835
Joined: Mon Aug 31, 2009 4:13 am
Location: 東京都杉並区
Contact:

Re: Hit boxes on oblong/shaped shots?

Post by trap15 »

The issue with Sand Scorpion is it throws a shitload of "can be hit by player bullet" objects on screen, and it also has the player shoot a ton of bullets. Collision detection being O(n*m) means this gets really bad really quick, especially when you don't write your collision check code very efficiently.
@trap0xf | daifukkat.su/blog | scores | FIRE LANCER
<S.Yagawa> I like the challenge of "doing the impossible" with older hardware, and pushing it as far as it can go.
User avatar
Shepardus
Posts: 3505
Joined: Sat Dec 13, 2014 10:01 pm
Location: Ringing the bells of fortune

Re: Hit boxes on oblong/shaped shots?

Post by Shepardus »

Yup - there's significantly less slowdown if you use the green or red weapons, which don't shoot as many bullets (though even then it still gets pretty bad).

I've been wondering if any games give the player both a circular and a square hitbox. You can use the circular hitbox for circular bullets, and the square hitbox for rectangular bullets. If I had to implement Utsuho's attacks in Subterranean Animism, which have a lot of large circular bullets, some of which change size as they move, that's what I would do (or just use circles for everything, which would be feasible in SA).

I also wonder what the hitboxes look like on Marisa's rotating Final Spark in Imperishable Night or on her laser attacks in Fairy Wars, with the "blocking the beam with ice" mechanic.
Last edited by Shepardus on Tue Nov 29, 2016 10:35 am, edited 4 times in total.
Image
NTSC-J: You know STGs are in trouble when you have threads on how to introduce them to a wider audience and get more people playing followed by threads on how to get its hardcore fan base to play them, too.
1CCs | Twitch | YouTube
User avatar
Sumez
Posts: 8825
Joined: Fri Feb 18, 2011 10:11 am
Location: Denmarku
Contact:

Re: Hit boxes on oblong/shaped shots?

Post by Sumez »

Yeah, partitioning is mostly an issue when you have a lot of object-on-object collisions, complex collisions, and physics simulations and such, not as much when all you care about is whether the player gets hit. You always gotta balance the performance and memory overhead with the cycles you can potentially save.
Post Reply