townengine/src/game/scenes/ingame.c

65 lines
1.9 KiB
C
Raw Normal View History

2024-07-08 00:44:20 +00:00
#include "ingame.h"
#include "title.h"
#include "scene.h"
2024-07-08 06:46:12 +00:00
#include "../../audio.h"
2024-07-08 00:44:20 +00:00
static void ingame_tick(struct state *state) {
struct scene_ingame *scn = (struct scene_ingame *)state->scene;
world_drawdef(scn->world);
player_calc(scn->player);
2024-07-08 15:13:33 +00:00
// unfurl_triangle("/assets/title.png",
// (t_fvec3){ 1250, 700, 0 },
// (t_fvec3){ 0, 800, 0 },
// (t_fvec3){ 0, 0, 0 },
// (t_shvec2){ 0, 360 },
// (t_shvec2){ 0, 0 },
// (t_shvec2){ 360, 0 });
unfurl_triangle("/assets/red.png",
(t_fvec3){ 0, 0, 0 },
(t_fvec3){ RENDER_BASE_WIDTH, 0, 0 },
(t_fvec3){ RENDER_BASE_WIDTH, RENDER_BASE_HEIGHT, 0 },
(t_shvec2){ 0, 0 },
(t_shvec2){ 80, 0 },
(t_shvec2){ 80, 80 });
unfurl_triangle("/assets/red.png",
(t_fvec3){ RENDER_BASE_WIDTH, RENDER_BASE_HEIGHT, 0 },
(t_fvec3){ 0, RENDER_BASE_HEIGHT, 0 },
(t_fvec3){ 0, 0, 0 },
(t_shvec2){ 80, 80 },
(t_shvec2){ 0, 80 },
(t_shvec2){ 0, 0 });
2024-07-08 00:44:20 +00:00
}
static void ingame_end(struct state *state) {
struct scene_ingame *scn = (struct scene_ingame *)state->scene;
player_destroy(scn->player);
world_destroy(scn->world);
}
struct scene *ingame_scene(struct state *state) {
(void)state;
struct scene_ingame *new_scene = ccalloc(1, sizeof *new_scene);
new_scene->base.tick = ingame_tick;
new_scene->base.end = ingame_end;
new_scene->world = world_create();
new_scene->player = player_create(new_scene->world);
2024-07-08 15:00:38 +00:00
play_audio_ex("music/repeat-test.xm", "soundtrack", (t_play_audio_args){
2024-07-08 06:46:12 +00:00
.volume = 0.8f,
2024-07-08 15:00:38 +00:00
.panning = -0.5f,
.repeat = true,
2024-07-08 06:46:12 +00:00
});
2024-07-08 00:44:20 +00:00
return (struct scene *)new_scene;
}