rework input to be in line with rendering semantics

This commit is contained in:
veclavtalica
2024-10-22 20:32:17 +03:00
parent a22bcfd97e
commit 9da26638c8
13 changed files with 98 additions and 130 deletions

View File

@ -18,40 +18,13 @@ void game_tick(void) {
state->ctx = &ctx;
state->scene = title_scene(state);
}
input_add_action("debug_toggle");
input_bind_action_control("debug_toggle", CONTROL_BACKSPACE);
input_add_action("debug_dump_atlases");
input_bind_action_control("debug_dump_atlases", CONTROL_HOME);
input_add_action("player_left");
input_bind_action_control("player_left", CONTROL_A);
input_add_action("player_right");
input_bind_action_control("player_right", CONTROL_D);
input_add_action("player_forward");
input_bind_action_control("player_forward", CONTROL_W);
input_add_action("player_backward");
input_bind_action_control("player_backward", CONTROL_S);
input_add_action("player_jump");
input_bind_action_control("player_jump", CONTROL_SPACE);
input_add_action("player_run");
input_bind_action_control("player_run", CONTROL_LSHIFT);
input_add_action("ui_accept");
input_bind_action_control("ui_accept", CONTROL_RETURN);
input_add_action("mouse_capture_toggle");
input_bind_action_control("mouse_capture_toggle", CONTROL_ESCAPE);
}
State *state = ctx.udata;
input_bind_action_control("debug_toggle", CONTROL_BACKSPACE);
input_bind_action_control("debug_dump_atlases", CONTROL_HOME);
if (input_is_action_just_pressed("debug_toggle")) {
ctx.debug = !ctx.debug;
}

View File

@ -11,6 +11,13 @@
static void ingame_tick(State *state) {
SceneIngame *scn = (SceneIngame *)state->scene;
input_bind_action_control("player_left", CONTROL_A);
input_bind_action_control("player_right", CONTROL_D);
input_bind_action_control("player_forward", CONTROL_W);
input_bind_action_control("player_backward", CONTROL_S);
input_bind_action_control("player_jump", CONTROL_SPACE);
input_bind_action_control("player_run", CONTROL_LSHIFT);
world_drawdef(scn->world);
player_calc(scn->player);

View File

@ -14,6 +14,8 @@ static void title_tick(State *state) {
SceneTitle *scn = (SceneTitle *)state->scene;
(void)scn;
input_bind_action_control("ui_accept", CONTROL_RETURN);
if (input_is_action_just_pressed("ui_accept")) {
switch_to(state, ingame_scene);
return;