From c956b21cda0a5c14807c211b757d69246377da4c Mon Sep 17 00:00:00 2001 From: quou Date: Sun, 7 May 2023 21:48:29 +1000 Subject: Add a basic tutorial --- config.h | 2 +- game.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++--- game.h | 3 ++- wave.c | 2 +- 4 files changed, 55 insertions(+), 6 deletions(-) diff --git a/config.h b/config.h index b1c18f8..4373ec3 100644 --- a/config.h +++ b/config.h @@ -10,7 +10,7 @@ #define renderer_h 240 #define renderer_scale 2 -#define no_sound 0 +#define no_sound 1 #define asset_memory (1024 * 120) 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) { diff --git a/game.h b/game.h index b67ec3c..ce8d3a3 100644 --- a/game.h +++ b/game.h @@ -26,7 +26,8 @@ struct Game { Menu menu; World world; - int wave_timer, want_next, display_wave_text; + int first; + int wave_timer, want_next, display_wave_text, display_tutorial; int wait_timer, wait_timer2, fading, fade_timer, fade_frame; }; diff --git a/wave.c b/wave.c index f10d27f..1e12ebe 100644 --- a/wave.c +++ b/wave.c @@ -7,7 +7,7 @@ static const Wave waves[] = { { { { - 20, + 30, 2, { { 3, 5 }, -- cgit v1.2.3-54-g00ecf