It is currently Mon Oct 23, 2017 12:09 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Mon May 29, 2017 5:24 am 
Online
User avatar

Joined: Sat Sep 07, 2013 2:59 pm
Posts: 1405
How do old games like "Link's Awakening" or "Final Fantasy Adventure" do the collision check when the hero swings his sword in an arc? Especially the diagonal version.

Usually, collision checks are done by declaring a rectangle for the object and seeing whether the rectangles would overlap.

So, in a diagonal direction, do they simply put a rectangle over the whole sprite, so that a collision also registers even if the monster only touched empty space?
Or do they use various smaller rectangles, located diagonally along the sword, doing more than one collision check?
Or is there any other method?

_________________
Available now: My game "City Trouble".
Website: https://megacatstudios.com/products/city-trouble
Trailer: https://youtu.be/IYXpP59qSxA
Gameplay: https://youtu.be/Eee0yurkIW4
German Retro Gamer article: http://i67.tinypic.com/345o108.jpg


Top
 Profile  
 
PostPosted: Mon May 29, 2017 6:19 am 
Offline
Formerly WheelInventor

Joined: Thu Apr 14, 2016 2:55 am
Posts: 910
Location: Gothenburg, Sweden
This is pure speculation, but what if they used small hit maps? a table of say 8x8 or 16x16 y/n entries, which corresponds to the current frame. That would be very precise. (the resolution doesn't have to be 1:1 to pixels. 1:2 would be precise enough, i think).
Note that you only need to call these checks during a brief attack, only when an enemy is within a first conditional range, and only for as long as the returns are 'no'.

_________________
http://www.frankengraphics.com - personal NES blog


Top
 Profile  
 
PostPosted: Mon May 29, 2017 6:37 am 
Online
User avatar

Joined: Sat Sep 07, 2013 2:59 pm
Posts: 1405
Yeah, that's what I mean with a lot of small rectangles.

I'm still asking myself whether this is how it actually worked in "Zelda IV" or if they used a different technique.

_________________
Available now: My game "City Trouble".
Website: https://megacatstudios.com/products/city-trouble
Trailer: https://youtu.be/IYXpP59qSxA
Gameplay: https://youtu.be/Eee0yurkIW4
German Retro Gamer article: http://i67.tinypic.com/345o108.jpg


Top
 Profile  
 
PostPosted: Mon May 29, 2017 8:31 am 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1787
Location: DIGDUG
I used the position of the actual sword sprites...which would be several (2-3) small hitboxes.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Mon May 29, 2017 8:47 am 
Offline
User avatar

Joined: Thu Sep 15, 2016 6:29 am
Posts: 255
Location: Denmark (PAL)
I'm pretty sure Zelda 4 is just a rectangle that covers most of the animation, but that's just speculation on my part. A speedrunner would probably know the exact details (maybe one of these guides covers it: https://www.speedrun.com/ladx/guides )

The thing is, you COULD try for a more exact 1:1 relation between graphics and collisions, but it wouldn't really serve any purpose. It would feel the same to the player. As a general rule, you want hitboxes to always work in the player's favor - ie. a bit smaller than your sprite when taking damage, but possible a little bigger when dealing damage - I'm fairly certain Link's Awakening does this, making sure you never get the feeling that you should have hit something when you didn't.
Trying to make game logic more "realistic" rarely means better gameplay, and quite often the exact opposite. It's one of those quirks that define a lot of "retro" games.


I'm sure you could also find a lot of games that just check for collisions along a single vertical or horizontal line rather than a rectangle. Makes detections twice as fast, and can work just as well if you place it right.


Top
 Profile  
 
PostPosted: Mon May 29, 2017 9:44 am 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3944
How about just testing three points (origin, middle, tip) against a slightly enlarged hitbox of the enemy?

(fun fact, testing a point against an enlarged hitbox is equivalent to doing a naive rectangle check)

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
PostPosted: Mon May 29, 2017 10:11 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19120
Location: NE Indiana, USA (NTSC)
Sumez wrote:
The thing is, you COULD try for a more exact 1:1 relation between graphics and collisions, but it wouldn't really serve any purpose. It would feel the same to the player. As a general rule, you want hitboxes to always work in the player's favor - ie. a bit smaller than your sprite when taking damage, but possible a little bigger when dealing damage

That would be better for a game with only player-against-environment (PvE) encounters than a game that also includes player-against-player (PvP) encounters. The increased precision expected of PvP is why the Super Smash Bros. fighting games use a "thick line segment" hitbox shape, defined as the set of points within a radius of a line segment.

  • If the lines cross, it's a collision.
  • Otherwise, both of one line segment's points are on one side of the other line segment. Forget the far point, and now you're down to a point-line proximity test.
  • If the point is between the perpendiculars of the endpoint, use a distance-from-line test.
  • Otherwise, use a distance-from-point test.

A simplified form of this, as a test between a circle and axis-aligned line segment, is used for collisions between explosions and balloons in Thwaite and between the ball and paddle in "ZapPing" in Zap Ruder.


Top
 Profile  
 
PostPosted: Mon May 29, 2017 10:42 am 
Offline
User avatar

Joined: Thu Sep 15, 2016 6:29 am
Posts: 255
Location: Denmark (PAL)
PvP gameplay is a completely different size in many ways, really. The biggest challenge in making a fighting game is obviously balancing completely different styles of attacks in a way that never seems unfair to either player, and that goes way beyond just hit- and hurtboxes (general character design as well as attack type priorities, etc.). I don't think that's what OP was going for though.


Top
 Profile  
 
PostPosted: Tue May 30, 2017 2:33 am 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7235
Location: Chexbres, VD, Switzerland
In my game I simply have a set of variable for each of the 4 corners of a collision box, and by default they're set to some values. When the player is in its "attacking" pose I overwrite them with other values, depending on the direction the player is facing.


Top
 Profile  
 
PostPosted: Thu Jun 01, 2017 12:29 am 
Offline

Joined: Mon May 27, 2013 9:40 am
Posts: 351
I simply moved a small hitbox, in some cases just a pixel at the tip of the sword, using a precalculated set of offsets syncronized with the animation. Using chibi proportions this works well enough, as the sword is not very long and is of course not longer than enemies or destructible stuff, meaning that you won't miss something going between the player and the "hotspot".

_________________
http://www.mojontwins.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: DRW, lidnariq and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group