fix deplacement out of range
This commit is contained in:
14
function.c
14
function.c
@@ -87,8 +87,18 @@ move (unsigned short int **tab, vect *playerPos, vect direction)
|
||||
{
|
||||
short int valueOfNCase
|
||||
= tab[playerPos->x + direction.x][playerPos->y + direction.y];
|
||||
short int valueOfNPlusOneCase
|
||||
= tab[playerPos->x + direction.x * 2][playerPos->y + direction.y * 2];
|
||||
|
||||
vect add = plusVect(*playerPos, direction);
|
||||
add = plusVect(add,direction);
|
||||
short int valueOfNPlusOneCase;
|
||||
|
||||
if(add.x < 0 || add.y < 0)
|
||||
{
|
||||
valueOfNPlusOneCase = WALL;
|
||||
}else
|
||||
{
|
||||
valueOfNPlusOneCase = tab[add.x][add.y];
|
||||
}
|
||||
|
||||
short int returnValue = canIGoDirection (valueOfNCase, valueOfNPlusOneCase);
|
||||
short int playerState = tab[playerPos->x][playerPos->y];
|
||||
|
||||
Reference in New Issue
Block a user