Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 12 Oct 2012
Offline Last Active Dec 04 2014 11:47 PM

#5153319 2D Arcade Fighter Game

Posted by on 13 May 2014 - 08:59 AM

Hello aanthonyz1

I've also been thinking about how to handle collision detection in fighting games, so I did some research about it and I found some pretty cool results. Some games use the pixel perfect approach as DpakoH mentioned, But there are others who use a collection of "Hit Boxes" for each frame of animation. The fighting game Skullgirls uses the Hitbox method. Here is a link so you can get an idea of how it works.




While hitbox detection is most often faster than pixel perfect collision detection, you have to manually create the hitboxes for every single frame ,of every single animation and for every single character in your game, while the pixel perfect method only needs the image data. But in my opinion I think hitbox detection is the way to go. It makes it very easy to specify which parts of your character are Hurt areas (Areas that can be hit by attacks, such as the torso, head ,etc.), and which areas are Attack areas (Areas used in attacking, such as, fists, legs, weapons, etc.). Though the downside is that it will most likely be tedious to set up, unless you make some kind of external program to make editing the hitboxes for your characters easier. But then again the same thing could be done with pixel perfect collision detection if you use a separate set of images along with the original image data that specifies the hurt and attack areas. For example you could color the hurt areas blue and the attack areas red. Then when you do the collision detection, you just get the color of the pixels that are colliding and determine if its a successful hit or not. But this would make your game take up more space due to the extra image data.

#5014440 2D tile map collision detection

Posted by on 26 December 2012 - 11:12 AM

the way i would do it is to just do a bounding box collision check, then if there was a collision i would correct on the axis with the lowest penetration value. the penetration value is how far one bounding box has penetrated another . so you get the penetration value of both the x axis and the y axis. and correct for the smallest penetration value. you can get the penetration value by taking the distance from the center of the bounding box to the edge of the bounding box "width/2 or height /2". for both bounding boxes, and then subtract it from the distance from the center of box 1 to  the center of box 2:


int Xpenetration=( ( Boundingbox1.width/2 + Boundingbox2.width/2 ) - (Boundingbox2.centerX-Boundingbox1.centerX) );

int Ypenetration=( ( Boundingbox1.height/2 + Boundingbox2.height/2 ) - (Boundingbox2.centerY-Boundingbox1.centerY) );



then you compare the absolute value of both the Xpenetration and the Ypenetration, and just correct for the smallest value:


if( abs(Xpenetration) > abs(Ypenetration) )
   // correct on the y axis using Ypenetration value.
   // correct on the x axis using Xpenetration value.

#5005727 Game states?

Posted by on 30 November 2012 - 10:17 AM

Hi there! I'm also working on a state based engine and the way I'm doing it is that when I call my engine's ChangeState() function it accepts a gamestate object and an integer value as an argument ex: Function ChangeState( CgameState * state, Int i). each state can use this value how it wants. for example if I pass in the "in-game" state, I use the integer value to specify which level I want to load.The levels themselves are stored seperately as "level" objects, not as states. With this method, Loading/Switching to level 3 is as simple as calling Changestate(inGame,3). If you want to keep data that is constant between states, I would suggest creating a class that holds the game data. Whenever you load a new level you just read the data from the GameData class. I hope This helps :D