Review sample games

This commit is contained in:
Ray 2019-05-21 17:47:06 +02:00
parent 0027868d1f
commit 8b4f58b9e9
11 changed files with 199 additions and 263 deletions

View File

@ -25,7 +25,6 @@
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Some Defines // Some Defines
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#define PLAYER_MAX_LIFE 5 #define PLAYER_MAX_LIFE 5
#define LINES_OF_BRICKS 5 #define LINES_OF_BRICKS 5
#define BRICKS_PER_LINE 20 #define BRICKS_PER_LINE 20
@ -56,16 +55,16 @@ typedef struct Brick {
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Global Variables Declaration // Global Variables Declaration
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
static int screenWidth = 800; static const int screenWidth = 800;
static int screenHeight = 450; static const int screenHeight = 450;
static bool gameOver; static bool gameOver = false;
static bool pause; static bool pause = false;
static Player player; static Player player = { 0 };
static Ball ball; static Ball ball = { 0 };
static Brick brick[LINES_OF_BRICKS][BRICKS_PER_LINE]; static Brick brick[LINES_OF_BRICKS][BRICKS_PER_LINE] = { 0 };
static Vector2 brickSize; static Vector2 brickSize = { 0 };
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Module Functions Declaration (local) // Module Functions Declaration (local)
@ -90,7 +89,6 @@ int main(void)
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
emscripten_set_main_loop(UpdateDrawFrame, 0, 1); emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
#else #else
SetTargetFPS(60); SetTargetFPS(60);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -103,7 +101,6 @@ int main(void)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
#endif #endif
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadGame(); // Unload loaded data (textures, sounds, models...) UnloadGame(); // Unload loaded data (textures, sounds, models...)
@ -272,8 +269,6 @@ void UpdateGame(void)
gameOver = false; gameOver = false;
} }
} }
} }
// Draw game (one frame) // Draw game (one frame)

View File

@ -34,7 +34,6 @@
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Types and Structures Definition // Types and Structures Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
typedef struct Player { typedef struct Player {
Vector2 position; Vector2 position;
Vector2 speed; Vector2 speed;
@ -65,25 +64,25 @@ typedef struct Meteor {
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Global Variables Declaration // Global Variables Declaration
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
static int screenWidth = 800; static const int screenWidth = 800;
static int screenHeight = 450; static const int screenHeight = 450;
static bool gameOver; static bool gameOver = false;
static bool pause; static bool pause = false;
static bool victory; static bool victory = false;
// NOTE: Defined triangle is isosceles with common angles of 70 degrees. // NOTE: Defined triangle is isosceles with common angles of 70 degrees.
static float shipHeight; static float shipHeight = 0.0f;
static Player player; static Player player = { 0 };
static Shoot shoot[PLAYER_MAX_SHOOTS]; static Shoot shoot[PLAYER_MAX_SHOOTS] = { 0 };
static Meteor bigMeteor[MAX_BIG_METEORS]; static Meteor bigMeteor[MAX_BIG_METEORS] = { 0 };
static Meteor mediumMeteor[MAX_MEDIUM_METEORS]; static Meteor mediumMeteor[MAX_MEDIUM_METEORS] = { 0 };
static Meteor smallMeteor[MAX_SMALL_METEORS]; static Meteor smallMeteor[MAX_SMALL_METEORS] = { 0 };
static int midMeteorsCount; static int midMeteorsCount = 0;
static int smallMeteorsCount; static int smallMeteorsCount = 0;
static int destroyedMeteorsCount; static int destroyedMeteorsCount = 0;
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Module Functions Declaration (local) // Module Functions Declaration (local)
@ -108,7 +107,6 @@ int main(void)
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
emscripten_set_main_loop(UpdateDrawFrame, 0, 1); emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
#else #else
SetTargetFPS(60); SetTargetFPS(60);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -121,7 +119,6 @@ int main(void)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
#endif #endif
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadGame(); // Unload loaded data (textures, sounds, models...) UnloadGame(); // Unload loaded data (textures, sounds, models...)

View File

@ -33,7 +33,6 @@
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Types and Structures Definition // Types and Structures Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
typedef struct Player { typedef struct Player {
Vector2 position; Vector2 position;
Vector2 speed; Vector2 speed;
@ -54,19 +53,19 @@ typedef struct Meteor {
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Global Variables Declaration // Global Variables Declaration
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
static int screenWidth = 800; static const int screenWidth = 800;
static int screenHeight = 450; static const int screenHeight = 450;
static int framesCounter; static int framesCounter = 0;
static bool gameOver; static bool gameOver = false;
static bool pause; static bool pause = false;
// NOTE: Defined triangle is isosceles with common angles of 70 degrees. // NOTE: Defined triangle is isosceles with common angles of 70 degrees.
static float shipHeight; static float shipHeight = 0.0f;
static Player player; static Player player = { 0 };
static Meteor mediumMeteor[MAX_MEDIUM_METEORS]; static Meteor mediumMeteor[MAX_MEDIUM_METEORS] = { 0 };
static Meteor smallMeteor[MAX_SMALL_METEORS]; static Meteor smallMeteor[MAX_SMALL_METEORS] = { 0 };
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Module Functions Declaration (local) // Module Functions Declaration (local)
@ -91,7 +90,6 @@ int main(void)
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
emscripten_set_main_loop(UpdateDrawFrame, 0, 1); emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
#else #else
SetTargetFPS(60); SetTargetFPS(60);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -104,7 +102,6 @@ int main(void)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
#endif #endif
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadGame(); // Unload loaded data (textures, sounds, models...) UnloadGame(); // Unload loaded data (textures, sounds, models...)
@ -354,7 +351,7 @@ void DrawGame(void)
else DrawCircleV(smallMeteor[i].position, smallMeteor[i].radius, Fade(LIGHTGRAY, 0.3f)); else DrawCircleV(smallMeteor[i].position, smallMeteor[i].radius, Fade(LIGHTGRAY, 0.3f));
} }
DrawText(FormatText("TIME: %.02f", (float)framesCounter/60), 10, 10, 20, BLACK); DrawText(TextFormat("TIME: %.02f", (float)framesCounter/60), 10, 10, 20, BLACK);
if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY); if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY);
} }

