   Calculating next step coordinates
  Hi all :)I am developing some drafts for my new game for few hours now.My map is defined with;#define WALKABLE 1#define BLOCKED 0struct _M{int texture;int walkable;}MAP[100][100];Some of my MAP places are blocked by editor, this is simple.I am walking using 'W,S,A,D' and using rotation by mouse.To compute the walk forward math's i use: PLAYERS[a].x+=    ((float)sin(PLAYERS[a].rot*piover180))*PLAYER_SPEED;// Move On The X-Plane Based On Player DirectionPLAYERS[a].z+=((float)cos(PLAYERS[a].rot*piover180))*PLAYER_SPEED; The thing is:How to caltulate next tile position of my player to predict eventual walking onBLOCKED tile?Knowing the angle of rotation and actual position - how can this be calculated?many thanks for any reply,i am stuck here..   
  What you need to do is to check whether the new position is within a blocked tile and depending on that accept the update, or try to get as close to the tile as possible (which would result in touching a wall). And after that you update the position. But be careful, if the player moves too fast, this might not detect collisions between the current and the new state (also called tunneling effect). Easiest measure would be to restrict the maximum velocity of the player.You will also have to calculate the tile coordinates from a player coordinate which would be something likeAdditionally you probably need a bounding sphere for the tile, as I guess the player is bigger than just 1 pixel. Make sure you take this into account when checking for collisions.  // calculate the velocity of the player  velocity.x+= ((float)sin(PLAYERS[a].rot*piover180))*PLAYER_SPEED;  velocity.z+= ((float)cos(PLAYERS[a].rot*piover180))*PLAYER_SPEED;   // depending whether you move up/down, left/right you have to add  // radius or subtract it  int tilex = (int) round (posx +- radius + velocity.x)  int tilez = (int) round (posz +- radius + velocity.z)  // is the next position in a blocked tile?  if (MAP[tilex + 100][tilez + 100] == BLOCKED)    // calculate how far you can go until you    // crash into the tile -> t  else    // accept the full -> t = 1To calculate the closest position, you have first to check on which side of the tile you will crash into. Once this is done, you have to calculate how far left/right or up/down you can move until you touch the side of the tile.If you calculated that the player will touch the right side you end up calculating  t = (tile_right_x - posx + radius) / velocity.xThen you can update the position with  posx += t * velocity.x  posz += t * velocity.zCheers,fng   ;  Great stuff, many many thanks!I'll post an update when i finish up with this implementation.Best regards!   