Review sample games
This commit is contained in:
parent
0027868d1f
commit
8b4f58b9e9
@ -25,7 +25,6 @@
|
||||
//----------------------------------------------------------------------------------
|
||||
// Some Defines
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
#define PLAYER_MAX_LIFE 5
|
||||
#define LINES_OF_BRICKS 5
|
||||
#define BRICKS_PER_LINE 20
|
||||
@ -56,16 +55,16 @@ typedef struct Brick {
|
||||
//------------------------------------------------------------------------------------
|
||||
// Global Variables Declaration
|
||||
//------------------------------------------------------------------------------------
|
||||
static int screenWidth = 800;
|
||||
static int screenHeight = 450;
|
||||
static const int screenWidth = 800;
|
||||
static const int screenHeight = 450;
|
||||
|
||||
static bool gameOver;
|
||||
static bool pause;
|
||||
static bool gameOver = false;
|
||||
static bool pause = false;
|
||||
|
||||
static Player player;
|
||||
static Ball ball;
|
||||
static Brick brick[LINES_OF_BRICKS][BRICKS_PER_LINE];
|
||||
static Vector2 brickSize;
|
||||
static Player player = { 0 };
|
||||
static Ball ball = { 0 };
|
||||
static Brick brick[LINES_OF_BRICKS][BRICKS_PER_LINE] = { 0 };
|
||||
static Vector2 brickSize = { 0 };
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Module Functions Declaration (local)
|
||||
@ -90,7 +89,6 @@ int main(void)
|
||||
#if defined(PLATFORM_WEB)
|
||||
emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
|
||||
#else
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
@ -103,7 +101,6 @@ int main(void)
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
#endif
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadGame(); // Unload loaded data (textures, sounds, models...)
|
||||
@ -272,8 +269,6 @@ void UpdateGame(void)
|
||||
gameOver = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Draw game (one frame)
|
||||
|
@ -34,7 +34,6 @@
|
||||
//----------------------------------------------------------------------------------
|
||||
// Types and Structures Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
typedef struct Player {
|
||||
Vector2 position;
|
||||
Vector2 speed;
|
||||
@ -65,25 +64,25 @@ typedef struct Meteor {
|
||||
//------------------------------------------------------------------------------------
|
||||
// Global Variables Declaration
|
||||
//------------------------------------------------------------------------------------
|
||||
static int screenWidth = 800;
|
||||
static int screenHeight = 450;
|
||||
static const int screenWidth = 800;
|
||||
static const int screenHeight = 450;
|
||||
|
||||
static bool gameOver;
|
||||
static bool pause;
|
||||
static bool victory;
|
||||
static bool gameOver = false;
|
||||
static bool pause = false;
|
||||
static bool victory = false;
|
||||
|
||||
// NOTE: Defined triangle is isosceles with common angles of 70 degrees.
|
||||
static float shipHeight;
|
||||
static float shipHeight = 0.0f;
|
||||
|
||||
static Player player;
|
||||
static Shoot shoot[PLAYER_MAX_SHOOTS];
|
||||
static Meteor bigMeteor[MAX_BIG_METEORS];
|
||||
static Meteor mediumMeteor[MAX_MEDIUM_METEORS];
|
||||
static Meteor smallMeteor[MAX_SMALL_METEORS];
|
||||
static Player player = { 0 };
|
||||
static Shoot shoot[PLAYER_MAX_SHOOTS] = { 0 };
|
||||
static Meteor bigMeteor[MAX_BIG_METEORS] = { 0 };
|
||||
static Meteor mediumMeteor[MAX_MEDIUM_METEORS] = { 0 };
|
||||
static Meteor smallMeteor[MAX_SMALL_METEORS] = { 0 };
|
||||
|
||||
static int midMeteorsCount;
|
||||
static int smallMeteorsCount;
|
||||
static int destroyedMeteorsCount;
|
||||
static int midMeteorsCount = 0;
|
||||
static int smallMeteorsCount = 0;
|
||||
static int destroyedMeteorsCount = 0;
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Module Functions Declaration (local)
|
||||
@ -108,7 +107,6 @@ int main(void)
|
||||
#if defined(PLATFORM_WEB)
|
||||
emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
|
||||
#else
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
@ -121,7 +119,6 @@ int main(void)
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
#endif
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadGame(); // Unload loaded data (textures, sounds, models...)
|
||||
|
@ -33,7 +33,6 @@
|
||||
//----------------------------------------------------------------------------------
|
||||
// Types and Structures Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
typedef struct Player {
|
||||
Vector2 position;
|
||||
Vector2 speed;
|
||||
@ -54,19 +53,19 @@ typedef struct Meteor {
|
||||
//------------------------------------------------------------------------------------
|
||||
// Global Variables Declaration
|
||||
//------------------------------------------------------------------------------------
|
||||
static int screenWidth = 800;
|
||||
static int screenHeight = 450;
|
||||
static const int screenWidth = 800;
|
||||
static const int screenHeight = 450;
|
||||
|
||||
static int framesCounter;
|
||||
static bool gameOver;
|
||||
static bool pause;
|
||||
static int framesCounter = 0;
|
||||
static bool gameOver = false;
|
||||
static bool pause = false;
|
||||
|
||||
// NOTE: Defined triangle is isosceles with common angles of 70 degrees.
|
||||
static float shipHeight;
|
||||
static float shipHeight = 0.0f;
|
||||
|
||||
static Player player;
|
||||
static Meteor mediumMeteor[MAX_MEDIUM_METEORS];
|
||||
static Meteor smallMeteor[MAX_SMALL_METEORS];
|
||||
static Player player = { 0 };
|
||||
static Meteor mediumMeteor[MAX_MEDIUM_METEORS] = { 0 };
|
||||
static Meteor smallMeteor[MAX_SMALL_METEORS] = { 0 };
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Module Functions Declaration (local)
|
||||
@ -91,7 +90,6 @@ int main(void)
|
||||
#if defined(PLATFORM_WEB)
|
||||
emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
|
||||
#else
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
@ -104,7 +102,6 @@ int main(void)
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
#endif
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
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));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -42,19 +42,19 @@ typedef struct Tubes {
|
||||
//------------------------------------------------------------------------------------
|
||||
// Global Variables Declaration
|
||||
//------------------------------------------------------------------------------------
|
||||
static int screenWidth = 800;
|
||||
static int screenHeight = 450;
|
||||
static const int screenWidth = 800;
|
||||
static const int screenHeight = 450;
|
||||
|
||||
static bool gameOver;
|
||||
static bool pause;
|
||||
static int score;
|
||||
static bool gameOver = false;
|
||||
static bool pause = false;
|
||||
static int score = 0;
|
||||
static int hiScore = 0;
|
||||
|
||||
static Floppy floppy;
|
||||
static Tubes tubes[MAX_TUBES*2];
|
||||
static Vector2 tubesPos[MAX_TUBES];
|
||||
static int tubesSpeedX;
|
||||
static bool superfx;
|
||||
static Floppy floppy = { 0 };
|
||||
static Tubes tubes[MAX_TUBES*2] = { 0 };
|
||||
static Vector2 tubesPos[MAX_TUBES] = { 0 };
|
||||
static int tubesSpeedX = 0;
|
||||
static bool superfx = false;
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Module Functions Declaration (local)
|
||||
@ -79,7 +79,6 @@ int main(void)
|
||||
#if defined(PLATFORM_WEB)
|
||||
emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
|
||||
#else
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
@ -92,7 +91,6 @@ int main(void)
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
#endif
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadGame(); // Unload loaded data (textures, sounds, models...)
|
||||
@ -216,8 +214,8 @@ void DrawGame(void)
|
||||
superfx = false;
|
||||
}
|
||||
|
||||
DrawText(FormatText("%04i", score), 20, 20, 40, GRAY);
|
||||
DrawText(FormatText("HI-SCORE: %04i", hiScore), 20, 70, 20, LIGHTGRAY);
|
||||
DrawText(TextFormat("%04i", score), 20, 20, 40, GRAY);
|
||||
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);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ typedef struct Enemy {
|
||||
Vector2 speed;
|
||||
int radius;
|
||||
int radiusBounds;
|
||||
bool moveRight; // RAY: o__O
|
||||
bool moveRight;
|
||||
} Enemy;
|
||||
|
||||
typedef struct Points {
|
||||
@ -51,19 +51,19 @@ typedef struct Home {
|
||||
//------------------------------------------------------------------------------------
|
||||
// Global Variables Declaration
|
||||
//------------------------------------------------------------------------------------
|
||||
static int screenWidth = 800;
|
||||
static int screenHeight = 450;
|
||||
static const int screenWidth = 800;
|
||||
static const int screenHeight = 450;
|
||||
|
||||
static bool gameOver;
|
||||
static bool pause;
|
||||
static int score;
|
||||
static bool gameOver = false;
|
||||
static bool pause = false;
|
||||
static int score = 0;
|
||||
static int hiScore = 0;
|
||||
|
||||
static Player player;
|
||||
static Enemy enemy;
|
||||
static Points points;
|
||||
static Home home;
|
||||
static bool follow;
|
||||
static Player player = { 0 };
|
||||
static Enemy enemy = { 0 };
|
||||
static Points points = { 0 };
|
||||
static Home home = { 0 };
|
||||
static bool follow = false;
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Module Functions Declaration (local)
|
||||
@ -88,7 +88,6 @@ int main(void)
|
||||
#if defined(PLATFORM_WEB)
|
||||
emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
|
||||
#else
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
@ -101,7 +100,6 @@ int main(void)
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
#endif
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadGame(); // Unload loaded data (textures, sounds, models...)
|
||||
@ -155,19 +153,19 @@ void UpdateGame(void)
|
||||
|
||||
if (!pause)
|
||||
{
|
||||
//Control player
|
||||
// Control player
|
||||
if (IsKeyDown(KEY_RIGHT)) 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_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 >= 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 >= 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 (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;
|
||||
}
|
||||
|
||||
//wall behaviour enemy
|
||||
// Wall behaviour enemy
|
||||
if (enemy.position.x - enemy.radius <= 0) enemy.moveRight = true;
|
||||
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 >= screenHeight) enemy.position.y = screenHeight - enemy.radius;
|
||||
|
||||
//Collisions
|
||||
// Collisions
|
||||
if (CheckCollisionCircles(player.position, player.radius, points.position, points.radius) && points.active)
|
||||
{
|
||||
follow = true;
|
||||
@ -257,8 +255,8 @@ void DrawGame(void)
|
||||
DrawCircleV(player.position, player.radius, GRAY);
|
||||
if (points.active) DrawCircleV(points.position, points.radius, GOLD);
|
||||
|
||||
DrawText(FormatText("SCORE: %04i", score), 20, 15, 20, GRAY);
|
||||
DrawText(FormatText("HI-SCORE: %04i", hiScore), 300, 15, 20, GRAY);
|
||||
DrawText(TextFormat("SCORE: %04i", score), 20, 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);
|
||||
}
|
||||
|
@ -84,16 +84,16 @@ typedef struct Ball {
|
||||
//------------------------------------------------------------------------------------
|
||||
// Global Variables Declaration
|
||||
//------------------------------------------------------------------------------------
|
||||
static int screenWidth = 800;
|
||||
static int screenHeight = 450;
|
||||
static const int screenWidth = 800;
|
||||
static const int screenHeight = 450;
|
||||
|
||||
static bool gameOver = false;
|
||||
static bool pause = false;
|
||||
|
||||
static Player player[MAX_PLAYERS];
|
||||
static Building building[MAX_BUILDINGS];
|
||||
static Explosion explosion[MAX_EXPLOSIONS];
|
||||
static Ball ball;
|
||||
static Player player[MAX_PLAYERS] = { 0 };
|
||||
static Building building[MAX_BUILDINGS] = { 0 };
|
||||
static Explosion explosion[MAX_EXPLOSIONS] = { 0 };
|
||||
static Ball ball = { 0 };
|
||||
|
||||
static int playerTurn = 0;
|
||||
static bool ballOnAir = false;
|
||||
@ -272,21 +272,21 @@ void DrawGame(void)
|
||||
/*
|
||||
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(FormatText("Previous Angle %i", player[playerTurn].previousAngle), 20, 50, 20, DARKBLUE);
|
||||
DrawText(FormatText("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(FormatText("Aiming Angle %i", player[playerTurn].aimingAngle), 20, 140, 20, DARKBLUE);
|
||||
DrawText(FormatText("Aiming Power %i", player[playerTurn].aimingPower), 20, 170, 20, DARKBLUE);
|
||||
DrawText(TextFormat("Previous Point %i, %i", (int)player[playerTurn].previousPoint.x, (int)player[playerTurn].previousPoint.y), 20, 20, 20, DARKBLUE);
|
||||
DrawText(TextFormat("Previous Angle %i", player[playerTurn].previousAngle), 20, 50, 20, DARKBLUE);
|
||||
DrawText(TextFormat("Previous Power %i", player[playerTurn].previousPower), 20, 80, 20, DARKBLUE);
|
||||
DrawText(TextFormat("Aiming Point %i, %i", (int)player[playerTurn].aimingPoint.x, (int)player[playerTurn].aimingPoint.y), 20, 110, 20, DARKBLUE);
|
||||
DrawText(TextFormat("Aiming Angle %i", player[playerTurn].aimingAngle), 20, 140, 20, DARKBLUE);
|
||||
DrawText(TextFormat("Aiming Power %i", player[playerTurn].aimingPower), 20, 170, 20, DARKBLUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawText(FormatText("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(FormatText("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(FormatText("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("Previous Point %i, %i", (int)player[playerTurn].previousPoint.x, (int)player[playerTurn].previousPoint.y), screenWidth*3/4, 20, 20, DARKBLUE);
|
||||
DrawText(TextFormat("Previous Angle %i", player[playerTurn].previousAngle), screenWidth*3/4, 50, 20, DARKBLUE);
|
||||
DrawText(TextFormat("Previous Power %i", player[playerTurn].previousPower), screenWidth*3/4, 80, 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(TextFormat("Aiming Angle %i", player[playerTurn].aimingAngle), screenWidth*3/4, 140, 20, DARKBLUE);
|
||||
DrawText(TextFormat("Aiming Power %i", player[playerTurn].aimingPower), screenWidth*3/4, 170, 20, DARKBLUE);
|
||||
}
|
||||
*/
|
||||
|
||||
|
@ -92,11 +92,11 @@ static bool gameOver = false;
|
||||
static bool pause = false;
|
||||
static int score = 0;
|
||||
|
||||
static Missile missile[MAX_MISSILES];
|
||||
static Interceptor interceptor[MAX_INTERCEPTORS];
|
||||
static Explosion explosion[MAX_EXPLOSIONS];
|
||||
static Launcher launcher[LAUNCHERS_AMOUNT];
|
||||
static Building building[BUILDINGS_AMOUNT];
|
||||
static Missile missile[MAX_MISSILES] = { 0 };
|
||||
static Interceptor interceptor[MAX_INTERCEPTORS] = { 0 };
|
||||
static Explosion explosion[MAX_EXPLOSIONS] = { 0 };
|
||||
static Launcher launcher[LAUNCHERS_AMOUNT] = { 0 };
|
||||
static Building building[BUILDINGS_AMOUNT] = { 0 };
|
||||
static int explosionIndex = 0;
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
@ -126,7 +126,6 @@ int main(void)
|
||||
#if defined(PLATFORM_WEB)
|
||||
emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
|
||||
#else
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
@ -139,7 +138,6 @@ int main(void)
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
#endif
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadGame(); // Unload loaded data (textures, sounds, models...)
|
||||
@ -436,7 +434,7 @@ void DrawGame(void)
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
@ -504,7 +502,7 @@ static void UpdateIncomingFire()
|
||||
static int missileIndex = 0;
|
||||
|
||||
// Launch missile
|
||||
if (framesCounter % MISSILE_LAUNCH_FRAMES == 0)
|
||||
if (framesCounter%MISSILE_LAUNCH_FRAMES == 0)
|
||||
{
|
||||
float module;
|
||||
float sideX;
|
||||
|
49
games/pang.c
49
games/pang.c
@ -32,7 +32,6 @@
|
||||
//----------------------------------------------------------------------------------
|
||||
// Types and Structures Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
typedef struct Player {
|
||||
Vector2 position;
|
||||
Vector2 speed;
|
||||
@ -66,33 +65,33 @@ typedef struct Points {
|
||||
//------------------------------------------------------------------------------------
|
||||
// Global Variables Declaration
|
||||
//------------------------------------------------------------------------------------
|
||||
static int screenWidth = 800;
|
||||
static int screenHeight = 450;
|
||||
static const int screenWidth = 800;
|
||||
static const int screenHeight = 450;
|
||||
|
||||
static int framesCounter;
|
||||
static bool gameOver;
|
||||
static bool pause;
|
||||
static int score;
|
||||
static int framesCounter = 0;
|
||||
static bool gameOver = false;
|
||||
static bool pause = false;
|
||||
static int score = 0;
|
||||
|
||||
static Player player;
|
||||
static Shoot shoot[PLAYER_MAX_SHOOTS];
|
||||
static Ball bigBalls[MAX_BIG_BALLS];
|
||||
static Ball mediumBalls[MAX_BIG_BALLS*2];
|
||||
static Ball smallBalls[MAX_BIG_BALLS*4];
|
||||
static Points points[5];
|
||||
static Player player = { 0 };
|
||||
static Shoot shoot[PLAYER_MAX_SHOOTS] = { 0 };
|
||||
static Ball bigBalls[MAX_BIG_BALLS] = { 0 };
|
||||
static Ball mediumBalls[MAX_BIG_BALLS*2] = { 0 };
|
||||
static Ball smallBalls[MAX_BIG_BALLS*4] = { 0 };
|
||||
static Points points[5] = { 0 };
|
||||
|
||||
// NOTE: Defined triangle is isosceles with common angles of 70 degrees.
|
||||
static float shipHeight;
|
||||
static float gravity;
|
||||
static float shipHeight = 0.0f;
|
||||
static float gravity = 0.0f;
|
||||
|
||||
static int countmediumBallss;
|
||||
static int countsmallBallss;
|
||||
static int meteorsDestroyed;
|
||||
static Vector2 linePosition;
|
||||
static int countmediumBallss = 0;
|
||||
static int countsmallBallss = 0;
|
||||
static int meteorsDestroyed = 0;
|
||||
static Vector2 linePosition = { 0 };
|
||||
|
||||
static bool victory;
|
||||
static bool lose;
|
||||
static bool awake;
|
||||
static bool victory = false;
|
||||
static bool lose = false;
|
||||
static bool awake = false;
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Module Functions Declaration (local)
|
||||
@ -117,7 +116,6 @@ int main(void)
|
||||
#if defined(PLATFORM_WEB)
|
||||
emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
|
||||
#else
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
@ -130,7 +128,6 @@ int main(void)
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
#endif
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadGame(); // Unload loaded data (textures, sounds, models...)
|
||||
@ -593,12 +590,12 @@ void DrawGame(void)
|
||||
{
|
||||
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)
|
||||
DrawText(FormatText("SCORE: %i", score), 10, 10, 20, LIGHTGRAY);
|
||||
DrawText(TextFormat("SCORE: %i", score), 10, 10, 20, LIGHTGRAY);
|
||||
|
||||
if (victory)
|
||||
{
|
||||
|
@ -43,19 +43,19 @@ typedef struct Food {
|
||||
//------------------------------------------------------------------------------------
|
||||
// Global Variables Declaration
|
||||
//------------------------------------------------------------------------------------
|
||||
static int screenWidth = 800;
|
||||
static int screenHeight = 450;
|
||||
static const int screenWidth = 800;
|
||||
static const int screenHeight = 450;
|
||||
|
||||
static int framesCounter;
|
||||
static bool gameOver;
|
||||
static bool pause;
|
||||
static int framesCounter = 0;
|
||||
static bool gameOver = false;
|
||||
static bool pause = false;
|
||||
|
||||
static Food fruit;
|
||||
static Snake snake[SNAKE_LENGTH];
|
||||
static Vector2 snakePosition[SNAKE_LENGTH];
|
||||
static bool allowMove;
|
||||
static Vector2 offset;
|
||||
static int counterTail;
|
||||
static Food fruit = { 0 };
|
||||
static Snake snake[SNAKE_LENGTH] = { 0 };
|
||||
static Vector2 snakePosition[SNAKE_LENGTH] = { 0 };
|
||||
static bool allowMove = false;
|
||||
static Vector2 offset = { 0 };
|
||||
static int counterTail = 0;
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Module Functions Declaration (local)
|
||||
@ -80,7 +80,6 @@ int main(void)
|
||||
#if defined(PLATFORM_WEB)
|
||||
emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
|
||||
#else
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
@ -93,7 +92,6 @@ int main(void)
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
#endif
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadGame(); // Unload loaded data (textures, sounds, models...)
|
||||
@ -150,7 +148,7 @@ void UpdateGame(void)
|
||||
|
||||
if (!pause)
|
||||
{
|
||||
// control
|
||||
// Player control
|
||||
if (IsKeyPressed(KEY_RIGHT) && (snake[0].speed.x == 0) && allowMove)
|
||||
{
|
||||
snake[0].speed = (Vector2){ SQUARE_SIZE, 0 };
|
||||
@ -172,7 +170,7 @@ void UpdateGame(void)
|
||||
allowMove = false;
|
||||
}
|
||||
|
||||
// movement
|
||||
// Snake movement
|
||||
for (int i = 0; i < counterTail; i++) snakePosition[i] = snake[i].position;
|
||||
|
||||
if ((framesCounter%5) == 0)
|
||||
@ -189,7 +187,7 @@ void UpdateGame(void)
|
||||
}
|
||||
}
|
||||
|
||||
// wall behaviour
|
||||
// Wall behaviour
|
||||
if (((snake[0].position.x) > (screenWidth - offset.x)) ||
|
||||
((snake[0].position.y) > (screenHeight - offset.y)) ||
|
||||
(snake[0].position.x < 0) || (snake[0].position.y < 0))
|
||||
@ -197,13 +195,13 @@ void UpdateGame(void)
|
||||
gameOver = true;
|
||||
}
|
||||
|
||||
// collision with yourself
|
||||
// Collision with yourself
|
||||
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;
|
||||
}
|
||||
|
||||
// fruit.position calculation
|
||||
// Fruit position calculation
|
||||
if (!fruit.active)
|
||||
{
|
||||
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) &&
|
||||
(snake[0].position.y < (fruit.position.y + fruit.size.y) && (snake[0].position.y + snake[0].size.y) > fruit.position.y))
|
||||
{
|
||||
|
@ -54,25 +54,25 @@ typedef struct Shoot{
|
||||
//------------------------------------------------------------------------------------
|
||||
// Global Variables Declaration
|
||||
//------------------------------------------------------------------------------------
|
||||
static int screenWidth = 800;
|
||||
static int screenHeight = 450;
|
||||
static const int screenWidth = 800;
|
||||
static const int screenHeight = 450;
|
||||
|
||||
static bool gameOver;
|
||||
static bool pause;
|
||||
static int score;
|
||||
static bool victory;
|
||||
static bool gameOver = false;
|
||||
static bool pause = false;
|
||||
static int score = 0;
|
||||
static bool victory = false;
|
||||
|
||||
static Player player;
|
||||
static Enemy enemy[NUM_MAX_ENEMIES];
|
||||
static Shoot shoot[NUM_SHOOTS];
|
||||
static EnemyWave wave;
|
||||
static Player player = { 0 };
|
||||
static Enemy enemy[NUM_MAX_ENEMIES] = { 0 };
|
||||
static Shoot shoot[NUM_SHOOTS] = { 0 };
|
||||
static EnemyWave wave = { 0 };
|
||||
|
||||
static int shootRate;
|
||||
static float alpha;
|
||||
static int shootRate = 0;
|
||||
static float alpha = 0.0f;
|
||||
|
||||
static int activeEnemies;
|
||||
static int enemiesKill;
|
||||
static bool smooth;
|
||||
static int activeEnemies = 0;
|
||||
static int enemiesKill = 0;
|
||||
static bool smooth = false;
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Module Functions Declaration (local)
|
||||
@ -97,7 +97,6 @@ int main(void)
|
||||
#if defined(PLATFORM_WEB)
|
||||
emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
|
||||
#else
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
@ -110,7 +109,6 @@ int main(void)
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
#endif
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
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 + player.rec.height >= screenHeight) player.rec.y = screenHeight - player.rec.height;
|
||||
|
||||
//Shoot initialization
|
||||
// Shoot initialization
|
||||
if (IsKeyDown(KEY_SPACE))
|
||||
{
|
||||
shootRate += 5;
|
||||
@ -375,7 +373,7 @@ void DrawGame(void)
|
||||
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);
|
||||
|
||||
|
148
games/tetris.c
148
games/tetris.c
@ -44,8 +44,8 @@ typedef enum GridSquare { EMPTY, MOVING, FULL, BLOCK, FADING } GridSquare;
|
||||
//------------------------------------------------------------------------------------
|
||||
// Global Variables Declaration
|
||||
//------------------------------------------------------------------------------------
|
||||
static int screenWidth = 800;
|
||||
static int screenHeight = 450;
|
||||
static const int screenWidth = 800;
|
||||
static const int screenHeight = 450;
|
||||
|
||||
static bool gameOver = false;
|
||||
static bool pause = false;
|
||||
@ -99,7 +99,7 @@ static void ResolveFallingMovement();
|
||||
static bool ResolveLateralMovement();
|
||||
static bool ResolveTurnMovement();
|
||||
static void CheckDetection();
|
||||
static void CheckCompletition();
|
||||
static void CheckCompletion();
|
||||
static void DeleteCompleteLines();
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
@ -116,7 +116,6 @@ int main(void)
|
||||
#if defined(PLATFORM_WEB)
|
||||
emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
|
||||
#else
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
@ -129,7 +128,6 @@ int main(void)
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
#endif
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadGame(); // Unload loaded data (textures, sounds, models...)
|
||||
@ -239,7 +237,7 @@ void UpdateGame(void)
|
||||
ResolveFallingMovement(&detection, &pieceActive);
|
||||
|
||||
// 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;
|
||||
}
|
||||
@ -387,7 +385,7 @@ void DrawGame(void)
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@ -450,8 +448,7 @@ static bool Createpiece()
|
||||
|
||||
static void GetRandompiece()
|
||||
{
|
||||
srand(time(NULL));
|
||||
int random = rand() % 7;
|
||||
int random = GetRandomValue(0, 6);
|
||||
|
||||
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 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 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 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 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 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 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 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
|
||||
else // We move down the piece
|
||||
{
|
||||
for (int j = GRID_VERTICAL_SIZE - 2; j >= 0; j--)
|
||||
{
|
||||
@ -505,6 +501,7 @@ static void ResolveFallingMovement(bool *detection, bool *pieceActive)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
piecePositionY++;
|
||||
}
|
||||
}
|
||||
@ -513,8 +510,8 @@ static bool ResolveLateralMovement()
|
||||
{
|
||||
bool collision = false;
|
||||
|
||||
// Move left
|
||||
if (IsKeyDown(KEY_LEFT))
|
||||
// Piece movement
|
||||
if (IsKeyDown(KEY_LEFT)) // Move left
|
||||
{
|
||||
// Check if is possible to move to left
|
||||
for (int j = GRID_VERTICAL_SIZE - 2; j >= 0; j--)
|
||||
@ -528,6 +525,7 @@ static bool ResolveLateralMovement()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If able, move left
|
||||
if (!collision)
|
||||
{
|
||||
@ -547,9 +545,7 @@ static bool ResolveLateralMovement()
|
||||
piecePositionX--;
|
||||
}
|
||||
}
|
||||
|
||||
// Move right
|
||||
else if (IsKeyDown(KEY_RIGHT))
|
||||
else if (IsKeyDown(KEY_RIGHT)) // Move right
|
||||
{
|
||||
// Check if is possible to move to right
|
||||
for (int j = GRID_VERTICAL_SIZE - 2; j >= 0; j--)
|
||||
@ -567,6 +563,7 @@ static bool ResolveLateralMovement()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If able move right
|
||||
if (!collision)
|
||||
{
|
||||
@ -595,112 +592,73 @@ static bool ResolveTurnMovement()
|
||||
// Input for turning the piece
|
||||
if (IsKeyDown(KEY_UP))
|
||||
{
|
||||
int aux;
|
||||
int aux = 0;
|
||||
bool checker = false;
|
||||
|
||||
// Check all turning possibilities
|
||||
if ((grid[piecePositionX + 3][piecePositionY] == MOVING) &&
|
||||
(grid[piecePositionX][piecePositionY] != EMPTY) &&
|
||||
(grid[piecePositionX][piecePositionY] != MOVING))
|
||||
{
|
||||
checker = true;
|
||||
}
|
||||
(grid[piecePositionX][piecePositionY] != MOVING)) checker = true;
|
||||
|
||||
if ((grid[piecePositionX + 3][piecePositionY + 3] == MOVING) &&
|
||||
(grid[piecePositionX + 3][piecePositionY] != EMPTY) &&
|
||||
(grid[piecePositionX + 3][piecePositionY] != MOVING))
|
||||
{
|
||||
checker = true;
|
||||
}
|
||||
(grid[piecePositionX + 3][piecePositionY] != MOVING)) checker = true;
|
||||
|
||||
if ((grid[piecePositionX][piecePositionY + 3] == MOVING) &&
|
||||
(grid[piecePositionX + 3][piecePositionY + 3] != EMPTY) &&
|
||||
(grid[piecePositionX + 3][piecePositionY + 3] != MOVING))
|
||||
{
|
||||
checker = true;
|
||||
}
|
||||
(grid[piecePositionX + 3][piecePositionY + 3] != MOVING)) checker = true;
|
||||
|
||||
if ((grid[piecePositionX][piecePositionY] == MOVING) &&
|
||||
(grid[piecePositionX][piecePositionY + 3] != EMPTY) &&
|
||||
(grid[piecePositionX][piecePositionY + 3] != MOVING))
|
||||
{
|
||||
checker = true;
|
||||
}
|
||||
|
||||
(grid[piecePositionX][piecePositionY + 3] != MOVING)) checker = true;
|
||||
|
||||
if ((grid[piecePositionX + 1][piecePositionY] == MOVING) &&
|
||||
(grid[piecePositionX][piecePositionY + 2] != EMPTY) &&
|
||||
(grid[piecePositionX][piecePositionY + 2] != MOVING))
|
||||
{
|
||||
checker = true;
|
||||
}
|
||||
(grid[piecePositionX][piecePositionY + 2] != MOVING)) checker = true;
|
||||
|
||||
if ((grid[piecePositionX + 3][piecePositionY + 1] == MOVING) &&
|
||||
(grid[piecePositionX + 1][piecePositionY] != EMPTY) &&
|
||||
(grid[piecePositionX + 1][piecePositionY] != MOVING))
|
||||
{
|
||||
checker = true;
|
||||
}
|
||||
(grid[piecePositionX + 1][piecePositionY] != MOVING)) checker = true;
|
||||
|
||||
if ((grid[piecePositionX + 2][piecePositionY + 3] == MOVING) &&
|
||||
(grid[piecePositionX + 3][piecePositionY + 1] != EMPTY) &&
|
||||
(grid[piecePositionX + 3][piecePositionY + 1] != MOVING))
|
||||
{
|
||||
checker = true;
|
||||
}
|
||||
(grid[piecePositionX + 3][piecePositionY + 1] != MOVING)) checker = true;
|
||||
|
||||
if ((grid[piecePositionX][piecePositionY + 2] == MOVING) &&
|
||||
(grid[piecePositionX + 2][piecePositionY + 3] != EMPTY) &&
|
||||
(grid[piecePositionX + 2][piecePositionY + 3] != MOVING))
|
||||
{
|
||||
checker = true;
|
||||
}
|
||||
|
||||
(grid[piecePositionX + 2][piecePositionY + 3] != MOVING)) checker = true;
|
||||
|
||||
if ((grid[piecePositionX + 2][piecePositionY] == MOVING) &&
|
||||
(grid[piecePositionX][piecePositionY + 1] != EMPTY) &&
|
||||
(grid[piecePositionX][piecePositionY + 1] != MOVING))
|
||||
{
|
||||
checker = true;
|
||||
}
|
||||
(grid[piecePositionX][piecePositionY + 1] != MOVING)) checker = true;
|
||||
|
||||
if ((grid[piecePositionX + 3][piecePositionY + 2] == MOVING) &&
|
||||
(grid[piecePositionX + 2][piecePositionY] != EMPTY) &&
|
||||
(grid[piecePositionX + 2][piecePositionY] != MOVING))
|
||||
{
|
||||
checker = true;
|
||||
}
|
||||
(grid[piecePositionX + 2][piecePositionY] != MOVING)) checker = true;
|
||||
|
||||
if ((grid[piecePositionX + 1][piecePositionY + 3] == MOVING) &&
|
||||
(grid[piecePositionX + 3][piecePositionY + 2] != EMPTY) &&
|
||||
(grid[piecePositionX + 3][piecePositionY + 2] != MOVING))
|
||||
{
|
||||
checker = true;
|
||||
}
|
||||
(grid[piecePositionX + 3][piecePositionY + 2] != MOVING)) checker = true;
|
||||
|
||||
if ((grid[piecePositionX][piecePositionY + 1] == MOVING) &&
|
||||
(grid[piecePositionX + 1][piecePositionY + 3] != EMPTY) &&
|
||||
(grid[piecePositionX + 1][piecePositionY + 3] != MOVING))
|
||||
{
|
||||
checker = true;
|
||||
}
|
||||
(grid[piecePositionX + 1][piecePositionY + 3] != MOVING)) checker = true;
|
||||
|
||||
if ((grid[piecePositionX + 1][piecePositionY + 1] == MOVING) &&
|
||||
(grid[piecePositionX + 1][piecePositionY + 2] != EMPTY) &&
|
||||
(grid[piecePositionX + 1][piecePositionY + 2] != MOVING))
|
||||
{
|
||||
checker = true;
|
||||
}
|
||||
(grid[piecePositionX + 1][piecePositionY + 2] != MOVING)) checker = true;
|
||||
|
||||
if ((grid[piecePositionX + 2][piecePositionY + 1] == MOVING) &&
|
||||
(grid[piecePositionX + 1][piecePositionY + 1] != EMPTY) &&
|
||||
(grid[piecePositionX + 1][piecePositionY + 1] != MOVING))
|
||||
{
|
||||
checker = true;
|
||||
}
|
||||
(grid[piecePositionX + 1][piecePositionY + 1] != MOVING)) checker = true;
|
||||
|
||||
if ((grid[piecePositionX + 2][piecePositionY + 2] == MOVING) &&
|
||||
(grid[piecePositionX + 2][piecePositionY + 1] != EMPTY) &&
|
||||
(grid[piecePositionX + 2][piecePositionY + 1] != MOVING))
|
||||
{
|
||||
checker = true;
|
||||
}
|
||||
(grid[piecePositionX + 2][piecePositionY + 1] != MOVING)) checker = true;
|
||||
|
||||
if ((grid[piecePositionX + 1][piecePositionY + 2] == MOVING) &&
|
||||
(grid[piecePositionX + 2][piecePositionY + 2] != EMPTY) &&
|
||||
(grid[piecePositionX + 2][piecePositionY + 2] != MOVING))
|
||||
{
|
||||
checker = true;
|
||||
}
|
||||
(grid[piecePositionX + 2][piecePositionY + 2] != MOVING)) checker = true;
|
||||
|
||||
if (!checker)
|
||||
{
|
||||
@ -750,6 +708,7 @@ static bool ResolveTurnMovement()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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--)
|
||||
{
|
||||
@ -801,7 +760,7 @@ static void CheckCompletition(bool *lineToDelete)
|
||||
|
||||
static void DeleteCompleteLines()
|
||||
{
|
||||
// erase the completed line
|
||||
// Erase the completed line
|
||||
for (int j = GRID_VERTICAL_SIZE - 2; j >= 0; j--)
|
||||
{
|
||||
while (grid[1][j] == FADING)
|
||||
@ -810,6 +769,7 @@ static void DeleteCompleteLines()
|
||||
{
|
||||
grid[i][j] = EMPTY;
|
||||
}
|
||||
|
||||
for (int j2 = j-1; j2 >= 0; j2--)
|
||||
{
|
||||
for (int i2 = 1; i2 < GRID_HORIZONTAL_SIZE - 1; i2++)
|
||||
|
Loading…
Reference in New Issue
Block a user