Skip to content

Commit

Permalink
Add Score and Dead screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Okami115 committed Nov 13, 2022
1 parent 4572794 commit 721c201
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
4 changes: 2 additions & 2 deletions SRC/CoreLoop/CoreLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace OkamiIndustries
void CoreLoop()
{

InitWindow(screenWidth, screenHeight, "Okami Industries - Mars X - V0.2");
InitWindow(screenWidth, screenHeight, "Okami Industries - Mars X - V0.3");
SetExitKey(KEY_NULL);
HideCursor();
InitExplorer();
Expand Down Expand Up @@ -86,7 +86,7 @@ namespace OkamiIndustries
}

DrawMouse();
DrawText("V0.2", 30, 30, 20, RAYWHITE);
DrawText("V0.3", 30, 30, 20, RAYWHITE);

EndDrawing();

Expand Down
3 changes: 3 additions & 0 deletions SRC/Explorer/Explorer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ namespace OkamiIndustries
Vector2 explorerOrigin = { explorer.width / 2, explorer.height / 2 };
float explorerRotation = 0;

bool isLive = true;

extern const int maxObstacles = 3;
extern Rectangle Obstacles[maxObstacles];

Expand Down Expand Up @@ -50,6 +52,7 @@ namespace OkamiIndustries
if (CheckCollision(Obstacles[i], explorer))
{
DrawRectanglePro(explorer, explorerOrigin, explorerRotation, RED);
isLive = false;
break;
}
else
Expand Down
24 changes: 19 additions & 5 deletions SRC/GameLoop/GameLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,24 @@ namespace OkamiIndustries
Vector2 Floorpos2 = { 1920,0 };

int score = 0;
extern bool isLive;

void GameLoop()
{
if (IsKeyPressed(KEY_ESCAPE))
{
SetScene = 0;
isLive = true;
}

if (isLive)
{
updateBackground();
MoveExplorer();
ShootExplorer();
MoveObstacles();
MoveUFO();
}
updateBackground();
MoveExplorer();
ShootExplorer();
MoveObstacles();
MoveUFO();
}

void DrawGame()
Expand All @@ -51,11 +57,19 @@ namespace OkamiIndustries
DrawTextureEx(Parallax3Game, Parallax3pos2, 0, 1, WHITE);
DrawTextureEx(FloorGame, Floorpos, 0, 1, WHITE);
DrawTextureEx(FloorGame, Floorpos2, 0, 1, WHITE);
DrawText(TextFormat("Score: %i", score * 100), (GetScreenWidth() / 4) * 3, 30, 20, WHITE);

DrawExplorer();
DrawBullets();
DrawObstacles();
DrawUFO();

if (!isLive)
{
DrawText(TextFormat("Score: %05i", score * 100), GetScreenWidth() / 4, GetScreenHeight() / 2, 150, RED);
DrawText("ESC to retun the menu", GetScreenWidth() / 3, GetScreenHeight() / 2 + 300, 50, WHITE);
}

}

void InitGame()
Expand Down
2 changes: 1 addition & 1 deletion SRC/Martians/UFO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace OkamiIndustries
{
if (CheckCollisionCircleRec(bullet[j].Position, static_cast <float>(bullet[j].Radius), UFOs[i]))
{
UFOs[i].x = -1000;
UFOs[i].x = -500 * maxUFOs - 1;
score++;
}
}
Expand Down
3 changes: 2 additions & 1 deletion SRC/Obstacles/Obstacles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace OkamiIndustries
float ObstaclesRotation = 0;

extern Rectangle explorer;
extern int score;

void InitObstacles()
{
Expand All @@ -32,9 +33,9 @@ namespace OkamiIndustries
if (Obstacles[i].x < 0 - Obstacles[i].width)
{
Obstacles[i].x = static_cast <float>(GetScreenWidth());
score++;
}
}

}

void DrawObstacles()
Expand Down

0 comments on commit 721c201

Please sign in to comment.