I am currently doing some game engine programming as a hobby. I have been working on getting the collision detection working for a while now, and I'm at my wits end with it.
I started with this guide. If you scroll down the the picture of the character sprite, you will see that she uses points on the character instead of a bounding box to do the collision. That is what I currently have implemented, but I'm having a ridiculously hard time making it work perfectly.
I started with axis aligned, but moved to separating axis theorem so that I can implement collision boxes that are at an angle. The collision response I'm trying to use when a collision occurs on the bottom of the character is this horrible thing:
nextY = (bottomColl.getY1() + bottomColl.getCenterY() + (currHeight() / 2) +
(nextX + collisionPoints[currState][currFrame][4][0] - bottomColl.getCenterX() + (currHeight() / 2) * tan(angle / 2)) * tan(angle));
Y1 being top left corner and collisionPoints 4 being the bottom right point. (This is for an incline as opposed to a decline. The decline would use point 5, the bottom left point.)
This, however, doesn't work, and updates the character position to slightly lower than he is supposed to be. This has little effect, unless the frame rate is really high, in which case, the jump animation does not move the character out of the collision box and the character gets pushed way far away.
I realize the code is probably hard to decipher out of context, but I'm pretty damn sure the algorithm should be right, yet it doesn't work properly.
Would it be better to switch to using a bounding box for the character and figure out collision response for that, or does anyone know what the proper equation is for setting the character height on an incline given an X position?
Edit: Here is a picture of me showing the equation works in CAD. The calculator shows me using my equation from above to get the same number as is indicated on the sketch.