View File

@ -42,19 +42,19 @@ typedef struct Tubes {
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Global Variables Declaration // Global Variables Declaration
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
static int screenWidth = 800; static const int screenWidth = 800;
static int screenHeight = 450; static const int screenHeight = 450;
static bool gameOver; static bool gameOver = false;
static bool pause; static bool pause = false;
static int score; static int score = 0;
static int hiScore = 0; static int hiScore = 0;
static Floppy floppy; static Floppy floppy = { 0 };
static Tubes tubes[MAX_TUBES*2]; static Tubes tubes[MAX_TUBES*2] = { 0 };
static Vector2 tubesPos[MAX_TUBES]; static Vector2 tubesPos[MAX_TUBES] = { 0 };
static int tubesSpeedX; static int tubesSpeedX = 0;
static bool superfx; static bool superfx = false;
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Module Functions Declaration (local) // Module Functions Declaration (local)
@ -79,7 +79,6 @@ int main(void)
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
emscripten_set_main_loop(UpdateDrawFrame, 0, 1); emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
#else #else
SetTargetFPS(60); SetTargetFPS(60);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -92,7 +91,6 @@ int main(void)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
#endif #endif
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadGame(); // Unload loaded data (textures, sounds, models...) UnloadGame(); // Unload loaded data (textures, sounds, models...)
@ -216,8 +214,8 @@ void DrawGame(void)
superfx = false; superfx = false;
} }
DrawText(FormatText("%04i", score), 20, 20, 40, GRAY); DrawText(TextFormat("%04i", score), 20, 20, 40, GRAY);
DrawText(FormatText("HI-SCORE: %04i", hiScore), 20, 70, 20, LIGHTGRAY); DrawText(TextFormat("HI-SCORE: %04i", hiScore), 20, 70, 20, LIGHTGRAY);
if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY); if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY);
} }

View File

