From a945de3218e3cf9593fa21bcc6d8af04de4443ef Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Thu, 22 Sep 2022 23:24:37 +0200 Subject: Added brothers jumping --- src/brothers.zig | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/brothers.zig') diff --git a/src/brothers.zig b/src/brothers.zig index 6121841..c3bde96 100644 --- a/src/brothers.zig +++ b/src/brothers.zig @@ -28,6 +28,15 @@ pub const Brother = struct { self.x -= 1; if (gamepad.held.right and self.x <= utils.rightLimit[@enumToInt(self.side)] - brother_width) self.x += 1; + if (self.y < 160) { // jumping! + self.vy += utils.gravity; + self.y += self.vy * utils.frequency; + if (self.y > 160) + self.y = 160; + } else if (gamepad.pressed.up) { + self.vy = -200; + self.y += self.vy * utils.frequency; + } } }; -- cgit v1.2.3