From 437ad8c4b0d2ddd1d53416b68eed2476d4237380 Mon Sep 17 00:00:00 2001 From: Edgaru089 Date: Sun, 28 Apr 2024 19:59:16 +0800 Subject: [PATCH] Load a level for graphics on title screen --- app.c | 1 + mapper_misc.c | 6 ++++-- title.txt | 9 +++++++++ ui_build.c | 6 +----- 4 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 title.txt diff --git a/app.c b/app.c index 99d9a32..b4779ee 100644 --- a/app.c +++ b/app.c @@ -43,6 +43,7 @@ App *app_NewApp() { app->wantQuit = false; app->paused = false; + app_QueueLoadLevel(app, "title.txt"); return app; } diff --git a/mapper_misc.c b/mapper_misc.c index 77c2c45..781c75d 100644 --- a/mapper_misc.c +++ b/mapper_misc.c @@ -140,8 +140,6 @@ void misc_thinker_ChangeLevel(App *app, Entity *e, Duration deltaTime) { e->thinker = NULL; return; } - if (app->player->player == NULL) // No player - return; // Copied from Hazard thinker uint64_t emitCooldown = 400.0 * 60000.0 / e->misc->trigger.size.x; // 60 msec across 400px @@ -164,6 +162,10 @@ void misc_thinker_ChangeLevel(App *app, Entity *e, Duration deltaTime) { 20, duration_FromSeconds(0), &render_ModeDefault); e->thinkerData = (void *)lastEmit.microseconds; } + + if (app->player->player == NULL) // No player + return; + Component_Player *p = app->player->player; Box2 playerbox = physics_HitboxAbsolute(p->super->hitbox); diff --git a/title.txt b/title.txt new file mode 100644 index 0000000..aa9c209 --- /dev/null +++ b/title.txt @@ -0,0 +1,9 @@ +CUTOFF 1500 +BACKGROUND 40 40 40 +PUT_CAMERA 0 0 +HAZARD -590 -250 200 100 +LEVEL_TRANSITION 350 100 200 100 intro.txt +FILL 0 0 0 -590 -250 200 1000 +FILL 255 255 255 350 100 200 500 +FILL 20 20 20 -219 152 184 488 +TEXTBOX -206 79 65 78 info_plate_small_2 safa diff --git a/ui_build.c b/ui_build.c index 2ad66cc..0525cf2 100644 --- a/ui_build.c +++ b/ui_build.c @@ -24,11 +24,7 @@ static void _ui_Action_ReturnToTitle(System_UI *sys, ui_Part *part, uintptr_t da WARN("new state stack is now empty, ohno"); sys->super->clear_color = RGB(40, 40, 40); - // Clear the app - // see app_file.c:233 - entity_Clear(sys->super->entity); - particle_Clear(sys->super->particle); - sys->super->camera->target = NULL; + app_QueueLoadLevel(sys->super, "title.txt"); } static void _ui_Action_SelectLevel(System_UI *sys, ui_Part *part, uintptr_t data) { while (vector_Size(sys->state) > 0 && ui_CurrentState(sys) != ui_TitleMenu) {