diff options
Diffstat (limited to '')
-rw-r--r-- | src/brothers.zig | 1 | ||||
-rw-r--r-- | src/game.zig | 2 | ||||
-rw-r--r-- | src/inputs.zig | 5 |
3 files changed, 8 insertions, 0 deletions
diff --git a/src/brothers.zig b/src/brothers.zig index f29895e..ddd0903 100644 --- a/src/brothers.zig +++ b/src/brothers.zig @@ -50,6 +50,7 @@ pub const Brother = struct { pub fn resetRound(self: *Brother) void { self.x = utils.startingX[@enumToInt(self.side)]; self.y = 160; + self.vy = 0; } pub fn update(self: *Brother, gamepad: inputs.Gamepad) void { if (gamepad.held.left and self.x > utils.leftLimit[@enumToInt(self.side)]) diff --git a/src/game.zig b/src/game.zig index ce98eef..a8be210 100644 --- a/src/game.zig +++ b/src/game.zig @@ -40,6 +40,8 @@ pub const Game = struct { } self.brothers[0].resetRound(); self.brothers[1].resetRound(); + self.gamepads[0].reset(); + self.gamepads[1].reset(); } pub fn update(self: *Game) bool { self.gamepads[0].update(w4.GAMEPAD1.*); diff --git a/src/inputs.zig b/src/inputs.zig index 4d2afa0..7a5e706 100644 --- a/src/inputs.zig +++ b/src/inputs.zig @@ -18,6 +18,11 @@ pub const Gamepad = struct { pressed: Buttons = .{}, released: Buttons = .{}, + pub fn reset(self: *Gamepad) void { + self.held = @bitCast(Buttons, @bitCast(u8, self.held) ^ @bitCast(u8, self.held)); + self.pressed = @bitCast(Buttons, @bitCast(u8, self.pressed) ^ @bitCast(u8, self.pressed)); + self.released = @bitCast(Buttons, @bitCast(u8, self.released) ^ @bitCast(u8, self.released)); + } pub fn update(self: *Gamepad, buttons: u8) void { var previous = @bitCast(u8, self.held); self.held = @bitCast(Buttons, buttons); |