townengine/src/game/scenes/ingame.c
2024-07-08 09:55:28 +03:00

40 lines
930 B
C

#include "ingame.h"
#include "title.h"
#include "scene.h"
#include "../../audio.h"
static void ingame_tick(struct state *state) {
struct scene_ingame *scn = (struct scene_ingame *)state->scene;
world_drawdef(scn->world);
player_calc(scn->player);
}
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);
play_audio_ex("music/test.ogg", "soundtrack", (t_play_audio_args){
.volume = 0.8f,
.panning = -0.5f
});
return (struct scene *)new_scene;
}