@ -31,7 +31,7 @@ typedef struct Enemy {
Vector2 speed; Vector2 speed;
int radius; int radius;
int radiusBounds; int radiusBounds;
bool moveRight; // RAY: o__O bool moveRight;
} Enemy; } Enemy;
typedef struct Points { typedef struct Points {
@ -51,19 +51,19 @@ typedef struct Home {
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Global Variables Declaration // Global Variables Declaration
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
static int screenWidth = 800; static const int screenWidth = 800;
static int screenHeight = 450; static const int screenHeight = 450;
static bool gameOver; static bool gameOver = false;
static bool pause; static bool pause = false;
static int score; static int score = 0;
static int hiScore = 0; static int hiScore = 0;
static Player player; static Player player = { 0 };
static Enemy enemy; static Enemy enemy = { 0 };
static Points points; static Points points = { 0 };
static Home home; static Home home = { 0 };
static bool follow; static bool follow = false;
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Module Functions Declaration (local) // Module Functions Declaration (local)
@ -88,7 +88,6 @@ int main(void)
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
emscripten_set_main_loop(UpdateDrawFrame, 0, 1); emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
#else #else
SetTargetFPS(60); SetTargetFPS(60);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -101,7 +100,6 @@ int main(void)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
#endif #endif
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadGame(); // Unload loaded data (textures, sounds, models...) UnloadGame(); // Unload loaded data (textures, sounds, models...)
@ -155,19 +153,19 @@ void UpdateGame(void)
if (!pause) if (!pause)
{ {
//Control player // Control player
if (IsKeyDown(KEY_RIGHT)) player.position.x += player.speed.x; if (IsKeyDown(KEY_RIGHT)) player.position.x += player.speed.x;
if (IsKeyDown(KEY_LEFT)) player.position.x -= player.speed.x; if (IsKeyDown(KEY_LEFT)) player.position.x -= player.speed.x;
if (IsKeyDown(KEY_UP)) player.position.y -= player.speed.y; if (IsKeyDown(KEY_UP)) player.position.y -= player.speed.y;
if (IsKeyDown(KEY_DOWN)) player.position.y += player.speed.y; if (IsKeyDown(KEY_DOWN)) player.position.y += player.speed.y;
//wall behaviour player // Wall behaviour player
if (player.position.x - player.radius <= 0) player.position.x = player.radius; if (player.position.x - player.radius <= 0) player.position.x = player.radius;
if (player.position.x + player.radius >= screenWidth) player.position.x = screenWidth - player.radius; if (player.position.x + player.radius >= screenWidth) player.position.x = screenWidth - player.radius;
if (player.position.y - player.radius <= 0) player.position.y = player.radius; if (player.position.y - player.radius <= 0) player.position.y = player.radius;
if (player.position.y + player.radius >= screenHeight) player.position.y = screenHeight - player.radius; if (player.position.y + player.radius >= screenHeight) player.position.y = screenHeight - player.radius;
//IA Enemy // IA Enemy
if ( (follow || CheckCollisionCircles(player.position, player.radius, enemy.position, enemy.radiusBounds)) && !home.save) if ( (follow || CheckCollisionCircles(player.position, player.radius, enemy.position, enemy.radiusBounds)) && !home.save)
{ {
if (player.position.x > enemy.position.x) enemy.position.x += enemy.speed.x; if (player.position.x > enemy.position.x) enemy.position.x += enemy.speed.x;
@ -182,7 +180,7 @@ void UpdateGame(void)
else enemy.position.x -= enemy.speed.x; else enemy.position.x -= enemy.speed.x;
} }
//wall behaviour enemy // Wall behaviour enemy
if (enemy.position.x - enemy.radius <= 0) enemy.moveRight = true; if (enemy.position.x - enemy.radius <= 0) enemy.moveRight = true;
if (enemy.position.x + enemy.radius >= screenWidth) enemy.moveRight = false; if (enemy.position.x + enemy.radius >= screenWidth) enemy.moveRight = false;
@ -191,7 +189,7 @@ void UpdateGame(void)
if (enemy.position.y - enemy.radius <= 0) enemy.position.y = enemy.radius; if (enemy.position.y - enemy.radius <= 0) enemy.position.y = enemy.radius;
if (enemy.position.y + enemy.radius >= screenHeight) enemy.position.y = screenHeight - enemy.radius; if (enemy.position.y + enemy.radius >= screenHeight) enemy.position.y = screenHeight - enemy.radius;
//Collisions // Collisions
if (CheckCollisionCircles(player.position, player.radius, points.position, points.radius) && points.active) if (CheckCollisionCircles(player.position, player.radius, points.position, points.radius) && points.active)
{ {
follow = true; follow = true;
@ -257,8 +255,8 @@ void DrawGame(void)
DrawCircleV(player.position, player.radius, GRAY); DrawCircleV(player.position, player.radius, GRAY);
if (points.active) DrawCircleV(points.position, points.radius, GOLD); if (points.active) DrawCircleV(points.position, points.radius, GOLD);
DrawText(FormatText("SCORE: %04i", score), 20, 15, 20, GRAY); DrawText(TextFormat("SCORE: %04i", score), 20, 15, 20, GRAY);
DrawText(FormatText("HI-SCORE: %04i", hiScore), 300, 15, 20, GRAY); DrawText(TextFormat("HI-SCORE: %04i", hiScore), 300, 15, 20, GRAY);
if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY); if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY);
} }

View File

@ -84,16 +84,16 @@ typedef struct Ball {
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Global Variables Declaration // Global Variables Declaration
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
static int screenWidth = 800; static const int screenWidth = 800;
static int screenHeight = 450; static const int screenHeight = 450;
static bool gameOver = false; static bool gameOver = false;
static bool pause = false; static bool pause = false;
static Player player[MAX_PLAYERS]; static Player player[MAX_PLAYERS] = { 0 };
static Building building[MAX_BUILDINGS]; static Building building[MAX_BUILDINGS] = { 0 };
static Explosion explosion[MAX_EXPLOSIONS]; static Explosion explosion[MAX_EXPLOSIONS] = { 0 };
static Ball ball; static Ball ball = { 0 };
static int playerTurn = 0; static int playerTurn = 0;
static bool ballOnAir = false; static bool ballOnAir = false;
@ -272,21 +272,21 @@ void DrawGame(void)
/* /*
if (player[playerTurn].isLeftTeam) if (player[playerTurn].isLeftTeam)
{ {
DrawText(FormatText("Previous Point %i, %i", (int)player[playerTurn].previousPoint.x, (int)player[playerTurn].previousPoint.y), 20, 20, 20, DARKBLUE); DrawText(TextFormat("Previous Point %i, %i", (int)player[playerTurn].previousPoint.x, (int)player[playerTurn].previousPoint.y), 20, 20, 20, DARKBLUE);
DrawText(FormatText("Previous Angle %i", player[playerTurn].previousAngle), 20, 50, 20, DARKBLUE); DrawText(TextFormat("Previous Angle %i", player[playerTurn].previousAngle), 20, 50, 20, DARKBLUE);
DrawText(FormatText("Previous Power %i", player[playerTurn].previousPower), 20, 80, 20, DARKBLUE); DrawText(TextFormat("Previous Power %i", player[playerTurn].previousPower), 20, 80, 20, DARKBLUE);
DrawText(FormatText("Aiming Point %i, %i", (int)player[playerTurn].aimingPoint.x, (int)player[playerTurn].aimingPoint.y), 20, 110, 20, DARKBLUE); DrawText(TextFormat("Aiming Point %i, %i", (int)player[playerTurn].aimingPoint.x, (int)player[playerTurn].aimingPoint.y), 20, 110, 20, DARKBLUE);
DrawText(FormatText("Aiming Angle %i", player[playerTurn].aimingAngle), 20, 140, 20, DARKBLUE); DrawText(TextFormat("Aiming Angle %i", player[playerTurn].aimingAngle), 20, 140, 20, DARKBLUE);
DrawText(FormatText("Aiming Power %i", player[playerTurn].aimingPower), 20, 170, 20, DARKBLUE); DrawText(TextFormat("Aiming Power %i", player[playerTurn].aimingPower), 20, 170, 20, DARKBLUE);
} }
else else
{ {
DrawText(FormatText("Previous Point %i, %i", (int)player[playerTurn].previousPoint.x, (int)player[playerTurn].previousPoint.y), screenWidth*3/4, 20, 20, DARKBLUE); DrawText(TextFormat("Previous Point %i, %i", (int)player[playerTurn].previousPoint.x, (int)player[playerTurn].previousPoint.y), screenWidth*3/4, 20, 20, DARKBLUE);
DrawText(FormatText("Previous Angle %i", player[playerTurn].previousAngle), screenWidth*3/4, 50, 20, DARKBLUE); DrawText(TextFormat("Previous Angle %i", player[playerTurn].previousAngle), screenWidth*3/4, 50, 20, DARKBLUE);
DrawText(FormatText("Previous Power %i", player[playerTurn].previousPower), screenWidth*3/4, 80, 20, DARKBLUE); DrawText(TextFormat("Previous Power %i", player[playerTurn].previousPower), screenWidth*3/4, 80, 20, DARKBLUE);
DrawText(FormatText("Aiming Point %i, %i", (int)player[playerTurn].aimingPoint.x, (int)player[playerTurn].aimingPoint.y), screenWidth*3/4, 110, 20, DARKBLUE); DrawText(TextFormat("Aiming Point %i, %i", (int)player[playerTurn].aimingPoint.x, (int)player[playerTurn].aimingPoint.y), screenWidth*3/4, 110, 20, DARKBLUE);
DrawText(FormatText("Aiming Angle %i", player[playerTurn].aimingAngle), screenWidth*3/4, 140, 20, DARKBLUE); DrawText(TextFormat("Aiming Angle %i", player[playerTurn].aimingAngle), screenWidth*3/4, 140, 20, DARKBLUE);
DrawText(FormatText("Aiming Power %i", player[playerTurn].aimingPower), screenWidth*3/4, 170, 20, DARKBLUE); DrawText(TextFormat("Aiming Power %i", player[playerTurn].aimingPower), screenWidth*3/4, 170, 20, DARKBLUE);
} }
*/ */

View File

@ -92,11 +92,11 @@ static bool gameOver = false;
static bool pause = false; static bool pause = false;
static int score = 0; static int score = 0;
static Missile missile[MAX_MISSILES]; static Missile missile[MAX_MISSILES] = { 0 };
static Interceptor interceptor[MAX_INTERCEPTORS]; static Interceptor interceptor[MAX_INTERCEPTORS] = { 0 };
static Explosion explosion[MAX_EXPLOSIONS]; static Explosion explosion[MAX_EXPLOSIONS] = { 0 };
static Launcher launcher[LAUNCHERS_AMOUNT]; static Launcher launcher[LAUNCHERS_AMOUNT] = { 0 };
static Building building[BUILDINGS_AMOUNT]; static Building building[BUILDINGS_AMOUNT] = { 0 };
static int explosionIndex = 0; static int explosionIndex = 0;
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
@ -126,7 +126,6 @@ int main(void)
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
emscripten_set_main_loop(UpdateDrawFrame, 0, 1); emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
#else #else
SetTargetFPS(60); SetTargetFPS(60);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -139,7 +138,6 @@ int main(void)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
#endif #endif
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadGame(); // Unload loaded data (textures, sounds, models...) UnloadGame(); // Unload loaded data (textures, sounds, models...)
@ -436,7 +434,7 @@ void DrawGame(void)
} }
// Draw score // Draw score
DrawText(FormatText("SCORE %4i", score), 20, 20, 40, LIGHTGRAY); DrawText(TextFormat("SCORE %4i", score), 20, 20, 40, LIGHTGRAY);
if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY); if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY);
} }
@ -504,7 +502,7 @@ static void UpdateIncomingFire()
static int missileIndex = 0; static int missileIndex = 0;
// Launch missile // Launch missile
if (framesCounter % MISSILE_LAUNCH_FRAMES == 0) if (framesCounter%MISSILE_LAUNCH_FRAMES == 0)
{ {
float module; float module;
float sideX; float sideX;

View File

@ -32,7 +32,6 @@
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Types and Structures Definition // Types and Structures Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
typedef struct Player { typedef struct Player {
Vector2 position; Vector2 position;
Vector2 speed; Vector2 speed;
@ -66,33 +65,33 @@ typedef struct Points {
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Global Variables Declaration // Global Variables Declaration
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
static int screenWidth = 800; static const int screenWidth = 800;
static int screenHeight = 450; static const int screenHeight = 450;
static int framesCounter; static int framesCounter = 0;
static bool gameOver; static bool gameOver = false;
static bool pause; static bool pause = false;
static int score; static int score = 0;
static Player player; static Player player = { 0 };
static Shoot shoot[PLAYER_MAX_SHOOTS]; static Shoot shoot[PLAYER_MAX_SHOOTS] = { 0 };
static Ball bigBalls[MAX_BIG_BALLS]; static Ball bigBalls[MAX_BIG_BALLS] = { 0 };
static Ball mediumBalls[MAX_BIG_BALLS*2]; static Ball mediumBalls[MAX_BIG_BALLS*2] = { 0 };
static Ball smallBalls[MAX_BIG_BALLS*4]; static Ball smallBalls[MAX_BIG_BALLS*4] = { 0 };
static Points points[5]; static Points points[5] = { 0 };
// NOTE: Defined triangle is isosceles with common angles of 70 degrees. // NOTE: Defined triangle is isosceles with common angles of 70 degrees.
static float shipHeight; static float shipHeight = 0.0f;
static float gravity; static float gravity = 0.0f;
static int countmediumBallss; static int countmediumBallss = 0;
static int countsmallBallss; static int countsmallBallss = 0;
static int meteorsDestroyed; static int meteorsDestroyed = 0;
static Vector2 linePosition; static Vector2 linePosition = { 0 };
static bool victory; static bool victory = false;
static bool lose; static bool lose = false;
static bool awake; static bool awake = false;
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Module Functions Declaration (local) // Module Functions Declaration (local)
@ -117,7 +116,6 @@ int main(void)
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
emscripten_set_main_loop(UpdateDrawFrame, 0, 1); emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
#else #else
SetTargetFPS(60); SetTargetFPS(60);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -130,7 +128,6 @@ int main(void)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
#endif #endif
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadGame(); // Unload loaded data (textures, sounds, models...) UnloadGame(); // Unload loaded data (textures, sounds, models...)
@ -593,12 +590,12 @@ void DrawGame(void)
{ {
if (points[z].alpha > 0.0f) if (points[z].alpha > 0.0f)
{ {
DrawText(FormatText("+%02i", points[z].value), points[z].position.x, points[z].position.y, 20, Fade(BLUE, points[z].alpha)); DrawText(TextFormat("+%02i", points[z].value), points[z].position.x, points[z].position.y, 20, Fade(BLUE, points[z].alpha));
} }
} }
// Draw score (UI) // Draw score (UI)
DrawText(FormatText("SCORE: %i", score), 10, 10, 20, LIGHTGRAY); DrawText(TextFormat("SCORE: %i", score), 10, 10, 20, LIGHTGRAY);
if (victory) if (victory)
{ {

View File

@ -43,19 +43,19 @@ typedef struct Food {
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Global Variables Declaration // Global Variables Declaration
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
static int screenWidth = 800; static const int screenWidth = 800;
static int screenHeight = 450; static const int screenHeight = 450;
static int framesCounter; static int framesCounter = 0;
static bool gameOver; static bool gameOver = false;
static bool pause; static bool pause = false;
static Food fruit; static Food fruit = { 0 };
static Snake snake[SNAKE_LENGTH]; static Snake snake[SNAKE_LENGTH] = { 0 };
static Vector2 snakePosition[SNAKE_LENGTH]; static Vector2 snakePosition[SNAKE_LENGTH] = { 0 };
static bool allowMove; static bool allowMove = false;
static Vector2 offset; static Vector2 offset = { 0 };
static int counterTail; static int counterTail = 0;
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Module Functions Declaration (local) // Module Functions Declaration (local)
@ -80,7 +80,6 @@ int main(void)
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
emscripten_set_main_loop(UpdateDrawFrame, 0, 1); emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
#else #else
SetTargetFPS(60); SetTargetFPS(60);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -93,7 +92,6 @@ int main(void)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
#endif #endif
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadGame(); // Unload loaded data (textures, sounds, models...) UnloadGame(); // Unload loaded data (textures, sounds, models...)
@ -150,7 +148,7 @@ void UpdateGame(void)
if (!pause) if (!pause)
{ {
// control // Player control
if (IsKeyPressed(KEY_RIGHT) && (snake[0].speed.x == 0) && allowMove) if (IsKeyPressed(KEY_RIGHT) && (snake[0].speed.x == 0) && allowMove)
{ {
snake[0].speed = (Vector2){ SQUARE_SIZE, 0 }; snake[0].speed = (Vector2){ SQUARE_SIZE, 0 };
@ -172,7 +170,7 @@ void UpdateGame(void)
allowMove = false; allowMove = false;
} }
// movement // Snake movement
for (int i = 0; i < counterTail; i++) snakePosition[i] = snake[i].position; for (int i = 0; i < counterTail; i++) snakePosition[i] = snake[i].position;
if ((framesCounter%5) == 0) if ((framesCounter%5) == 0)
@ -189,7 +187,7 @@ void UpdateGame(void)
} }
} }
// wall behaviour // Wall behaviour
if (((snake[0].position.x) > (screenWidth - offset.x)) || if (((snake[0].position.x) > (screenWidth - offset.x)) ||
((snake[0].position.y) > (screenHeight - offset.y)) || ((snake[0].position.y) > (screenHeight - offset.y)) ||
(snake[0].position.x < 0) || (snake[0].position.y < 0)) (snake[0].position.x < 0) || (snake[0].position.y < 0))
@ -197,13 +195,13 @@ void UpdateGame(void)
gameOver = true; gameOver = true;
} }
// collision with yourself // Collision with yourself
for (int i = 1; i < counterTail; i++) for (int i = 1; i < counterTail; i++)
{ {
if ((snake[0].position.x == snake[i].position.x) && (snake[0].position.y == snake[i].position.y)) gameOver = true; if ((snake[0].position.x == snake[i].position.x) && (snake[0].position.y == snake[i].position.y)) gameOver = true;
} }
// fruit.position calculation // Fruit position calculation
if (!fruit.active) if (!fruit.active)
{ {
fruit.active = true; fruit.active = true;
@ -219,7 +217,7 @@ void UpdateGame(void)
} }
} }
// collision // Collision
if ((snake[0].position.x < (fruit.position.x + fruit.size.x) && (snake[0].position.x + snake[0].size.x) > fruit.position.x) && if ((snake[0].position.x < (fruit.position.x + fruit.size.x) && (snake[0].position.x + snake[0].size.x) > fruit.position.x) &&
(snake[0].position.y < (fruit.position.y + fruit.size.y) && (snake[0].position.y + snake[0].size.y) > fruit.position.y)) (snake[0].position.y < (fruit.position.y + fruit.size.y) && (snake[0].position.y + snake[0].size.y) > fruit.position.y))
{ {

View File

@ -54,25 +54,25 @@ typedef struct Shoot{
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Global Variables Declaration // Global Variables Declaration
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
static int screenWidth = 800; static const int screenWidth = 800;
static int screenHeight = 450; static const int screenHeight = 450;
static bool gameOver; static bool gameOver = false;
static bool pause; static bool pause = false;
static int score; static int score = 0;
static bool victory; static bool victory = false;
static Player player; static Player player = { 0 };
static Enemy enemy[NUM_MAX_ENEMIES]; static Enemy enemy[NUM_MAX_ENEMIES] = { 0 };
static Shoot shoot[NUM_SHOOTS]; static Shoot shoot[NUM_SHOOTS] = { 0 };
static EnemyWave wave; static EnemyWave wave = { 0 };
static int shootRate; static int shootRate = 0;
static float alpha; static float alpha = 0.0f;
static int activeEnemies; static int activeEnemies = 0;
static int enemiesKill; static int enemiesKill = 0;
static bool smooth; static bool smooth = false;
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Module Functions Declaration (local) // Module Functions Declaration (local)
@ -97,7 +97,6 @@ int main(void)
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
emscripten_set_main_loop(UpdateDrawFrame, 0, 1); emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
#else #else
SetTargetFPS(60); SetTargetFPS(60);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -110,7 +109,6 @@ int main(void)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
#endif #endif
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadGame(); // Unload loaded data (textures, sounds, models...) UnloadGame(); // Unload loaded data (textures, sounds, models...)
@ -289,7 +287,7 @@ void UpdateGame(void)
if (player.rec.y <= 0) player.rec.y = 0; if (player.rec.y <= 0) player.rec.y = 0;
if (player.rec.y + player.rec.height >= screenHeight) player.rec.y = screenHeight - player.rec.height; if (player.rec.y + player.rec.height >= screenHeight) player.rec.y = screenHeight - player.rec.height;
//Shoot initialization // Shoot initialization
if (IsKeyDown(KEY_SPACE)) if (IsKeyDown(KEY_SPACE))
{ {
shootRate += 5; shootRate += 5;
@ -375,7 +373,7 @@ void DrawGame(void)
if (shoot[i].active) DrawRectangleRec(shoot[i].rec, shoot[i].color); if (shoot[i].active) DrawRectangleRec(shoot[i].rec, shoot[i].color);
} }
DrawText(FormatText("%04i", score), 20, 20, 40, GRAY); DrawText(TextFormat("%04i", score), 20, 20, 40, GRAY);
if (victory) DrawText("YOU WIN", screenWidth/2 - MeasureText("YOU WIN", 40)/2, screenHeight/2 - 40, 40, BLACK); if (victory) DrawText("YOU WIN", screenWidth/2 - MeasureText("YOU WIN", 40)/2, screenHeight/2 - 40, 40, BLACK);

View File

@ -44,8 +44,8 @@ typedef enum GridSquare { EMPTY, MOVING, FULL, BLOCK, FADING } GridSquare;
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Global Variables Declaration // Global Variables Declaration
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
static int screenWidth = 800; static const int screenWidth = 800;
static int screenHeight = 450; static const int screenHeight = 450;
static bool gameOver = false; static bool gameOver = false;
static bool pause = false; static bool pause = false;
@ -99,7 +99,7 @@ static void ResolveFallingMovement();
static bool ResolveLateralMovement(); static bool ResolveLateralMovement();
static bool ResolveTurnMovement(); static bool ResolveTurnMovement();
static void CheckDetection(); static void CheckDetection();
static void CheckCompletition(); static void CheckCompletion();
static void DeleteCompleteLines(); static void DeleteCompleteLines();
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
@ -116,7 +116,6 @@ int main(void)
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
emscripten_set_main_loop(UpdateDrawFrame, 0, 1); emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
#else #else
SetTargetFPS(60); SetTargetFPS(60);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -129,7 +128,6 @@ int main(void)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
#endif #endif
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadGame(); // Unload loaded data (textures, sounds, models...) UnloadGame(); // Unload loaded data (textures, sounds, models...)
@ -239,7 +237,7 @@ void UpdateGame(void)
ResolveFallingMovement(&detection, &pieceActive); ResolveFallingMovement(&detection, &pieceActive);
// Check if we fullfilled a line and if so, erase the line and pull down the the lines above // Check if we fullfilled a line and if so, erase the line and pull down the the lines above
CheckCompletition(&lineToDelete); CheckCompletion(&lineToDelete);
gravityMovementCounter = 0; gravityMovementCounter = 0;
} }
@ -387,7 +385,7 @@ void DrawGame(void)
} }
DrawText("INCOMING:", offset.x, offset.y - 100, 10, GRAY); DrawText("INCOMING:", offset.x, offset.y - 100, 10, GRAY);
DrawText(FormatText("LINES: %04i", lines), offset.x, offset.y + 20, 10, GRAY); DrawText(TextFormat("LINES: %04i", lines), offset.x, offset.y + 20, 10, GRAY);
if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY); if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY);
} }
@ -450,8 +448,7 @@ static bool Createpiece()
static void GetRandompiece() static void GetRandompiece()
{ {
srand(time(NULL)); int random = GetRandomValue(0, 6);
int random = rand() % 7;
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
@ -461,15 +458,15 @@ static void GetRandompiece()
} }
} }
switch(random) switch (random)
{ {
case 0: { incomingPiece[1][1] = MOVING; incomingPiece[2][1] = MOVING; incomingPiece[1][2] = MOVING; incomingPiece[2][2] = MOVING; } break; //Cube case 0: { incomingPiece[1][1] = MOVING; incomingPiece[2][1] = MOVING; incomingPiece[1][2] = MOVING; incomingPiece[2][2] = MOVING; } break; //Cube
case 1: { incomingPiece[1][0] = MOVING; incomingPiece[1][1] = MOVING; incomingPiece[1][2] = MOVING; incomingPiece[2][2] = MOVING; } break; //L case 1: { incomingPiece[1][0] = MOVING; incomingPiece[1][1] = MOVING; incomingPiece[1][2] = MOVING; incomingPiece[2][2] = MOVING; } break; //L
case 2: { incomingPiece[1][2] = MOVING; incomingPiece[2][0] = MOVING; incomingPiece[2][1] = MOVING; incomingPiece[2][2] = MOVING; } break; //L inversa case 2: { incomingPiece[1][2] = MOVING; incomingPiece[2][0] = MOVING; incomingPiece[2][1] = MOVING; incomingPiece[2][2] = MOVING; } break; //L inversa
case 3: { incomingPiece[0][1] = MOVING; incomingPiece[1][1] = MOVING; incomingPiece[2][1] = MOVING; incomingPiece[3][1] = MOVING; } break; //Recta case 3: { incomingPiece[0][1] = MOVING; incomingPiece[1][1] = MOVING; incomingPiece[2][1] = MOVING; incomingPiece[3][1] = MOVING; } break; //Recta
case 4: { incomingPiece[1][0] = MOVING; incomingPiece[1][1] = MOVING; incomingPiece[1][2] = MOVING; incomingPiece[2][1] = MOVING; } break; //Creu tallada case 4: { incomingPiece[1][0] = MOVING; incomingPiece[1][1] = MOVING; incomingPiece[1][2] = MOVING; incomingPiece[2][1] = MOVING; } break; //Creu tallada
case 5: { incomingPiece[1][1] = MOVING; incomingPiece[2][1] = MOVING; incomingPiece[2][2] = MOVING; incomingPiece[3][2] = MOVING; } break; //S case 5: { incomingPiece[1][1] = MOVING; incomingPiece[2][1] = MOVING; incomingPiece[2][2] = MOVING; incomingPiece[3][2] = MOVING; } break; //S
case 6: { incomingPiece[1][2] = MOVING; incomingPiece[2][2] = MOVING; incomingPiece[2][1] = MOVING; incomingPiece[3][1] = MOVING; } break; //S inversa case 6: { incomingPiece[1][2] = MOVING; incomingPiece[2][2] = MOVING; incomingPiece[2][1] = MOVING; incomingPiece[3][1] = MOVING; } break; //S inversa
} }
} }
@ -491,8 +488,7 @@ static void ResolveFallingMovement(bool *detection, bool *pieceActive)
} }
} }
} }
// We move down the piece else // We move down the piece
else
{ {
for (int j = GRID_VERTICAL_SIZE - 2; j >= 0; j--) for (int j = GRID_VERTICAL_SIZE - 2; j >= 0; j--)
{ {
@ -505,6 +501,7 @@ static void ResolveFallingMovement(bool *detection, bool *pieceActive)
} }
} }
} }
piecePositionY++; piecePositionY++;
} }
} }
@ -513,8 +510,8 @@ static bool ResolveLateralMovement()
{ {
bool collision = false; bool collision = false;
// Move left // Piece movement
if (IsKeyDown(KEY_LEFT)) if (IsKeyDown(KEY_LEFT)) // Move left
{ {
// Check if is possible to move to left // Check if is possible to move to left
for (int j = GRID_VERTICAL_SIZE - 2; j >= 0; j--) for (int j = GRID_VERTICAL_SIZE - 2; j >= 0; j--)
@ -528,6 +525,7 @@ static bool ResolveLateralMovement()
} }
} }
} }
// If able, move left // If able, move left
if (!collision) if (!collision)
{ {
@ -547,9 +545,7 @@ static bool ResolveLateralMovement()
piecePositionX--; piecePositionX--;
} }
} }
else if (IsKeyDown(KEY_RIGHT)) // Move right
// Move right
else if (IsKeyDown(KEY_RIGHT))
{ {
// Check if is possible to move to right // Check if is possible to move to right
for (int j = GRID_VERTICAL_SIZE - 2; j >= 0; j--) for (int j = GRID_VERTICAL_SIZE - 2; j >= 0; j--)
@ -567,6 +563,7 @@ static bool ResolveLateralMovement()
} }
} }
} }
// If able move right // If able move right
if (!collision) if (!collision)
{ {
@ -595,112 +592,73 @@ static bool ResolveTurnMovement()
// Input for turning the piece // Input for turning the piece
if (IsKeyDown(KEY_UP)) if (IsKeyDown(KEY_UP))
{ {
int aux; int aux = 0;
bool checker = false; bool checker = false;
// Check all turning possibilities // Check all turning possibilities
if ((grid[piecePositionX + 3][piecePositionY] == MOVING) && if ((grid[piecePositionX + 3][piecePositionY] == MOVING) &&
(grid[piecePositionX][piecePositionY] != EMPTY) && (grid[piecePositionX][piecePositionY] != EMPTY) &&
(grid[piecePositionX][piecePositionY] != MOVING)) (grid[piecePositionX][piecePositionY] != MOVING)) checker = true;
{
checker = true;
}
if ((grid[piecePositionX + 3][piecePositionY + 3] == MOVING) && if ((grid[piecePositionX + 3][piecePositionY + 3] == MOVING) &&
(grid[piecePositionX + 3][piecePositionY] != EMPTY) && (grid[piecePositionX + 3][piecePositionY] != EMPTY) &&
(grid[piecePositionX + 3][piecePositionY] != MOVING)) (grid[piecePositionX + 3][piecePositionY] != MOVING)) checker = true;
{
checker = true;
}
if ((grid[piecePositionX][piecePositionY + 3] == MOVING) && if ((grid[piecePositionX][piecePositionY + 3] == MOVING) &&
(grid[piecePositionX + 3][piecePositionY + 3] != EMPTY) && (grid[piecePositionX + 3][piecePositionY + 3] != EMPTY) &&
(grid[piecePositionX + 3][piecePositionY + 3] != MOVING)) (grid[piecePositionX + 3][piecePositionY + 3] != MOVING)) checker = true;
{
checker = true;
}
if ((grid[piecePositionX][piecePositionY] == MOVING) && if ((grid[piecePositionX][piecePositionY] == MOVING) &&
(grid[piecePositionX][piecePositionY + 3] != EMPTY) && (grid[piecePositionX][piecePositionY + 3] != EMPTY) &&
(grid[piecePositionX][piecePositionY + 3] != MOVING)) (grid[piecePositionX][piecePositionY + 3] != MOVING)) checker = true;
{
checker = true;
}
if ((grid[piecePositionX + 1][piecePositionY] == MOVING) && if ((grid[piecePositionX + 1][piecePositionY] == MOVING) &&
(grid[piecePositionX][piecePositionY + 2] != EMPTY) && (grid[piecePositionX][piecePositionY + 2] != EMPTY) &&
(grid[piecePositionX][piecePositionY + 2] != MOVING)) (grid[piecePositionX][piecePositionY + 2] != MOVING)) checker = true;
{
checker = true;
}
if ((grid[piecePositionX + 3][piecePositionY + 1] == MOVING) && if ((grid[piecePositionX + 3][piecePositionY + 1] == MOVING) &&
(grid[piecePositionX + 1][piecePositionY] != EMPTY) && (grid[piecePositionX + 1][piecePositionY] != EMPTY) &&
(grid[piecePositionX + 1][piecePositionY] != MOVING)) (grid[piecePositionX + 1][piecePositionY] != MOVING)) checker = true;
{
checker = true;
}
if ((grid[piecePositionX + 2][piecePositionY + 3] == MOVING) && if ((grid[piecePositionX + 2][piecePositionY + 3] == MOVING) &&
(grid[piecePositionX + 3][piecePositionY + 1] != EMPTY) && (grid[piecePositionX + 3][piecePositionY + 1] != EMPTY) &&
(grid[piecePositionX + 3][piecePositionY + 1] != MOVING)) (grid[piecePositionX + 3][piecePositionY + 1] != MOVING)) checker = true;
{
checker = true;
}
if ((grid[piecePositionX][piecePositionY + 2] == MOVING) && if ((grid[piecePositionX][piecePositionY + 2] == MOVING) &&
(grid[piecePositionX + 2][piecePositionY + 3] != EMPTY) && (grid[piecePositionX + 2][piecePositionY + 3] != EMPTY) &&
(grid[piecePositionX + 2][piecePositionY + 3] != MOVING)) (grid[piecePositionX + 2][piecePositionY + 3] != MOVING)) checker = true;
{
checker = true;
}
if ((grid[piecePositionX + 2][piecePositionY] == MOVING) && if ((grid[piecePositionX + 2][piecePositionY] == MOVING) &&
(grid[piecePositionX][piecePositionY + 1] != EMPTY) && (grid[piecePositionX][piecePositionY + 1] != EMPTY) &&
(grid[piecePositionX][piecePositionY + 1] != MOVING)) (grid[piecePositionX][piecePositionY + 1] != MOVING)) checker = true;
{
checker = true;
}
if ((grid[piecePositionX + 3][piecePositionY + 2] == MOVING) && if ((grid[piecePositionX + 3][piecePositionY + 2] == MOVING) &&
(grid[piecePositionX + 2][piecePositionY] != EMPTY) && (grid[piecePositionX + 2][piecePositionY] != EMPTY) &&
(grid[piecePositionX + 2][piecePositionY] != MOVING)) (grid[piecePositionX + 2][piecePositionY] != MOVING)) checker = true;
{
checker = true;
}
if ((grid[piecePositionX + 1][piecePositionY + 3] == MOVING) && if ((grid[piecePositionX + 1][piecePositionY + 3] == MOVING) &&
(grid[piecePositionX + 3][piecePositionY + 2] != EMPTY) && (grid[piecePositionX + 3][piecePositionY + 2] != EMPTY) &&
(grid[piecePositionX + 3][piecePositionY + 2] != MOVING)) (grid[piecePositionX + 3][piecePositionY + 2] != MOVING)) checker = true;
{
checker = true;
}
if ((grid[piecePositionX][piecePositionY + 1] == MOVING) && if ((grid[piecePositionX][piecePositionY + 1] == MOVING) &&
(grid[piecePositionX + 1][piecePositionY + 3] != EMPTY) && (grid[piecePositionX + 1][piecePositionY + 3] != EMPTY) &&
(grid[piecePositionX + 1][piecePositionY + 3] != MOVING)) (grid[piecePositionX + 1][piecePositionY + 3] != MOVING)) checker = true;
{
checker = true;
}
if ((grid[piecePositionX + 1][piecePositionY + 1] == MOVING) && if ((grid[piecePositionX + 1][piecePositionY + 1] == MOVING) &&
(grid[piecePositionX + 1][piecePositionY + 2] != EMPTY) && (grid[piecePositionX + 1][piecePositionY + 2] != EMPTY) &&
(grid[piecePositionX + 1][piecePositionY + 2] != MOVING)) (grid[piecePositionX + 1][piecePositionY + 2] != MOVING)) checker = true;
{
checker = true;
}
if ((grid[piecePositionX + 2][piecePositionY + 1] == MOVING) && if ((grid[piecePositionX + 2][piecePositionY + 1] == MOVING) &&
(grid[piecePositionX + 1][piecePositionY + 1] != EMPTY) && (grid[piecePositionX + 1][piecePositionY + 1] != EMPTY) &&
(grid[piecePositionX + 1][piecePositionY + 1] != MOVING)) (grid[piecePositionX + 1][piecePositionY + 1] != MOVING)) checker = true;
{
checker = true;
}
if ((grid[piecePositionX + 2][piecePositionY + 2] == MOVING) && if ((grid[piecePositionX + 2][piecePositionY + 2] == MOVING) &&
(grid[piecePositionX + 2][piecePositionY + 1] != EMPTY) && (grid[piecePositionX + 2][piecePositionY + 1] != EMPTY) &&
(grid[piecePositionX + 2][piecePositionY + 1] != MOVING)) (grid[piecePositionX + 2][piecePositionY + 1] != MOVING)) checker = true;
{
checker = true;
}
if ((grid[piecePositionX + 1][piecePositionY + 2] == MOVING) && if ((grid[piecePositionX + 1][piecePositionY + 2] == MOVING) &&
(grid[piecePositionX + 2][piecePositionY + 2] != EMPTY) && (grid[piecePositionX + 2][piecePositionY + 2] != EMPTY) &&
(grid[piecePositionX + 2][piecePositionY + 2] != MOVING)) (grid[piecePositionX + 2][piecePositionY + 2] != MOVING)) checker = true;
{
checker = true;
}
if (!checker) if (!checker)
{ {
@ -750,6 +708,7 @@ static bool ResolveTurnMovement()
} }
} }
} }
return true; return true;
} }
@ -767,9 +726,9 @@ static void CheckDetection(bool *detection)
} }
} }
static void CheckCompletition(bool *lineToDelete) static void CheckCompletion(bool *lineToDelete)
{ {
int calculator; int calculator = 0;
for (int j = GRID_VERTICAL_SIZE - 2; j >= 0; j--) for (int j = GRID_VERTICAL_SIZE - 2; j >= 0; j--)
{ {
@ -801,7 +760,7 @@ static void CheckCompletition(bool *lineToDelete)
static void DeleteCompleteLines() static void DeleteCompleteLines()
{ {
// erase the completed line // Erase the completed line
for (int j = GRID_VERTICAL_SIZE - 2; j >= 0; j--) for (int j = GRID_VERTICAL_SIZE - 2; j >= 0; j--)
{ {
while (grid[1][j] == FADING) while (grid[1][j] == FADING)
@ -810,6 +769,7 @@ static void DeleteCompleteLines()
{ {
grid[i][j] = EMPTY; grid[i][j] = EMPTY;
} }
for (int j2 = j-1; j2 >= 0; j2--) for (int j2 = j-1; j2 >= 0; j2--)
{ {
for (int i2 = 1; i2 < GRID_HORIZONTAL_SIZE - 1; i2++) for (int i2 = 1; i2 < GRID_HORIZONTAL_SIZE - 1; i2++)