aboutsummaryrefslogtreecommitdiff
path: root/src/game_loop
diff options
context:
space:
mode:
Diffstat (limited to 'src/game_loop')
-rw-r--r--src/game_loop/game_over.c28
-rw-r--r--src/game_loop/game_over.h18
-rw-r--r--src/game_loop/gameplay.c47
-rw-r--r--src/game_loop/gameplay.h17
-rw-r--r--src/game_loop/shop.c30
-rw-r--r--src/game_loop/shop.h18
-rw-r--r--src/game_loop/starting_screen.c32
-rw-r--r--src/game_loop/starting_screen.h14
8 files changed, 204 insertions, 0 deletions
diff --git a/src/game_loop/game_over.c b/src/game_loop/game_over.c
new file mode 100644
index 0000000..f5b70cf
--- /dev/null
+++ b/src/game_loop/game_over.c
@@ -0,0 +1,28 @@
+#include "game_over.h"
+
+
+void hh_game_over(hh_e_game_state* hh_game_state){
+ static hh_e_game_over hh_e_states_game_over = hh_e_game_over_show;
+
+ switch (hh_e_states_game_over)
+ {
+ case hh_e_game_over_show:
+ hh_clear_screen();
+ hh_clear_sprite();
+ // todo: make function to show game over
+ hh_e_states_game_over = hh_e_game_over_input;
+ break;
+ case hh_e_game_over_input:
+ if(g_hh_controller_p1.button_primary){
+ hh_e_states_game_over = hh_e_game_over_end;
+ }
+ break;
+ case hh_e_game_over_end:
+ hh_e_states_game_over = hh_e_game_over_show;
+ *hh_game_state = hh_e_state_game_over;
+ break;
+ default:
+ hh_e_states_game_over = hh_e_game_over_show;
+ break;
+ }
+}
diff --git a/src/game_loop/game_over.h b/src/game_loop/game_over.h
new file mode 100644
index 0000000..80db667
--- /dev/null
+++ b/src/game_loop/game_over.h
@@ -0,0 +1,18 @@
+#pragma once
+
+#include "input.h"
+#include "engine/draw_screen.h"
+#include "engine/level_const.h"
+
+
+#include <stdint.h>
+#include <stdbool.h>
+
+typedef enum {
+ hh_e_game_over_show,
+ hh_e_game_over_input,
+ hh_e_game_over_end,
+} hh_e_game_over;
+
+
+void hh_game_over(hh_e_game_state*);
diff --git a/src/game_loop/gameplay.c b/src/game_loop/gameplay.c
new file mode 100644
index 0000000..295eb5d
--- /dev/null
+++ b/src/game_loop/gameplay.c
@@ -0,0 +1,47 @@
+#include "gameplay.h"
+
+// player struct
+
+
+void hh_gameplay(hh_g_all_levels game, hh_e_game_state* hh_game_state){
+ static hh_e_gameplay gameplay = hh_e_setup_screen;
+
+ switch (gameplay)
+ {
+ case hh_e_setup_screen:
+ hh_setup_screen(game.level[game.current_level]);
+ gameplay = hh_e_play_level;
+ break;
+ case hh_e_play_level:
+ // todo: here come all the different functions for the gameplay
+ hh_player_actions();
+
+
+
+
+
+ if(game.level[game.current_level].hh_level_completed){
+ gameplay = hh_e_level_complete;
+ }
+ break;
+ case hh_e_level_complete:
+ if(game.current_level < 3){
+ game.current_level++;
+ gameplay = hh_e_setup_screen;
+ }
+ else {
+ gameplay = hh_e_game_over;
+ }
+ break;
+ case hh_e_game_over:
+ // todo make reset levels
+ hh_reset_levels();
+ gameplay = hh_e_setup_screen;
+ *hh_game_state = hh_e_state_game_over;
+ break;
+ default:
+ break;
+ }
+
+}
+void hh_reset_levels(){}
diff --git a/src/game_loop/gameplay.h b/src/game_loop/gameplay.h
new file mode 100644
index 0000000..d309e78
--- /dev/null
+++ b/src/game_loop/gameplay.h
@@ -0,0 +1,17 @@
+#pragma once
+#include "engine/draw_screen.h"
+#include "engine/player_controller.h"
+#include "engine/sprite_controller.h"
+#include "game_loop/starting_screen.h"
+#include "engine/level_const.h"
+
+typedef enum {
+ hh_e_setup_screen,
+ hh_e_play_level,
+ hh_e_level_complete,
+ hh_e_game_over,
+}hh_e_gameplay;
+
+void hh_reset_levels();
+void hh_gameplay(hh_g_all_levels, hh_e_game_state*);
+
diff --git a/src/game_loop/shop.c b/src/game_loop/shop.c
new file mode 100644
index 0000000..b3d2234
--- /dev/null
+++ b/src/game_loop/shop.c
@@ -0,0 +1,30 @@
+#include "shop.h"
+
+
+void hh_shop(hh_e_game_state* hh_game_state){
+ static hh_e_shop_states hh_e_shop = hh_e_shop_show;
+
+ switch (hh_e_shop)
+ {
+ case hh_e_shop_show:
+ hh_clear_screen();
+ hh_clear_sprite();
+ // todo: make function to show shop
+ //hh_setup_shop();
+ hh_e_shop = hh_e_shop_input;
+ break;
+ case hh_e_shop_input:
+ // todo: make it so that you can choose between shop
+ if(g_hh_controller_p1.button_primary){
+ hh_e_shop = hh_e_shop_end;
+ }
+ break;
+ case hh_e_shop_end:
+ hh_e_shop = hh_e_shop_show;
+ *hh_game_state = hh_e_state_gameplay;
+ break;
+ default:
+ hh_e_shop = hh_e_shop_show;
+ break;
+ }
+}
diff --git a/src/game_loop/shop.h b/src/game_loop/shop.h
new file mode 100644
index 0000000..7d01b7e
--- /dev/null
+++ b/src/game_loop/shop.h
@@ -0,0 +1,18 @@
+#pragma once
+
+#include "input.h"
+#include "engine/draw_screen.h"
+#include "engine/level_const.h"
+
+
+#include <stdint.h>
+#include <stdbool.h>
+
+typedef enum {
+ hh_e_shop_show,
+ hh_e_shop_input,
+ hh_e_shop_end,
+} hh_e_shop_states;
+
+
+void hh_shop(hh_e_game_state*);
diff --git a/src/game_loop/starting_screen.c b/src/game_loop/starting_screen.c
new file mode 100644
index 0000000..6ab0278
--- /dev/null
+++ b/src/game_loop/starting_screen.c
@@ -0,0 +1,32 @@
+#include "starting_screen.h""
+#include "input.h"
+#include "engine/title_screen.h"
+#include "engine/draw_screen.h"
+// #include "engine/player_controller.h"
+
+bool hh_show_starting_screen(){
+ static hh_e_screen_states hh_e_starting_screen = hh_e_state_show;
+
+ switch (hh_e_starting_screen)
+ {
+ case hh_e_state_show:
+ hh_clear_screen();
+ hh_init_title_screen();
+ hh_e_starting_screen = hh_e_state_input;
+ return false;
+ break;
+ case hh_e_state_input:
+ if(g_hh_controller_p1.button_primary){
+ hh_e_starting_screen = hh_e_state_end;
+ }
+ break;
+ case hh_e_state_end:
+ hh_e_starting_screen = hh_e_state_show;
+ return true;
+ break;
+ default:
+ hh_e_starting_screen = hh_e_state_show;
+ break;
+ }
+ return false;
+}
diff --git a/src/game_loop/starting_screen.h b/src/game_loop/starting_screen.h
new file mode 100644
index 0000000..4228f38
--- /dev/null
+++ b/src/game_loop/starting_screen.h
@@ -0,0 +1,14 @@
+#pragma once
+
+#include <stdint.h>
+#include <stdbool.h>
+
+typedef enum {
+ hh_e_state_show,
+ hh_e_state_input,
+ hh_e_state_end
+} hh_e_screen_states;
+
+
+bool hh_show_starting_screen();
+