2024-07-08 00:44:20 +00:00
|
|
|
#include "title.h"
|
|
|
|
#include "ingame.h"
|
|
|
|
#include "../world.h"
|
|
|
|
#include "../player.h"
|
2024-07-29 20:40:15 +00:00
|
|
|
#include "townengine/game_api.h"
|
2024-07-08 00:44:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
static void title_tick(struct state *state) {
|
|
|
|
struct scene_title *scn = (struct scene_title *)state->scene;
|
|
|
|
(void)scn;
|
|
|
|
|
|
|
|
if (input_is_action_just_pressed(&state->ctx->input, "ui_accept")) {
|
|
|
|
switch_to(state, ingame_scene);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
push_sprite("/assets/title.png", (t_frect) {
|
|
|
|
(RENDER_BASE_WIDTH / 2) - (320 / 2), 64, 320, 128
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void title_end(struct state *state) {
|
|
|
|
struct scene_title *scn = (struct scene_title *)state->scene;
|
|
|
|
player_destroy(scn->player);
|
|
|
|
world_destroy(scn->world);
|
2024-07-27 22:44:39 +00:00
|
|
|
free(state->scene);
|
2024-07-08 00:44:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct scene *title_scene(struct state *state) {
|
|
|
|
(void)state;
|
|
|
|
|
|
|
|
struct scene_title *new_scene = ccalloc(1, sizeof *new_scene);
|
|
|
|
new_scene->base.tick = title_tick;
|
|
|
|
new_scene->base.end = title_end;
|
|
|
|
|
|
|
|
new_scene->world = world_create();
|
|
|
|
new_scene->player = player_create(new_scene->world);
|
|
|
|
|
|
|
|
return (struct scene *)new_scene;
|
|
|
|
}
|