aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornathansmith117 <thenathansmithsmith@gmail.com>2024-05-07 00:22:30 +0000
committernathansmith117 <thenathansmithsmith@gmail.com>2024-05-07 00:22:30 +0000
commit1aec85f04d08665ca386c58c982094acc67dd118 (patch)
tree93cd0873f7ad1ebe0db5c6334982f5a3dec3a308
parent308aefcbc437664acc4654c51a6d5dfcd346de32 (diff)
downloadPenguinYippies-1aec85f04d08665ca386c58c982094acc67dd118.tar.gz
PenguinYippies-1aec85f04d08665ca386c58c982094acc67dd118.tar.bz2
PenguinYippies-1aec85f04d08665ca386c58c982094acc67dd118.zip
More penguin shooter stuff
-rw-r--r--src/shooterScreen.c25
-rw-r--r--src/shooterScreen.h3
2 files changed, 23 insertions, 5 deletions
diff --git a/src/shooterScreen.c b/src/shooterScreen.c
index f306322..513d37e 100644
--- a/src/shooterScreen.c
+++ b/src/shooterScreen.c
@@ -17,8 +17,7 @@ void initShooterScreeen(ShooterScreen* shooterScreen, Game* game)
.direction = (Vector3){0.0, 0.0, 1.0},
.velocity = Vector3Zero(),
.cameraAngle = Vector2Zero(),
- .jumpStage = 0,
- .sleepyness = 0.0
+ .jumpStage = 0
};
resetShooterScreen(shooterScreen);
@@ -71,6 +70,7 @@ void shootBulletShooterScreen(ShooterScreen* shooterScreen, Game* game)
if (closestPenguin != NULL)
{
closestPenguin->isDead = true;
+ ++shooterScreen->killCount;
}
}
@@ -232,12 +232,26 @@ void drawCrosshairShooterScreen(int size, int thickness)
(Vector2){halfWidth, halfHeight + size}, thickness, BLACK);
}
+void drawUIShooterScreen(ShooterScreen* shooterScreen, Game* game)
+{
+ drawCrosshairShooterScreen(10, 2);
+
+ size_t bufSize = 100;
+ char buf[bufSize];
+
+ snprintf(buf, bufSize, "Time playing: %d\nPenguins still awake: %d",
+ (int)(GetTime() - shooterScreen->startTime),
+ SHOOTER_PENGUIN_COUNT - shooterScreen->killCount);
+
+ DrawText(buf, 0, 0, 20, BLACK);
+}
+
void updateShooterScreen(ShooterScreen* shooterScreen, Game* game)
{
ShooterPlayer* player = &shooterScreen->player;
ClearBackground(PINK);
- drawCrosshairShooterScreen(10, 2);
+ drawUIShooterScreen(shooterScreen, game);
updateShooterScreenControls(shooterScreen, game);
updateShooterScreenJump(shooterScreen, game);
@@ -273,7 +287,6 @@ void resetShooterScreen(ShooterScreen* shooterScreen)
player->direction = (Vector3){0.0, 0.0, 1.0};
player->cameraAngle = Vector2Zero();
player->jumpStage = 0;
- player->sleepyness = 0.0;
player->velocity = Vector3Zero();
// Penguins.
@@ -294,12 +307,16 @@ void resetShooterScreen(ShooterScreen* shooterScreen)
shooterScreen->penguins[i].lastVelocityChange = 0.0;
shooterScreen->penguins[i].isDead = false;
}
+
+ // Time.
+ shooterScreen->startTime = GetTime();
}
void enterShooterScreen(Game* game)
{
game->currentScreen = SHOOTER_SCREEN;
DisableCursor();
+ resetShooterScreen(&game->shooterScreen);
}
void leaveShooterScreen(Game* game)
{
diff --git a/src/shooterScreen.h b/src/shooterScreen.h
index 054af15..2499413 100644
--- a/src/shooterScreen.h
+++ b/src/shooterScreen.h
@@ -29,7 +29,6 @@ typedef struct ShooterPlayer {
Vector2 cameraAngle;
int jumpStage;
- float sleepyness;
} ShooterPlayer;
// Penguin to "put to sleep".
@@ -46,6 +45,8 @@ typedef struct ShooterPenguin {
typedef struct ShooterScreen {
ShooterPlayer player;
ShooterPenguin penguins[SHOOTER_PENGUIN_COUNT];
+ double startTime;
+ int killCount; // "Sleep" count.
} ShooterScreen;
void initShooterScreeen(ShooterScreen* shooterScreen, Game* game);