unsigne short int -> char
This commit is contained in:
29
function.c
29
function.c
@@ -11,10 +11,15 @@
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
unsigned short int **creatArea2D (const unsigned int N)
|
||||
/**
|
||||
* \brief Cette fonction permet de creer une liste 2D carre
|
||||
* \param N La valeur N est le nombre d'élément dans le tableau.
|
||||
* \return Le tableau 2D carre
|
||||
*/
|
||||
char **creatArea2D (const unsigned int N)
|
||||
{
|
||||
unsigned short int **tab2d;
|
||||
tab2d = calloc (N, sizeof (unsigned short int *));
|
||||
char **tab2d;
|
||||
tab2d = calloc (N, sizeof (char *));
|
||||
if (tab2d == NULL)
|
||||
{
|
||||
return NULL;
|
||||
@@ -24,7 +29,7 @@ unsigned short int **creatArea2D (const unsigned int N)
|
||||
unsigned int i;
|
||||
for (i = 0; i < N && !fail; ++i)
|
||||
{
|
||||
tab2d[i] = calloc (N, sizeof (unsigned short int));
|
||||
tab2d[i] = calloc (N, sizeof (char));
|
||||
if (tab2d[i] == NULL)
|
||||
{
|
||||
fail = true;
|
||||
@@ -44,7 +49,7 @@ unsigned short int **creatArea2D (const unsigned int N)
|
||||
return tab2d;
|
||||
}
|
||||
|
||||
void free2D (unsigned short int **tab, int N)
|
||||
void free2D (char **tab, int N)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < N; ++i)
|
||||
@@ -99,7 +104,7 @@ short int canIGoDirection (short int valueOfNCase,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void move (unsigned short int **tab, vect *playerPos, vect direction,
|
||||
void move (char **tab, vect *playerPos, vect direction,
|
||||
score *score_user)
|
||||
{
|
||||
short int valueOfNCase
|
||||
@@ -193,7 +198,7 @@ void move (unsigned short int **tab, vect *playerPos, vect direction,
|
||||
}
|
||||
}
|
||||
|
||||
void inGameLoop (unsigned short int **tab2d, int N, vect *playerPos,
|
||||
void inGameLoop (char **tab2d, int N, vect *playerPos,
|
||||
vect *targets, int nbr_targets, dis *display_user,
|
||||
score *score_user)
|
||||
{
|
||||
@@ -286,7 +291,7 @@ void inGameLoop (unsigned short int **tab2d, int N, vect *playerPos,
|
||||
}
|
||||
}
|
||||
|
||||
bool isWin (unsigned short int **tab2d, vect *targets, int nbr_targets)
|
||||
bool isWin (char **tab2d, vect *targets, int nbr_targets)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < nbr_targets; ++i)
|
||||
@@ -301,7 +306,7 @@ bool isWin (unsigned short int **tab2d, vect *targets, int nbr_targets)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool islose (unsigned short int **tab2d, const int N)
|
||||
bool islose (char **tab2d, const int N)
|
||||
{
|
||||
int x = 0, y = 0;
|
||||
for (x = 0; x < N; ++x)
|
||||
@@ -336,7 +341,7 @@ vect plusVect (vect one, vect two)
|
||||
|
||||
int lengthVect (vect vector) { return abs (vector.x) + abs (vector.y); }
|
||||
|
||||
bool blockBox (unsigned short int **tab2d, vect box_coor)
|
||||
bool blockBox (char **tab2d, vect box_coor)
|
||||
{
|
||||
int nbr_touch = 0;
|
||||
vect card[4] = { { 0, -1 }, { 1, 0 }, { 0, 1 }, { -1, 0 } };
|
||||
@@ -346,7 +351,7 @@ bool blockBox (unsigned short int **tab2d, vect box_coor)
|
||||
for (i = 0; i < 4; ++i)
|
||||
{
|
||||
vect test = plusVect (box_coor, card[i]);
|
||||
unsigned short int val = tab2d[test.x][test.y];
|
||||
char val = tab2d[test.x][test.y];
|
||||
if (val == BOX || val == WALL || val == BOX_ON_TARGET)
|
||||
{
|
||||
nbr_touch++;
|
||||
@@ -417,7 +422,7 @@ bool blockBox (unsigned short int **tab2d, vect box_coor)
|
||||
vect current = plusVect (box_coor, dir_test[i]);
|
||||
while (!wall)
|
||||
{
|
||||
unsigned short int val = tab2d[current.x][current.y];
|
||||
char val = tab2d[current.x][current.y];
|
||||
if (val == WALL)
|
||||
wall = true;
|
||||
if (val == TARGET)
|
||||
|
||||
Reference in New Issue
Block a user