encore meilleur
This commit is contained in:
10
display.c
10
display.c
@@ -58,7 +58,8 @@ void screenDisplaySDL (unsigned short int **tab, dis *display_user)
|
||||
img = IMG_Load ("player_on_target.png");
|
||||
break;
|
||||
}
|
||||
texture = SDL_CreateTextureFromSurface (display_user->renderer, img);
|
||||
texture
|
||||
= SDL_CreateTextureFromSurface (display_user->renderer, img);
|
||||
displayImage (display_user->renderer, texture, pos, size);
|
||||
SDL_FreeSurface (img);
|
||||
SDL_DestroyTexture (texture);
|
||||
@@ -89,9 +90,10 @@ int getMaxSize ()
|
||||
void initSDL (dis *display_user)
|
||||
{
|
||||
SDL_Init (SDL_INIT_VIDEO);
|
||||
display_user->window = SDL_CreateWindow (
|
||||
"Sokoman", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
|
||||
display_user->size_window, display_user->size_window, SDL_WINDOW_SHOWN);
|
||||
display_user->window
|
||||
= SDL_CreateWindow ("Sokoman", SDL_WINDOWPOS_CENTERED,
|
||||
SDL_WINDOWPOS_CENTERED, display_user->size_window,
|
||||
display_user->size_window, SDL_WINDOW_SHOWN);
|
||||
if (!display_user->window)
|
||||
{
|
||||
SDL_Quit ();
|
||||
|
||||
12
function.c
12
function.c
@@ -67,7 +67,8 @@ short int canIGoDirection (short int valueOfNCase,
|
||||
return 2;
|
||||
}
|
||||
if ((valueOfNCase == BOX_ON_TARGET && valueOfNPlusOneCase == EMPTY)
|
||||
|| (valueOfNCase == BOX_ON_TARGET && valueOfNPlusOneCase == TARGET))
|
||||
|| (valueOfNCase == BOX_ON_TARGET
|
||||
&& valueOfNPlusOneCase == TARGET))
|
||||
{
|
||||
if (valueOfNPlusOneCase == TARGET)
|
||||
{
|
||||
@@ -111,7 +112,8 @@ void move (unsigned short int **tab, vect *playerPos, vect direction)
|
||||
valueOfNPlusOneCase = tab[add.x][add.y];
|
||||
}
|
||||
|
||||
short int returnValue = canIGoDirection (valueOfNCase, valueOfNPlusOneCase);
|
||||
short int returnValue
|
||||
= canIGoDirection (valueOfNCase, valueOfNPlusOneCase);
|
||||
short int playerState = tab[playerPos->x][playerPos->y];
|
||||
|
||||
switch (returnValue)
|
||||
@@ -127,7 +129,8 @@ void move (unsigned short int **tab, vect *playerPos, vect direction)
|
||||
// move player and the box
|
||||
|
||||
tab[playerPos->x + direction.x][playerPos->y + direction.y] = PLAYER;
|
||||
tab[playerPos->x + direction.x * 2][playerPos->y + direction.y * 2] = BOX;
|
||||
tab[playerPos->x + direction.x * 2][playerPos->y + direction.y * 2]
|
||||
= BOX;
|
||||
break;
|
||||
case 3:
|
||||
// move player and the box is well-placed
|
||||
@@ -145,7 +148,8 @@ void move (unsigned short int **tab, vect *playerPos, vect direction)
|
||||
case 5:
|
||||
// move box and player on a target
|
||||
|
||||
tab[playerPos->x + direction.x * 2][playerPos->y + direction.y * 2] = BOX;
|
||||
tab[playerPos->x + direction.x * 2][playerPos->y + direction.y * 2]
|
||||
= BOX;
|
||||
tab[playerPos->x + direction.x][playerPos->y + direction.y]
|
||||
= PLAYER_ON_TARGET;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user