2024-09-25 15:29:58 +00:00
|
|
|
#include "ingame.h"
|
|
|
|
#include "title.h"
|
|
|
|
#include "scene.h"
|
|
|
|
|
|
|
|
#include "twn_game_api.h"
|
2024-10-07 16:57:45 +00:00
|
|
|
#include "twn_vec.h"
|
2024-09-25 15:29:58 +00:00
|
|
|
|
2024-10-06 21:00:36 +00:00
|
|
|
#include <SDL2/SDL.h>
|
|
|
|
|
2024-09-25 15:29:58 +00:00
|
|
|
|
|
|
|
static void ingame_tick(State *state) {
|
|
|
|
SceneIngame *scn = (SceneIngame *)state->scene;
|
|
|
|
|
2024-10-29 09:25:24 +00:00
|
|
|
input_action("player_left", CONTROL_A);
|
|
|
|
input_action("player_right", CONTROL_D);
|
|
|
|
input_action("player_forward", CONTROL_W);
|
|
|
|
input_action("player_backward", CONTROL_S);
|
|
|
|
input_action("player_jump", CONTROL_SPACE);
|
|
|
|
input_action("player_run", CONTROL_LSHIFT);
|
2024-10-22 17:32:17 +00:00
|
|
|
|
2024-09-25 15:29:58 +00:00
|
|
|
world_drawdef(scn->world);
|
|
|
|
player_calc(scn->player);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void ingame_end(State *state) {
|
|
|
|
SceneIngame *scn = (SceneIngame *)state->scene;
|
|
|
|
player_destroy(scn->player);
|
|
|
|
world_destroy(scn->world);
|
|
|
|
free(state->scene);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Scene *ingame_scene(State *state) {
|
|
|
|
(void)state;
|
|
|
|
|
|
|
|
SceneIngame *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);
|
|
|
|
|
|
|
|
return (Scene *)new_scene;
|
|
|
|
}
|