From f57525cea609e0725308c8e76974470282f65872 Mon Sep 17 00:00:00 2001 From: veclavtalica Date: Wed, 26 Feb 2025 11:26:38 +0300 Subject: [PATCH] /apps/demos/scenery: remove title scene --- apps/demos/scenery/CMakeLists.txt | 1 - apps/demos/scenery/game.c | 3 +- apps/demos/scenery/scenes/ingame.c | 1 - apps/demos/scenery/scenes/title.c | 61 ------------------------------ apps/demos/scenery/scenes/title.h | 16 -------- 5 files changed, 1 insertion(+), 81 deletions(-) delete mode 100644 apps/demos/scenery/scenes/title.c delete mode 100644 apps/demos/scenery/scenes/title.h diff --git a/apps/demos/scenery/CMakeLists.txt b/apps/demos/scenery/CMakeLists.txt index c2079fa..3d8f91c 100644 --- a/apps/demos/scenery/CMakeLists.txt +++ b/apps/demos/scenery/CMakeLists.txt @@ -13,7 +13,6 @@ set(SOURCE_FILES state.h scenes/scene.c scenes/scene.h - scenes/title.c scenes/title.h scenes/ingame.c scenes/ingame.h ) diff --git a/apps/demos/scenery/game.c b/apps/demos/scenery/game.c index 1cd5709..61d0fd4 100644 --- a/apps/demos/scenery/game.c +++ b/apps/demos/scenery/game.c @@ -1,6 +1,5 @@ #include "state.h" #include "scenes/scene.h" -#include "scenes/title.h" #include "scenes/ingame.h" #include "twn_game_api.h" @@ -18,7 +17,7 @@ void game_tick(void) { State *state = ctx.udata; state->ctx = &ctx; - state->scene = title_scene(state); + state->scene = ingame_scene(state); } } diff --git a/apps/demos/scenery/scenes/ingame.c b/apps/demos/scenery/scenes/ingame.c index a6b5b70..de6dcfa 100644 --- a/apps/demos/scenery/scenes/ingame.c +++ b/apps/demos/scenery/scenes/ingame.c @@ -1,5 +1,4 @@ #include "ingame.h" -#include "title.h" #include "scene.h" #include "twn_game_api.h" diff --git a/apps/demos/scenery/scenes/title.c b/apps/demos/scenery/scenes/title.c deleted file mode 100644 index 4722c06..0000000 --- a/apps/demos/scenery/scenes/title.c +++ /dev/null @@ -1,61 +0,0 @@ -#include "title.h" -#include "ingame.h" - -#include "twn_game_api.h" - -#include -#include - - -static void title_tick(State *state) { - SceneTitle *scn = (SceneTitle *)state->scene; - (void)scn; - - input_action("ui_accept", "RETURN"); - - if (input_action_just_pressed("ui_accept")) { - switch_to(state, ingame_scene); - return; - } - - m_sprite("/assets/title.png", ((Rect) { - ((float)ctx.resolution.x / 2) - ((float)320 / 2), 64, 320, 128 })); - - /* draw the tick count as an example of dynamic text */ - size_t text_str_len = snprintf(NULL, 0, "%llu", (unsigned long long)state->ctx->frame_number) + 1; - char *text_str = malloc(text_str_len); - snprintf(text_str, text_str_len, "%llu", (unsigned long long)state->ctx->frame_number); - - const char *font = "/fonts/kenney-pixel.ttf"; - float text_h = 32; - float text_w = draw_text_width(text_str, text_h, font); - - draw_rectangle( - (Rect) { - .x = 0, - .y = 0, - .w = (float)text_w, - .h = (float)text_h, - }, - (Color) { 0, 0, 0, 255 } - ); - - draw_text(text_str, (Vec2){ 0, 0 }, text_h, (Color) { 255, 255, 255, 255 }, font); - free(text_str); -} - - -static void title_end(State *state) { - free(state->scene); -} - - -Scene *title_scene(State *state) { - (void)state; - - SceneTitle *new_scene = calloc(1, sizeof *new_scene); - new_scene->base.tick = title_tick; - new_scene->base.end = title_end; - - return (Scene *)new_scene; -} diff --git a/apps/demos/scenery/scenes/title.h b/apps/demos/scenery/scenes/title.h deleted file mode 100644 index 05a61a7..0000000 --- a/apps/demos/scenery/scenes/title.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef TITLE_H -#define TITLE_H - -#include "../state.h" -#include "scene.h" - - -typedef struct SceneTitle { - Scene base; -} SceneTitle; - - -Scene *title_scene(State *state); - - -#endif