I'm currently very busy with programming a new game, all programmed in Free BASIC (except some of the actual libraries I use etc. :P). And have hit a dead-end concerning collision.
Our game is a 2D platformer. The .stg files (stage info) store a list of entities in the stage, and some other allocation info. From the data there, the game calculates the collision box (called "bones" in the code, and are stored as the two opposite points of a rectangle) which is used for collision, obviously ;).
I'm unable to even get my head around some concepts of collision, let alone program it to actuality.
I do understand the basics of collision: it is when the playable character hits an entity, or multiple entities. Then my code is supposed to respond to that. Finding out if our character is in an entity is not the issue:
it's figuring out from which side our character is colliding with an entity. That's the issue.
I require to know if our character is colliding with an entity from with the TOP, LEFT, BOTTOM, or RIGHT side for the physics, esp. with platforms: the character is supposed to respond differently depending on if they hit the TOP (stand on), LEFT (unable to move RIGHT), BOTTOM (hits head on platform, and falls down), or RIGHT (unable to move LEFT) side of an entity. With enemies, this at the moment is not so much of an issue, but I realise that we also require this info if we are to make our character "bounce" off of an enemy when they collide with one, should we choose to implement such physics.
I've got the physics working, would you believe it! It's just that darn collision that's been bugging me (read: me tearing my hair out, almost literally) since a few days.
What I'm asking for help with is this: the ideas behind identifying if our character has collided with the top, bottom, left, or right side of an entity.
1. I'm not really asking for help with code directly, i.e. you don't have to program the idea for me: it's just getting my head round it. If I could understand the process, I could implement it fine, is my reckoning. Also the fact that I would have to post >100K code on a public forum (probably less as only a small fraction of that is the actual game engine as it stands now): I am still unsure if I should keep the code for the game closed-source or not, and as the game has no official first version yet, I would prefer to keep my code off the web.
2. I would like to avoid relying on pre-made game engines or libraries as I have already programmed the framework for one (i.e. gravity is working, as is jumping, moving, and lot's more like loading, graphics effects, menus etc.).
OK, I'll perhaps need to tell you a few things about the way our character moves:
1. He does not move one pixel at a time. If that were the case, then collision would be a lot easier generally. But he does not :(.
2. All entities at the moment are
If you need any other info, you can ask.
Thanks for your time.