deplacement touche SDL (sur azert -> zqsd, sur qwerty -> wasd)
+ un fix pour un cas de lose
This commit is contained in:
57
function.c
57
function.c
@@ -193,7 +193,7 @@ void inGameLoop (unsigned short int **tab2d, int N, vect *playerPos,
|
||||
SDL_Event event;
|
||||
while (!finish)
|
||||
{
|
||||
//printf ("Utilisez Z/Q/S/D pour bouger, X pour quitter : ");
|
||||
// printf ("Utilisez Z/Q/S/D pour bouger, X pour quitter : ");
|
||||
SDL_PollEvent (&event);
|
||||
|
||||
if (event.type == SDL_KEYDOWN)
|
||||
@@ -224,27 +224,24 @@ void inGameLoop (unsigned short int **tab2d, int N, vect *playerPos,
|
||||
default:
|
||||
direction.x = 0;
|
||||
direction.y = 0;
|
||||
last = SDL_SCANCODE_1;
|
||||
|
||||
last = SDL_SCANCODE_F21;
|
||||
}
|
||||
if (last != input)
|
||||
move (tab2d, playerPos, direction);
|
||||
last = input;
|
||||
if (isWin (tab2d, targets, nbr_targets))
|
||||
{
|
||||
puts ("Win!");
|
||||
finish = true;
|
||||
}
|
||||
if (islose (tab2d, N))
|
||||
{
|
||||
puts ("lose!");
|
||||
finish = true;
|
||||
}
|
||||
screenDisplaySDL (tab2d, display_user);
|
||||
}
|
||||
|
||||
//system ("clear");
|
||||
if (last != input) move (tab2d, playerPos, direction);
|
||||
last = input;
|
||||
if (isWin (tab2d, targets, nbr_targets))
|
||||
{
|
||||
puts ("Win!");
|
||||
finish = true;
|
||||
}
|
||||
if (islose (tab2d, N))
|
||||
{
|
||||
puts ("lose!");
|
||||
finish = true;
|
||||
}
|
||||
//screenDisplay (tab2d, N);
|
||||
screenDisplaySDL (tab2d, display_user);
|
||||
//SDL_Delay (1000);
|
||||
last = SDL_SCANCODE_F21;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,10 +323,24 @@ bool blockBox (unsigned short int **tab2d, vect box_coor)
|
||||
{
|
||||
if (id_box != -1)
|
||||
{
|
||||
vect test = plusVect (card[indice_card[(id_box + 1) % 3]],
|
||||
card[indice_card[(id_box + 2) % 3]]);
|
||||
if (test.x == 0 && test.y == 0)
|
||||
vect other1 = card[indice_card[(id_box + 1) % 3]];
|
||||
vect other2 = card[indice_card[(id_box + 2) % 3]];
|
||||
vect test_add_other = plusVect (other1, other2);
|
||||
vect coor_box = plusVect (card[indice_card[id_box]], box_coor);
|
||||
vect other_plus_box1 = plusVect (other1, coor_box);
|
||||
vect other_plus_box2 = plusVect (other2, coor_box);
|
||||
int val1 = tab2d[other_plus_box1.x][other_plus_box1.y];
|
||||
int val2 = tab2d[other_plus_box2.x][other_plus_box2.y];
|
||||
|
||||
if (test_add_other.x == 0 && test_add_other.y == 0)
|
||||
{
|
||||
|
||||
if ((val1 == WALL || val1 == BOX || val1 == BOX_ON_TARGET))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user