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 --- game.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) (limited to 'game.c') 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) { -- cgit v1.2.3-54-g00ecf