/apps/demos/scenery: remove title scene
This commit is contained in:
parent
6b2901be28
commit
f57525cea6
@ -13,7 +13,6 @@ set(SOURCE_FILES
|
|||||||
state.h
|
state.h
|
||||||
|
|
||||||
scenes/scene.c scenes/scene.h
|
scenes/scene.c scenes/scene.h
|
||||||
scenes/title.c scenes/title.h
|
|
||||||
scenes/ingame.c scenes/ingame.h
|
scenes/ingame.c scenes/ingame.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "state.h"
|
#include "state.h"
|
||||||
#include "scenes/scene.h"
|
#include "scenes/scene.h"
|
||||||
#include "scenes/title.h"
|
|
||||||
#include "scenes/ingame.h"
|
#include "scenes/ingame.h"
|
||||||
|
|
||||||
#include "twn_game_api.h"
|
#include "twn_game_api.h"
|
||||||
@ -18,7 +17,7 @@ void game_tick(void) {
|
|||||||
|
|
||||||
State *state = ctx.udata;
|
State *state = ctx.udata;
|
||||||
state->ctx = &ctx;
|
state->ctx = &ctx;
|
||||||
state->scene = title_scene(state);
|
state->scene = ingame_scene(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "ingame.h"
|
#include "ingame.h"
|
||||||
#include "title.h"
|
|
||||||
#include "scene.h"
|
#include "scene.h"
|
||||||
|
|
||||||
#include "twn_game_api.h"
|
#include "twn_game_api.h"
|
||||||
|
@ -1,61 +0,0 @@
|
|||||||
#include "title.h"
|
|
||||||
#include "ingame.h"
|
|
||||||
|
|
||||||
#include "twn_game_api.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
@ -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
|
|
Loading…
Reference in New Issue
Block a user