you've got comments with those functions
which one to use depends on what you want to achieve
if you want to assume that your character is a 2D Circle (in physics term) and you want to use collision detection for a moving circle and static edges (level), then use those functions which have a comment named 'if a moving circle cuts through static edge'
as I recall its this function
Bool CutsCIRCLEEdge (Circle &circle, Vec2 &move, Edge2 &edge, Flt *hit_frac=NULL, Vec2 *hit_normal=NULL)
you perform a test if a moving by 'move' vector 'circle' (your player) encounters a non moving 'edge'-wall
returns true if it hit an edge, and false if they don't collide
if you pass hit_frac it will return 0..1 value indicating at which fraction of the movement collision encountered
'hit_normal' stands for normal vector of collision
having this function you'd need to have a level built of 2D edges.
2D edges will allow you for complex levels with walls at different angles.
if you want simplier code, and you'll have a level limited to square tiles, with the fact that the characters will move slowly you can do it simplier
have a 2D map of tiles:
Code:
Byte tile[16][16]=
{
{1,1,1,1,1,1,1,1,1,1...}, // 16 values here, where '1'=wall, '0'=floor
{1,0,0,0,0,0,0,0,0,0...},
{1,0,1,1,1,0,0,0,0,0...},
{1,0,1,0,1,0,0,0,0,0...},
{1,0,1,0,0,0,0,0,0,0...},
{1,0,1,1,1,1,1,1,0,0...},
};
and then work out manually your collision detection, start with a 2d point
Vec2 point; // player position
write a position testing function
Code:
Bool PositionValid(Vec2 &pos)
{
int x=Trunc(pos.x),
y=Trunc(pos.y);
if(x>=0 && y>=0 && x<16 && y<16)return tile[y][x]==0; // tile at pos vector is floor
return false;
}
then write an updating position function
Code:
void UpdatePlayerPosition(Vec2 &pos)
{
Vec2 dir=Vec2(Kb.b(KB_D)-Kb.b(LB_A), Kb.b(KB_W)-Kb.b(KB_S))*Tm.d*0.5f;
Vec2 new_pos = pos + dir;
if(PositionValid(new_pos)) // if new position is valid - floor
{
pos=new_pos; // set players position
}
}
these are just the basics