Skip to content

Commit

Permalink
Added splash screen will customize more later, added sound/vibro, add…
Browse files Browse the repository at this point in the history
…ed logging, still crashes after team selection and not sure why
  • Loading branch information
RocketGod-git committed Aug 23, 2024
1 parent e1d90b0 commit afde2ee
Show file tree
Hide file tree
Showing 7 changed files with 768 additions and 180 deletions.
14 changes: 13 additions & 1 deletion game_state.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#include "game_state.h"
#include <furi.h>
#include <stdlib.h>
Expand All @@ -15,6 +14,7 @@ struct GameState {
GameState* game_state_alloc() {
GameState* state = malloc(sizeof(GameState));
if(!state) {
FURI_LOG_E("GameState", "Failed to allocate GameState");
return NULL;
}
state->team = TeamRed;
Expand All @@ -23,6 +23,7 @@ GameState* game_state_alloc() {
state->ammo = INITIAL_AMMO;
state->game_time = 0;
state->game_over = false;
FURI_LOG_I("GameState", "GameState allocated successfully");
return state;
}

Expand All @@ -33,11 +34,13 @@ void game_state_reset(GameState* state) {
state->ammo = INITIAL_AMMO;
state->game_time = 0;
state->game_over = false;
FURI_LOG_I("GameState", "GameState reset");
}

void game_state_set_team(GameState* state, LaserTagTeam team) {
furi_assert(state);
state->team = team;
FURI_LOG_I("GameState", "Team set to %s", (team == TeamRed) ? "Red" : "Blue");
}

LaserTagTeam game_state_get_team(GameState* state) {
Expand All @@ -52,12 +55,15 @@ void game_state_decrease_health(GameState* state, uint8_t amount) {
} else {
state->health = 0;
state->game_over = true;
FURI_LOG_W("GameState", "Health depleted, game over");
}
FURI_LOG_I("GameState", "Health decreased to %d", state->health);
}

void game_state_increase_health(GameState* state, uint8_t amount) {
furi_assert(state);
state->health = (state->health + amount > MAX_HEALTH) ? MAX_HEALTH : state->health + amount;
FURI_LOG_I("GameState", "Health increased to %d", state->health);
}

uint8_t game_state_get_health(GameState* state) {
Expand All @@ -68,6 +74,7 @@ uint8_t game_state_get_health(GameState* state) {
void game_state_increase_score(GameState* state, uint16_t points) {
furi_assert(state);
state->score += points;
FURI_LOG_I("GameState", "Score increased to %d", state->score);
}

uint16_t game_state_get_score(GameState* state) {
Expand All @@ -81,12 +88,15 @@ void game_state_decrease_ammo(GameState* state, uint16_t amount) {
state->ammo -= amount;
} else {
state->ammo = 0;
FURI_LOG_W("GameState", "Ammo depleted");
}
FURI_LOG_I("GameState", "Ammo decreased to %d", state->ammo);
}

void game_state_increase_ammo(GameState* state, uint16_t amount) {
furi_assert(state);
state->ammo += amount;
FURI_LOG_I("GameState", "Ammo increased to %d", state->ammo);
}

uint16_t game_state_get_ammo(GameState* state) {
Expand All @@ -97,6 +107,7 @@ uint16_t game_state_get_ammo(GameState* state) {
void game_state_update_time(GameState* state, uint32_t delta_time) {
furi_assert(state);
state->game_time += delta_time;
FURI_LOG_I("GameState", "Game time updated to %ld seconds", state->game_time);
}

uint32_t game_state_get_time(GameState* state) {
Expand All @@ -112,4 +123,5 @@ bool game_state_is_game_over(GameState* state) {
void game_state_set_game_over(GameState* state, bool game_over) {
furi_assert(state);
state->game_over = game_over;
FURI_LOG_I("GameState", "Game over status set to %s", game_over ? "true" : "false");
}
2 changes: 1 addition & 1 deletion game_state.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#pragma once

#include <stdint.h>
Expand All @@ -10,6 +9,7 @@ typedef enum {
} LaserTagTeam;

typedef enum {
LaserTagStateSplashScreen,
LaserTagStateTeamSelect,
LaserTagStateGame,
} LaserTagState;
Expand Down
Loading

0 comments on commit afde2ee

Please sign in to comment.