Commit 88b3037a authored by DIDON Maya's avatar DIDON Maya

Ajout d'un bonus de temps toutes les 20 lignes

parent 3ba71cdf
......@@ -6,7 +6,7 @@ Les améliorations majeures proposées sont :
* coloration des blocs
* ajout d'une musique de fond
* ajout de bruitages
* possibilité de gagner un bonus qui met le jeu en pause 5 secondes
* possibilité de gagner un bonus qui ralentit la vitesse du jeu pendant quelques instants
* ajout d'une fonctionnalité score ainsi que l'affichage du meilleur score enregistré
## Compiler et Lancer le Jeu :
......@@ -18,6 +18,7 @@ Le jeu devrait compiler et se lancer.
Ce jeu se joue comme un tetris basique, utilisez les flèches gauche et droite pour bouger la pièce du côte correspondant.
La flèche du haut permet de tourner la pièce, la flèche du bas permet de la descendre plus rapidement.
Essayez d'améliorer votre score en complètant un maximum de lignes à la fois !
Toutes les 20 lignes complétées, vous gagnerez un bonus sous le forme d'un escargot. En appuyant sur la touche ESPACE, vous enclencherez le bonus qui vous permet de ralentir le pas du jeu quelques instants.
## Fichiers écrits :
Ce projet est principalement basé sur la modification du code du fichier tetris.c fourni par la bibliothèque d'exemples Raylib.
......
......@@ -70,11 +70,14 @@ static bool beginPlay = true; // This var is only true at the begining of t
static bool pieceActive = false;
static bool detection = false;
static bool lineToDelete = false;
static bool powerUp = false;
static bool powerUpFinished = true;
// Statistics
static int level = 1;
static int lines = 0;
static int score = 0;
static int highScore = 0;
// Counters
static int gravityMovementCounter = 0;
......@@ -108,13 +111,16 @@ static int DeleteCompleteLines();
static unsigned int ReadHighScore();
static Color GiveLinesColors(int);
// High score variable
static int highScore = 0;
// Music and sound variables
Music soundtrack;
Sound fading;
// PowerUp variables
Texture2D slowIcon;
int frames=0;
int frameFinal=0;
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
......@@ -132,6 +138,9 @@ int main(void)
fading = LoadSound(fade);
PlayMusicStream(soundtrack);
// Initializing textures
slowIcon = LoadTexture("icon-slowdown.png");
InitGame();
#if defined(PLATFORM_WEB)
......@@ -147,6 +156,28 @@ int main(void)
//----------------------------------------------------------------------------------
UpdateDrawFrame();
UpdateMusicStream(soundtrack);
// Power-Up implementations
if(powerUp){
DrawTexture(slowIcon, 500, 200, RAYWHITE);
}
if(IsKeyPressed(KEY_SPACE) && powerUp){
powerUpFinished=false;
frameFinal=frames+240;
}
if(!powerUpFinished){
if((frameFinal-frames)>0){
gravitySpeed=80;
}
else{
frames=0;
gravitySpeed=30;
powerUpFinished=true;
powerUp=false;
}
}
frames++;
//----------------------------------------------------------------------------------
}
#endif
......@@ -320,6 +351,9 @@ void UpdateGame(void)
lines++;
score=score+(nbDel*nbDel);
if(lines%20==0){
powerUp=true;
}
}
}
}
......@@ -427,6 +461,7 @@ void DrawGame(void)
DrawText(TextFormat("SCORE: %04i", score), offset.x, offset.y + 50, 15, RED);
if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY);
}
else{
DrawText("PRESS [ENTER] TO PLAY AGAIN", GetScreenWidth()/2 - MeasureText("PRESS [ENTER] TO PLAY AGAIN", 20)/2, GetScreenHeight()/2 - 50, 20, GRAY);
......@@ -442,6 +477,7 @@ void UnloadGame(void)
{
UnloadMusicStream(soundtrack);
UnloadSound(fading);
UnloadTexture(slowIcon);
}
// Update and Draw (one frame)
......
No preview for this file type
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