Skip to content

Commit afde2ee

Browse files
committed
Added splash screen will customize more later, added sound/vibro, added logging, still crashes after team selection and not sure why
1 parent e1d90b0 commit afde2ee

File tree

7 files changed

+768
-180
lines changed

7 files changed

+768
-180
lines changed

game_state.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#include "game_state.h"
32
#include <furi.h>
43
#include <stdlib.h>
@@ -15,6 +14,7 @@ struct GameState {
1514
GameState* game_state_alloc() {
1615
GameState* state = malloc(sizeof(GameState));
1716
if(!state) {
17+
FURI_LOG_E("GameState", "Failed to allocate GameState");
1818
return NULL;
1919
}
2020
state->team = TeamRed;
@@ -23,6 +23,7 @@ GameState* game_state_alloc() {
2323
state->ammo = INITIAL_AMMO;
2424
state->game_time = 0;
2525
state->game_over = false;
26+
FURI_LOG_I("GameState", "GameState allocated successfully");
2627
return state;
2728
}
2829

@@ -33,11 +34,13 @@ void game_state_reset(GameState* state) {
3334
state->ammo = INITIAL_AMMO;
3435
state->game_time = 0;
3536
state->game_over = false;
37+
FURI_LOG_I("GameState", "GameState reset");
3638
}
3739

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

4346
LaserTagTeam game_state_get_team(GameState* state) {
@@ -52,12 +55,15 @@ void game_state_decrease_health(GameState* state, uint8_t amount) {
5255
} else {
5356
state->health = 0;
5457
state->game_over = true;
58+
FURI_LOG_W("GameState", "Health depleted, game over");
5559
}
60+
FURI_LOG_I("GameState", "Health decreased to %d", state->health);
5661
}
5762

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

6369
uint8_t game_state_get_health(GameState* state) {
@@ -68,6 +74,7 @@ uint8_t game_state_get_health(GameState* state) {
6874
void game_state_increase_score(GameState* state, uint16_t points) {
6975
furi_assert(state);
7076
state->score += points;
77+
FURI_LOG_I("GameState", "Score increased to %d", state->score);
7178
}
7279

7380
uint16_t game_state_get_score(GameState* state) {
@@ -81,12 +88,15 @@ void game_state_decrease_ammo(GameState* state, uint16_t amount) {
8188
state->ammo -= amount;
8289
} else {
8390
state->ammo = 0;
91+
FURI_LOG_W("GameState", "Ammo depleted");
8492
}
93+
FURI_LOG_I("GameState", "Ammo decreased to %d", state->ammo);
8594
}
8695

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

92102
uint16_t game_state_get_ammo(GameState* state) {
@@ -97,6 +107,7 @@ uint16_t game_state_get_ammo(GameState* state) {
97107
void game_state_update_time(GameState* state, uint32_t delta_time) {
98108
furi_assert(state);
99109
state->game_time += delta_time;
110+
FURI_LOG_I("GameState", "Game time updated to %ld seconds", state->game_time);
100111
}
101112

102113
uint32_t game_state_get_time(GameState* state) {
@@ -112,4 +123,5 @@ bool game_state_is_game_over(GameState* state) {
112123
void game_state_set_game_over(GameState* state, bool game_over) {
113124
furi_assert(state);
114125
state->game_over = game_over;
126+
FURI_LOG_I("GameState", "Game over status set to %s", game_over ? "true" : "false");
115127
}

game_state.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#pragma once
32

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

1211
typedef enum {
12+
LaserTagStateSplashScreen,
1313
LaserTagStateTeamSelect,
1414
LaserTagStateGame,
1515
} LaserTagState;

0 commit comments

Comments
 (0)