aboutsummaryrefslogtreecommitdiff
path: root/game.c
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2023-05-07 21:48:29 +1000
committerquou <quou@disroot.org>2023-05-07 21:48:29 +1000
commitc956b21cda0a5c14807c211b757d69246377da4c (patch)
treeef8c793c002000db32a5ce64682ab3f8fb6796ef /game.c
parentee2ecd8da2b66e0a819f59491ac176fd3efaa92a (diff)
Add a basic tutorial
Diffstat (limited to 'game.c')
-rw-r--r--game.c54
1 files changed, 51 insertions, 3 deletions
diff --git a/game.c b/game.c
index dfe83b9..4c6e6bf 100644
--- a/game.c
+++ b/game.c
@@ -20,6 +20,15 @@ void gameplay_new(Game* game) {
init_waver(&world->waver);
world->gmemory = gmemory_max;
+ if (game->first) {
+ game->display_wave_text = 1;
+ game->display_tutorial = 500;
+ game->first = 0;
+ } else {
+ game->display_wave_text = 0;
+ game->display_tutorial = 0;
+ }
+
set_song(song_main);
}
@@ -124,11 +133,15 @@ static void menu_deinit(Game* game) {
}
static void gameplay_init(Game* game) {
- start_wave(&game->world);
+ if (!game->display_tutorial) {
+ start_wave(&game->world);
+ }
game->want_next = 0;
game->wave_timer = 0;
- game->display_wave_text = 100;
+ if (!game->display_wave_text) {
+ game->display_wave_text = 100;
+ }
}
static void render_hud(Game* game) {
@@ -203,7 +216,9 @@ static void gameplay_update(Game* game) {
font = get_default_font();
- update_waver(&world->waver, world);
+ if (world->wave_started) {
+ update_waver(&world->waver, world);
+ }
ec = wave_enemy_count(&world->waver);
if (
@@ -251,6 +266,38 @@ static void gameplay_update(Game* game) {
game->display_wave_text--;
}
+ if (game->display_tutorial) {
+ col = make_colour(0x7f8dcf, 255);
+ rfont_text_col(
+ font,
+ renderer_w / 2 - 115,
+ renderer_h - 50,
+ "Arrows/D-pad ~ Movement",
+ col
+ );
+ rfont_text_col(
+ font,
+ renderer_w / 2 - 115,
+ renderer_h - 40,
+ " X ~ Shoot",
+ col
+ );
+ col = make_colour(0xa7a6c1, 255);
+ rfont_text_col(
+ font,
+ renderer_w / 2 - 135,
+ renderer_h - 25,
+ "Kill them; they use memory!",
+ col
+ );
+ game->display_tutorial--;
+
+ if (!game->display_tutorial) {
+ game->display_wave_text = 100;
+ start_wave(world);
+ }
+ }
+
game->wave_timer++;
render_hud(game);
@@ -502,6 +549,7 @@ void game_init(Game* game, Game_State state) {
game->state = state;
game->fns = get_state_fns(state);
game->fns->state_init(game);
+ game->first = 1;
}
void game_update(Game* game) {