Skip to content
Snippets Groups Projects
Commit 7b853fc6 authored by belkhiritaha's avatar belkhiritaha
Browse files

la touche b permet de reset la balle

parent 0e08094b
No related branches found
No related tags found
No related merge requests found
...@@ -5,8 +5,8 @@ int trajectoireAntoine[NUMBERPOINT_TRAJEC][2]; ...@@ -5,8 +5,8 @@ int trajectoireAntoine[NUMBERPOINT_TRAJEC][2];
void initBall() void initBall()
{ {
ball.x = 5 * BLOCK_SIZE; ball.x = (rand()%(MAP_WIDTH/2)) * BLOCK_SIZE;
ball.y = 5 * BLOCK_SIZE; ball.y = (rand()% (MAP_HEIGHT)) * BLOCK_SIZE;
ball.z = player.h / BLOCK_SIZE; ball.z = player.h / BLOCK_SIZE;
ball.h = 0.5 * BLOCK_SIZE; ball.h = 0.5 * BLOCK_SIZE;
ball.w = 0.5 * BLOCK_SIZE; ball.w = 0.5 * BLOCK_SIZE;
......
...@@ -25,7 +25,7 @@ void manageEnnemyMovement() ...@@ -25,7 +25,7 @@ void manageEnnemyMovement()
angleH = converterIntoAngleH(angleH); angleH = converterIntoAngleH(angleH);
ennemyZone = convertIntoZone(ennemy.x, ennemy.y); ennemyZone = convertIntoZone(ennemy.x, ennemy.y);
canonZone = convertIntoZone(lastHitPoint[0], lastHitPoint[1]); canonZone = convertIntoZone(lastHitPoint[0], lastHitPoint[1]);
action = takeAction(ennemy.x, ennemy.y, Q, canonZone, angleH, angleF, 0); action = takeAction(ennemy.x, ennemy.y, Q, canonZone, angleH, angleF, 1);
switch (action) switch (action)
{ {
case BACK: case BACK:
......
...@@ -115,6 +115,11 @@ void gestGame() ...@@ -115,6 +115,11 @@ void gestGame()
showHub = 0; showHub = 0;
} }
case SDLK_b:
initBall();
landingPointIsFind = 0;
continue;
default: default:
break; break;
} }
......
...@@ -5,6 +5,7 @@ int game_state; ...@@ -5,6 +5,7 @@ int game_state;
float ***** Q; float ***** Q;
int main() int main()
{ {
srand(time(NULL));
Q = allocateAndInitiateQ(); Q = allocateAndInitiateQ();
readQFromFile(Q); readQFromFile(Q);
running = 1; running = 1;
......
...@@ -33,7 +33,6 @@ void initPlayer() ...@@ -33,7 +33,6 @@ void initPlayer()
int *generateLandingPoint(int rxWall) int *generateLandingPoint(int rxWall)
{ {
int *landingPoint = malloc(sizeof(int) * 2); int *landingPoint = malloc(sizeof(int) * 2);
srand(time(NULL));
int randomPointX = MAP_WIDTH / 2 + 1 + rand() % (rxWall / BLOCK_SIZE - (MAP_WIDTH / 2)); int randomPointX = MAP_WIDTH / 2 + 1 + rand() % (rxWall / BLOCK_SIZE - (MAP_WIDTH / 2));
int randomPointY = -1; int randomPointY = -1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment