Added brothers jumping
This commit is contained in:
parent
085df94d38
commit
a945de3218
2 changed files with 11 additions and 1 deletions
|
@ -28,6 +28,15 @@ pub const Brother = struct {
|
||||||
self.x -= 1;
|
self.x -= 1;
|
||||||
if (gamepad.held.right and self.x <= utils.rightLimit[@enumToInt(self.side)] - brother_width)
|
if (gamepad.held.right and self.x <= utils.rightLimit[@enumToInt(self.side)] - brother_width)
|
||||||
self.x += 1;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
//----- Physics ---------------------------------------------------------------
|
//----- Physics ---------------------------------------------------------------
|
||||||
pub const gravity: f64 = 9.807; // m/s²
|
pub const gravity: f64 = 9.807; // m/s²
|
||||||
pub const scale: f64 = 1.0 / 30; // 30 pixels == 1m
|
pub const scale: f64 = 1.0 / 30.0; // 30 pixels == 1m
|
||||||
|
pub const frequency: f64 = 1.0 / 60.0; // 60 fps
|
||||||
|
|
||||||
//----- Playground ------------------------------------------------------------
|
//----- Playground ------------------------------------------------------------
|
||||||
pub const side = enum(u1) {
|
pub const side = enum(u1) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue