Make inputs mutable
This commit is contained in:
parent
6b32f45534
commit
c2786fdceb
|
@ -4,10 +4,10 @@ const input = @import("input.zig");
|
|||
|
||||
activate: bool = false,
|
||||
holding: bool = false,
|
||||
input: input.Input,
|
||||
input: *const input.Input,
|
||||
callback: *const anyopaque, // MUST be a function with void return
|
||||
|
||||
pub fn init(tmp_input: input.Input, callback: *const anyopaque) Self {
|
||||
pub fn init(tmp_input: *const input.Input, callback: *const anyopaque) Self {
|
||||
return Self{
|
||||
.input = tmp_input,
|
||||
.callback = callback,
|
||||
|
|
14
src/Game.zig
14
src/Game.zig
|
@ -41,13 +41,13 @@ shadow: Piece,
|
|||
score: Score = 0,
|
||||
|
||||
action_list: ActionList = .{
|
||||
.right = Action.init(input.game_right, actionRight), // Right
|
||||
.left = Action.init(input.game_left, actionLeft), // Left
|
||||
.down = Action.init(input.game_down, actionDown), // Down
|
||||
.hard = Action.init(input.game_drop, actionHard), // Instant Drop
|
||||
.swap = Action.init(input.game_swap_piece, actionSwap), // Swap Piece
|
||||
.rot_r = Action.init(input.game_rotate_r, actionRotR), // Rotate
|
||||
.rot_l = Action.init(input.game_rotate_l, actionRotL), // Rotate
|
||||
.right = Action.init(&input.game_right, actionRight), // Right
|
||||
.left = Action.init(&input.game_left, actionLeft), // Left
|
||||
.down = Action.init(&input.game_down, actionDown), // Down
|
||||
.hard = Action.init(&input.game_drop, actionHard), // Instant Drop
|
||||
.swap = Action.init(&input.game_swap_piece, actionSwap), // Swap Piece
|
||||
.rot_r = Action.init(&input.game_rotate_r, actionRotR), // Rotate
|
||||
.rot_l = Action.init(&input.game_rotate_l, actionRotL), // Rotate
|
||||
},
|
||||
|
||||
timer_down: Timer,
|
||||
|
|
|
@ -22,11 +22,11 @@ const ActionList = struct {
|
|||
};
|
||||
|
||||
action_list: ActionList = .{
|
||||
.right = Action.init(input.menu_right, actionTabRight), // Tab Right
|
||||
.left = Action.init(input.menu_left, actionTabLeft), // Tab left
|
||||
.down = Action.init(input.menu_down, actionSelDown), // Go down
|
||||
.up = Action.init(input.menu_up, actionSelUp), // Go up
|
||||
.select = Action.init(input.menu_accept, actionSelect), // Select
|
||||
.right = Action.init(&input.menu_right, actionTabRight), // Tab Right
|
||||
.left = Action.init(&input.menu_left, actionTabLeft), // Tab left
|
||||
.down = Action.init(&input.menu_down, actionSelDown), // Go down
|
||||
.up = Action.init(&input.menu_up, actionSelUp), // Go up
|
||||
.select = Action.init(&input.menu_accept, actionSelect), // Select
|
||||
},
|
||||
|
||||
tab_list: [3]MenuTab = .{
|
||||
|
|
|
@ -24,17 +24,17 @@ fn init(comptime name: []const u8, comptime key_code: []const u8) Input {
|
|||
};
|
||||
}
|
||||
|
||||
pub const menu_right = init("Menu Right", "RIGHT");
|
||||
pub const menu_left = init("Menu Left", "LEFT");
|
||||
pub const menu_down = init("Menu Down", "DOWN");
|
||||
pub const menu_up = init("Menu Up", "UP");
|
||||
pub const menu_accept = init("Menu Accept", "ENTER");
|
||||
pub const menu_cancel = init("Menu Cancel", "BACKSPACE");
|
||||
pub var menu_right = init("Menu Right", "RIGHT");
|
||||
pub var menu_left = init("Menu Left", "LEFT");
|
||||
pub var menu_down = init("Menu Down", "DOWN");
|
||||
pub var menu_up = init("Menu Up", "UP");
|
||||
pub var menu_accept = init("Menu Accept", "ENTER");
|
||||
pub var menu_cancel = init("Menu Cancel", "BACKSPACE");
|
||||
|
||||
pub const game_right = init("Move Right", "D");
|
||||
pub const game_left = init("Move Left", "A");
|
||||
pub const game_down = init("Move Down", "S");
|
||||
pub const game_drop = init("Drop Piece", "W");
|
||||
pub const game_swap_piece = init("Swap Piece", "SPACE");
|
||||
pub const game_rotate_r = init("Rotate Piece Clockwise", "RIGHT");
|
||||
pub const game_rotate_l = init("Rotate Piece Counterclockwise", "LEFT");
|
||||
pub var game_right = init("Move Right", "D");
|
||||
pub var game_left = init("Move Left", "A");
|
||||
pub var game_down = init("Move Down", "S");
|
||||
pub var game_drop = init("Drop Piece", "W");
|
||||
pub var game_swap_piece = init("Swap Piece", "SPACE");
|
||||
pub var game_rotate_r = init("Rotate Piece Clockwise", "RIGHT");
|
||||
pub var game_rotate_l = init("Rotate Piece Counterclockwise", "LEFT");
|
||||
|
|
Loading…
Reference in New Issue