aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game.zig16
-rw-r--r--src/main.zig18
2 files changed, 20 insertions, 14 deletions
diff --git a/src/game.zig b/src/game.zig
index ddd0b62..8af1889 100644
--- a/src/game.zig
+++ b/src/game.zig
@@ -12,22 +12,22 @@ pub const Game = struct {
try self.brothers[0].draw(rc);
try self.brothers[1].draw(rc);
}
- pub fn moveJump(self: *Game) void {
- self.brothers[@enumToInt(self.side)].moveJump();
+ pub fn moveJump(self: *Game, side: brothers.Side) void {
+ self.brothers[@enumToInt(side)].moveJump();
}
- pub fn moveLeft(self: *Game) void {
- self.brothers[@enumToInt(self.side)].moveLeft();
+ pub fn moveLeft(self: *Game, side: brothers.Side) void {
+ self.brothers[@enumToInt(side)].moveLeft();
}
- pub fn moveRight(self: *Game) void {
- self.brothers[@enumToInt(self.side)].moveRight();
+ pub fn moveRight(self: *Game, side: brothers.Side) void {
+ self.brothers[@enumToInt(side)].moveRight();
}
pub fn reset(self: *Game, side: brothers.Side) void {
self.side = side;
self.resetRound();
}
pub fn resetRound(self: *Game) void {
- self.brothers[0].reset(brothers.Side.left);
- self.brothers[1].reset(brothers.Side.right);
+ self.brothers[0].reset(.left);
+ self.brothers[1].reset(.right);
}
pub fn step(self: *Game) void {
self.brothers[0].step();
diff --git a/src/main.zig b/src/main.zig
index 3a534b9..875b02c 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -49,12 +49,18 @@ pub fn main() !void {
if (in.eqlDescription("escape") or in.eqlDescription("q")) {
done = true;
break;
- } else if (in.eqlDescription("arrow-left") or in.eqlDescription("a")) {
- gs.moveLeft();
- } else if (in.eqlDescription("arrow-right") or in.eqlDescription("d")) {
- gs.moveRight();
- } else if (in.eqlDescription("arrow-up") or in.eqlDescription("space")) {
- gs.moveJump();
+ } else if (in.eqlDescription("arrow-left")) {
+ gs.moveLeft(.right);
+ } else if (in.eqlDescription("arrow-right")) {
+ gs.moveRight(.right);
+ } else if (in.eqlDescription("arrow-up")) {
+ gs.moveJump(.right);
+ } else if (in.eqlDescription("a")) {
+ gs.moveLeft(.left);
+ } else if (in.eqlDescription("d")) {
+ gs.moveRight(.left);
+ } else if (in.eqlDescription("space")) {
+ gs.moveJump(.left);
}
}
} else {