Commit 5158a7a6 authored by MESLIN Léa's avatar MESLIN Léa

Update arkanoid_lea_meslin.c

parent 07a6ea8e
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
// Some Defines // Some Defines
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#define PLAYER_MAX_LIFE 5 #define PLAYER_MAX_LIFE 5
#define LINES_OF_BRICKS 5 #define LINES_OF_BRICKS 6
#define BRICKS_PER_LINE 20 #define BRICKS_PER_LINE 20
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
...@@ -45,10 +45,11 @@ typedef struct Brick { ...@@ -45,10 +45,11 @@ typedef struct Brick {
// Global Variables Declaration // Global Variables Declaration
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
static const int screenWidth = 800; static const int screenWidth = 800;
static const int screenHeight = 450; static const int screenHeight = 550;
static int score= 0; static int score= 0;
static int highScore = -50; static int highScore = -50;
static int choixTheme=0;
static bool gameOver = false; static bool gameOver = false;
static bool pause = false; static bool pause = false;
...@@ -135,18 +136,64 @@ void InitGame(void) ...@@ -135,18 +136,64 @@ void InitGame(void)
{ {
brick[i][j].position = (Vector2){ j*brickSize.x + brickSize.x/2, i*brickSize.y + initialDownPosition }; brick[i][j].position = (Vector2){ j*brickSize.x + brickSize.x/2, i*brickSize.y + initialDownPosition };
brick[i][j].active = true; brick[i][j].active = true;
int random = GetRandomValue(0,3); brick[i][j].couleur=0; //Valeur par défaut
switch(random){ }
case 0: {brick[i][j].couleur = 0;} break; }
case 1: {brick[i][j].couleur = 1;} break; choixTheme = GetRandomValue(0,1);
case 2: {brick[i][j].couleur = 2;} break; if (choixTheme==0){
case 3: {brick[i][j].couleur = 3;} break; for (int i = 0; i < LINES_OF_BRICKS; i++)
{
for (int j = 0; j < BRICKS_PER_LINE; j++)
{
int random = GetRandomValue(0,3);
switch(random){
case 0: {brick[i][j].couleur = 0;} break;
case 1: {brick[i][j].couleur = 1;} break;
case 2: {brick[i][j].couleur = 2;} break;
case 3: {brick[i][j].couleur = 3;} break;
}
}
}
}
else {
//Cas coeur
for (int i=0; i<6; i++){
for (int j=2; j<9; j++){
brick[i][j].couleur=2;
brick[i][j+9].couleur=2;
} }
} }
brick[4][5].couleur=3;
brick[4][14].couleur=3;
brick[3][4].couleur=3;
brick[3][13].couleur=3;
brick[3][6].couleur=3;
brick[3][15].couleur=3;
brick[2][3].couleur=3;
brick[2][12].couleur=3;
brick[2][5].couleur=3;
brick[2][14].couleur=3;
brick[2][7].couleur=3;
brick[2][16].couleur=3;
brick[1][3].couleur=3;
brick[1][12].couleur=3;
brick[1][4].couleur=3;
brick[1][13].couleur=3;
brick[1][6].couleur=3;
brick[1][15].couleur=3;
brick[1][7].couleur=3;
brick[1][16].couleur=3;
brick[2][6].couleur=1;
brick[2][15].couleur=1;
brick[2][4].couleur=1;
brick[2][13].couleur=1;
brick[3][5].couleur=1;
brick[3][14].couleur=1;
} }
} }
void briqueCouleurRouge(int i, int j){ void briqueCouleurBleue(int i, int j){
if ((brick[i][j].couleur== 1)){ if ((brick[i][j].couleur== 1)){
int k= i; int k= i;
int l= j; int l= j;
...@@ -179,7 +226,8 @@ void briqueCouleurRouge(int i, int j){ ...@@ -179,7 +226,8 @@ void briqueCouleurRouge(int i, int j){
brick[k][l-1].active=false; brick[k][l-1].active=false;
brick[k][l+1].active=false; brick[k][l+1].active=false;
} }
} score+=4;
}
} }
void briqueCouleurNoire(int i, int j){ void briqueCouleurNoire(int i, int j){
...@@ -189,7 +237,7 @@ void briqueCouleurNoire(int i, int j){ ...@@ -189,7 +237,7 @@ void briqueCouleurNoire(int i, int j){
} }
} }
void briqueCouleurVerte(int i, int j){ void briqueCouleurViolette(int i, int j){
if ((brick[i][j].couleur== 3)){ if ((brick[i][j].couleur== 3)){
ball.position.y=screenHeight*1/8; ball.position.y=screenHeight*1/8;
ball.speed.x+= -1/2; ball.speed.x+= -1/2;
...@@ -273,9 +321,9 @@ void UpdateGame(void) ...@@ -273,9 +321,9 @@ void UpdateGame(void)
{ {
brick[i][j].active = false; brick[i][j].active = false;
ball.speed.y *= -1; ball.speed.y *= -1;
briqueCouleurRouge(i,j); briqueCouleurBleue(i,j);
briqueCouleurNoire(i,j); briqueCouleurNoire(i,j);
briqueCouleurVerte(i,j); briqueCouleurViolette(i,j);
score +=1; score +=1;
} }
// Hit above // Hit above
...@@ -285,9 +333,9 @@ void UpdateGame(void) ...@@ -285,9 +333,9 @@ void UpdateGame(void)
{ {
brick[i][j].active = false; brick[i][j].active = false;
ball.speed.y *= -1; ball.speed.y *= -1;
briqueCouleurRouge(i,j); briqueCouleurBleue(i,j);
briqueCouleurNoire(i,j); briqueCouleurNoire(i,j);
briqueCouleurVerte(i,j); briqueCouleurViolette(i,j);
score +=1; score +=1;
} }
// Hit left // Hit left
...@@ -297,9 +345,9 @@ void UpdateGame(void) ...@@ -297,9 +345,9 @@ void UpdateGame(void)
{ {
brick[i][j].active = false; brick[i][j].active = false;
ball.speed.x *= -1; ball.speed.x *= -1;
briqueCouleurRouge(i,j); briqueCouleurBleue(i,j);
briqueCouleurNoire(i,j); briqueCouleurNoire(i,j);
briqueCouleurVerte(i,j); briqueCouleurViolette(i,j);
score +=1; score +=1;
} }
// Hit right // Hit right
...@@ -309,9 +357,9 @@ void UpdateGame(void) ...@@ -309,9 +357,9 @@ void UpdateGame(void)
{ {
brick[i][j].active = false; brick[i][j].active = false;
ball.speed.x *= -1; ball.speed.x *= -1;
briqueCouleurRouge(i,j); briqueCouleurBleue(i,j);
briqueCouleurNoire(i,j); briqueCouleurNoire(i,j);
briqueCouleurVerte(i,j); briqueCouleurViolette(i,j);
score +=1; score +=1;
} }
} }
...@@ -382,8 +430,8 @@ void DrawGame(void) ...@@ -382,8 +430,8 @@ void DrawGame(void)
if (brick[i][j].active) if (brick[i][j].active)
{ {
if (brick[i][j].couleur== 1) DrawRectangle (brick[i][j].position.x - brickSize.x/2, brick[i][j].position.y - brickSize.y/2, brickSize.x, brickSize.y, BLUE); if (brick[i][j].couleur== 1) DrawRectangle (brick[i][j].position.x - brickSize.x/2, brick[i][j].position.y - brickSize.y/2, brickSize.x, brickSize.y, BLUE);
else if (brick[i][j].couleur== 3) DrawRectangle (brick[i][j].position.x - brickSize.x/2, brick[i][j].position.y - brickSize.y/2, brickSize.x, brickSize.y, PURPLE);
else if (brick[i][j].couleur== 2) DrawRectangle (brick[i][j].position.x - brickSize.x/2, brick[i][j].position.y - brickSize.y/2, brickSize.x, brickSize.y, BLACK); else if (brick[i][j].couleur== 2) DrawRectangle (brick[i][j].position.x - brickSize.x/2, brick[i][j].position.y - brickSize.y/2, brickSize.x, brickSize.y, BLACK);
else if (brick[i][j].couleur== 3) DrawRectangle (brick[i][j].position.x - brickSize.x/2, brick[i][j].position.y - brickSize.y/2, brickSize.x, brickSize.y, PURPLE);
else if ((i + j) % 2 == 0) DrawRectangle(brick[i][j].position.x - brickSize.x/2, brick[i][j].position.y - brickSize.y/2, brickSize.x, brickSize.y, GRAY); else if ((i + j) % 2 == 0) DrawRectangle(brick[i][j].position.x - brickSize.x/2, brick[i][j].position.y - brickSize.y/2, brickSize.x, brickSize.y, GRAY);
else DrawRectangle(brick[i][j].position.x - brickSize.x/2, brick[i][j].position.y - brickSize.y/2, brickSize.x, brickSize.y, DARKGRAY); else DrawRectangle(brick[i][j].position.x - brickSize.x/2, brick[i][j].position.y - brickSize.y/2, brickSize.x, brickSize.y, DARKGRAY);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment