summaryrefslogtreecommitdiffhomepage
path: root/games/samples/space_invaders.c
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2016-02-07 11:23:12 +0100
committerraysan5 <[email protected]>2016-02-07 11:23:12 +0100
commit4ad375a3783472b8629387d45fb90619115c973a (patch)
tree14d2c9c4a70e494d6d02d96c87369c21a8e3986f /games/samples/space_invaders.c
parent4a3509f06d60e2761aa048378fe979e11a5a1667 (diff)
downloadraylib-4ad375a3783472b8629387d45fb90619115c973a.tar.gz
raylib-4ad375a3783472b8629387d45fb90619115c973a.zip
Code review
Most of this code was developed by students, it requires some additional review to be used for teaching.
Diffstat (limited to 'games/samples/space_invaders.c')
-rw-r--r--games/samples/space_invaders.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/games/samples/space_invaders.c b/games/samples/space_invaders.c
index 9f380628..c2dd0c61 100644
--- a/games/samples/space_invaders.c
+++ b/games/samples/space_invaders.c
@@ -29,7 +29,7 @@
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
-typedef enum { FIRST = 0, SECOND, THIRD } enemyWave;
+typedef enum { FIRST = 0, SECOND, THIRD } EnemyWave;
typedef struct Player{
Rectangle rec;
@@ -66,7 +66,7 @@ static bool victory;
static Player player;
static Enemy enemy[NUM_MAX_ENEMIES];
static Shoot shoot[NUM_SHOOTS];
-static enemyWave wave;
+static EnemyWave wave;
static int shootRate;
static float alpha;
@@ -149,8 +149,8 @@ void InitGame(void)
// Initialize player
player.rec.x = 20;
player.rec.y = 50;
- player.rec.width = 10;
- player.rec.height = 10;
+ player.rec.width = 20;
+ player.rec.height = 20;
player.speed.x = 5;
player.speed.y = 5;
player.color = BLACK;
@@ -165,7 +165,7 @@ void InitGame(void)
enemy[i].speed.x = 5;
enemy[i].speed.y = 5;
enemy[i].active = true;
- enemy[i].color = DARKGRAY;
+ enemy[i].color = GRAY;
}
// Initialize shoots
@@ -178,7 +178,7 @@ void InitGame(void)
shoot[i].speed.x = 7;
shoot[i].speed.y = 0;
shoot[i].active = false;
- shoot[i].color = WHITE;
+ shoot[i].color = MAROON;
}
}
@@ -325,10 +325,9 @@ void UpdateGame(void)
{
if (enemy[j].active)
{
- if (CheckCollisionRecs(shoot[i].rec, enemy[j].rec))
+ if (CheckCollisionRecs(shoot[i].rec, enemy[j].rec))
{
shoot[i].active = false;
- enemy[j].active = false;
enemy[j].rec.x = GetRandomValue(screenWidth, screenWidth + 1000);
enemy[j].rec.y = GetRandomValue(0, screenHeight - enemy[j].rec.height);
shootRate = 0;
@@ -362,7 +361,7 @@ void DrawGame(void)
{
BeginDrawing();
- ClearBackground(LIGHTGRAY);
+ ClearBackground(RAYWHITE);
if (!gameOver)
{
@@ -382,7 +381,7 @@ void DrawGame(void)
if (shoot[i].active) DrawRectangleRec(shoot[i].rec, shoot[i].color);
}
- DrawText(FormatText("%04i", score), 20, 20, 40, DARKGRAY);
+ DrawText(FormatText("%04i", score), 20, 20, 40, GRAY);
if (victory) DrawText("YOU WIN", screenWidth/2 - MeasureText("YOU WIN", 40)/2, screenHeight/2 - 40, 40, BLACK);