twn_input: singleton rework, twn_control.h and fixes
This commit is contained in:
@ -15,10 +15,10 @@
|
||||
static void ingame_tick(State *state) {
|
||||
SceneIngame *scn = (SceneIngame *)state->scene;
|
||||
|
||||
if (input_is_mouse_captured(&ctx.input)) {
|
||||
if (input_is_mouse_captured()) {
|
||||
const float sensitivity = 0.6f; /* TODO: put this in a better place */
|
||||
scn->yaw += (float)ctx.input.mouse_relative_position.x * sensitivity;
|
||||
scn->pitch -= (float)ctx.input.mouse_relative_position.y * sensitivity;
|
||||
scn->yaw += (float)ctx.mouse_relative_position.x * sensitivity;
|
||||
scn->pitch -= (float)ctx.mouse_relative_position.y * sensitivity;
|
||||
scn->pitch = clampf(scn->pitch, -89.0f, 89.0f);
|
||||
|
||||
const float yaw_rad = scn->yaw * (float)DEG2RAD;
|
||||
@ -33,27 +33,27 @@ static void ingame_tick(State *state) {
|
||||
|
||||
const Vec3 right = m_vec_norm(m_vec_cross(scn->cam.target, scn->cam.up));
|
||||
const float speed = 0.04f; /* TODO: put this in a better place */
|
||||
if (input_is_action_pressed(&ctx.input, "player_left"))
|
||||
if (input_is_action_pressed("player_left"))
|
||||
scn->cam.pos = vec3_sub(scn->cam.pos, m_vec_scale(right, speed));
|
||||
|
||||
if (input_is_action_pressed(&ctx.input, "player_right"))
|
||||
if (input_is_action_pressed("player_right"))
|
||||
scn->cam.pos = vec3_add(scn->cam.pos, m_vec_scale(right, speed));
|
||||
|
||||
if (input_is_action_pressed(&ctx.input, "player_forward"))
|
||||
if (input_is_action_pressed("player_forward"))
|
||||
scn->cam.pos = vec3_add(scn->cam.pos, m_vec_scale(scn->cam.target, speed));
|
||||
|
||||
if (input_is_action_pressed(&ctx.input, "player_backward"))
|
||||
if (input_is_action_pressed("player_backward"))
|
||||
scn->cam.pos = vec3_sub(scn->cam.pos, m_vec_scale(scn->cam.target, speed));
|
||||
|
||||
if (input_is_action_pressed(&ctx.input, "player_jump"))
|
||||
if (input_is_action_pressed("player_jump"))
|
||||
scn->cam.pos.y += speed;
|
||||
|
||||
if (input_is_action_pressed(&ctx.input, "player_run"))
|
||||
if (input_is_action_pressed("player_run"))
|
||||
scn->cam.pos.y -= speed;
|
||||
|
||||
/* toggle mouse capture with end key */
|
||||
if (input_is_action_just_pressed(&ctx.input, "mouse_capture_toggle")) {
|
||||
input_set_mouse_captured(&ctx.input, !input_is_mouse_captured(&ctx.input));
|
||||
if (input_is_action_just_pressed("mouse_capture_toggle")) {
|
||||
input_set_mouse_captured(!input_is_mouse_captured());
|
||||
}
|
||||
|
||||
draw_camera(&scn->cam);
|
||||
@ -111,7 +111,7 @@ Scene *ingame_scene(State *state) {
|
||||
m_opt(channel, "soundtrack"),
|
||||
m_opt(repeat, true));
|
||||
|
||||
input_set_mouse_captured(&ctx.input, true);
|
||||
input_set_mouse_captured(true);
|
||||
|
||||
return (Scene *)new_scene;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ static void title_tick(State *state) {
|
||||
SceneTitle *scn = (SceneTitle *)state->scene;
|
||||
(void)scn;
|
||||
|
||||
if (input_is_action_just_pressed(&state->ctx->input, "ui_accept")) {
|
||||
if (input_is_action_just_pressed("ui_accept")) {
|
||||
switch_to(state, ingame_scene);
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user