deplacement touche SDL (sur azert -> zqsd, sur qwerty -> wasd)
+ un fix pour un cas de lose
This commit is contained in:
33
function.c
33
function.c
@@ -224,13 +224,10 @@ void inGameLoop (unsigned short int **tab2d, int N, vect *playerPos,
|
|||||||
default:
|
default:
|
||||||
direction.x = 0;
|
direction.x = 0;
|
||||||
direction.y = 0;
|
direction.y = 0;
|
||||||
last = SDL_SCANCODE_1;
|
last = SDL_SCANCODE_F21;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
if (last != input)
|
||||||
|
move (tab2d, playerPos, direction);
|
||||||
//system ("clear");
|
|
||||||
if (last != input) move (tab2d, playerPos, direction);
|
|
||||||
last = input;
|
last = input;
|
||||||
if (isWin (tab2d, targets, nbr_targets))
|
if (isWin (tab2d, targets, nbr_targets))
|
||||||
{
|
{
|
||||||
@@ -242,9 +239,9 @@ void inGameLoop (unsigned short int **tab2d, int N, vect *playerPos,
|
|||||||
puts ("lose!");
|
puts ("lose!");
|
||||||
finish = true;
|
finish = true;
|
||||||
}
|
}
|
||||||
//screenDisplay (tab2d, N);
|
|
||||||
screenDisplaySDL (tab2d, display_user);
|
screenDisplaySDL (tab2d, display_user);
|
||||||
//SDL_Delay (1000);
|
}
|
||||||
|
last = SDL_SCANCODE_F21;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -326,11 +323,25 @@ bool blockBox (unsigned short int **tab2d, vect box_coor)
|
|||||||
{
|
{
|
||||||
if (id_box != -1)
|
if (id_box != -1)
|
||||||
{
|
{
|
||||||
vect test = plusVect (card[indice_card[(id_box + 1) % 3]],
|
vect other1 = card[indice_card[(id_box + 1) % 3]];
|
||||||
card[indice_card[(id_box + 2) % 3]]);
|
vect other2 = card[indice_card[(id_box + 2) % 3]];
|
||||||
if (test.x == 0 && test.y == 0)
|
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 false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user