diff options
author | quou <quou@disroot.org> | 2023-05-07 21:48:29 +1000 |
---|---|---|
committer | quou <quou@disroot.org> | 2023-05-07 21:48:29 +1000 |
commit | c956b21cda0a5c14807c211b757d69246377da4c (patch) | |
tree | ef8c793c002000db32a5ce64682ab3f8fb6796ef | |
parent | ee2ecd8da2b66e0a819f59491ac176fd3efaa92a (diff) |
Add a basic tutorial
-rw-r--r-- | config.h | 2 | ||||
-rw-r--r-- | game.c | 54 | ||||
-rw-r--r-- | game.h | 3 | ||||
-rw-r--r-- | wave.c | 2 |
4 files changed, 55 insertions, 6 deletions
@@ -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) @@ -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) { @@ -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; }; @@ -7,7 +7,7 @@ static const Wave waves[] = { { { { - 20, + 30, 2, { { 3, 5 }, |