diff options
author | NielsCoding <48092678+heavydemon21@users.noreply.github.com> | 2023-03-30 13:02:36 +0200 |
---|---|---|
committer | NielsCoding <48092678+heavydemon21@users.noreply.github.com> | 2023-03-30 13:02:36 +0200 |
commit | 552dcc17db2b98287ba1b480c2e70759cd94d81f (patch) | |
tree | 7f7bbd7a8b3964bbebc2878d33be0ed8a9382e3f /src/GameLoop | |
parent | 7f51cd925883bbf958baa289d4d19231667c9eba (diff) |
gameloop/bullet/levels
gameloop moet nog wat gefixt worden. shop moet nog wat art en functie krijgen zefde voor gameover/highscore
bullet moet meerdere entityten kunnen doen nu nog alleen gemaakt voor 1.
levels moet alleen nog backwords kunnen
Diffstat (limited to 'src/GameLoop')
-rw-r--r-- | src/GameLoop/game_over.c | 28 | ||||
-rw-r--r-- | src/GameLoop/game_over.h | 18 | ||||
-rw-r--r-- | src/GameLoop/gameplay.c | 44 | ||||
-rw-r--r-- | src/GameLoop/gameplay.h | 17 | ||||
-rw-r--r-- | src/GameLoop/shop.c | 28 | ||||
-rw-r--r-- | src/GameLoop/shop.h | 12 |
6 files changed, 128 insertions, 19 deletions
diff --git a/src/GameLoop/game_over.c b/src/GameLoop/game_over.c new file mode 100644 index 0000000..09e6858 --- /dev/null +++ b/src/GameLoop/game_over.c @@ -0,0 +1,28 @@ +#include "game_over.h" + + +void hh_game_over(hh_e_GameState* 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_GameOver; + break; + default: + hh_e_states_game_over = hh_e_game_over_SHOW; + break; + } +} diff --git a/src/GameLoop/game_over.h b/src/GameLoop/game_over.h new file mode 100644 index 0000000..0d40b6c --- /dev/null +++ b/src/GameLoop/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_GameState*); diff --git a/src/GameLoop/gameplay.c b/src/GameLoop/gameplay.c new file mode 100644 index 0000000..72297f5 --- /dev/null +++ b/src/GameLoop/gameplay.c @@ -0,0 +1,44 @@ +#include "gameplay.h" + + + +void hh_gameplay(hh_g_all_levels game, hh_e_GameState* 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.currentLevel]); + 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.currentLevel].hh_level_completed){ + gameplay = hh_e_level_complete; + } + break; + case hh_e_level_complete: + if(game.currentLevel < 3){ + game.currentLevel++; + 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_GameOver; + break; + default: + break; + } + +} +void hh_reset_levels(){} diff --git a/src/GameLoop/gameplay.h b/src/GameLoop/gameplay.h new file mode 100644 index 0000000..6e8c1ec --- /dev/null +++ b/src/GameLoop/gameplay.h @@ -0,0 +1,17 @@ +#pragma once +#include "engine/draw_screen.h" +#include "engine/player_controller.h" +#include "engine/sprite_controller.h" +#include "GameLoop/startingScreen.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_GameState*); + diff --git a/src/GameLoop/shop.c b/src/GameLoop/shop.c index eb6bed5..8e6dc71 100644 --- a/src/GameLoop/shop.c +++ b/src/GameLoop/shop.c @@ -1,30 +1,30 @@ #include "shop.h" -bool hh_show_Shop(){ - static hh_e_ShopStates hh_e_Shop = hh_e_STATE_SHOW; +void hh_Shop(hh_e_GameState* hh_game_state){ + static hh_e_ShopStates hh_e_Shop = hh_e_shop_SHOW; switch (hh_e_Shop) { - case hh_e_STATE_SHOW: - //hh_clear_screen(); - + 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_STATE_Input; - return false; + hh_e_Shop = hh_e_shop_Input; break; - case hh_e_STATE_Input: + 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_STATE_END; + hh_e_Shop = hh_e_shop_END; } break; - case hh_e_STATE_END: - hh_e_Shop = hh_e_STATE_SHOW; - return true; + 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_STATE_SHOW; + hh_e_Shop = hh_e_shop_SHOW; break; } - return false; } diff --git a/src/GameLoop/shop.h b/src/GameLoop/shop.h index 4014f58..1efc057 100644 --- a/src/GameLoop/shop.h +++ b/src/GameLoop/shop.h @@ -1,16 +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_STATE_SHOW, - hh_e_STATE_Input, - hh_e_STATE_END + hh_e_shop_SHOW, + hh_e_shop_Input, + hh_e_shop_END, } hh_e_ShopStates; -bool hh_show_Shop(); +void hh_Shop(hh_e_GameState*); |