diff options
author | Julien Dessaux | 2022-09-29 22:03:25 +0200 |
---|---|---|
committer | Julien Dessaux | 2022-09-29 22:03:25 +0200 |
commit | 2f76bca8dc84525f18df8b0658176cf806815b15 (patch) | |
tree | 342c49f27bf662381a81d352ddffd7b5b83c0d1f /src/game.zig | |
parent | Improved net collisions (diff) | |
download | grenade-brothers-2f76bca8dc84525f18df8b0658176cf806815b15.tar.gz grenade-brothers-2f76bca8dc84525f18df8b0658176cf806815b15.tar.bz2 grenade-brothers-2f76bca8dc84525f18df8b0658176cf806815b15.zip |
Added end of round detection and scoring
Diffstat (limited to '')
-rw-r--r-- | src/game.zig | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/game.zig b/src/game.zig index 9597a83..9b8086d 100644 --- a/src/game.zig +++ b/src/game.zig @@ -37,13 +37,22 @@ pub const Game = struct { self.brothers[0].resetRound(); self.brothers[1].resetRound(); } - pub fn update(self: *Game) void { + pub fn update(self: *Game) bool { self.gamepads[0].update(w4.GAMEPAD1.*); self.gamepads[1].update(w4.GAMEPAD2.*); self.brothers[0].update(self.gamepads[0]); self.brothers[1].update(self.gamepads[1]); - self.ball.update(); + const finished = self.ball.update(); self.brothers[0].collide(&self.ball); self.brothers[1].collide(&self.ball); + if (finished) |side| { + if (side == .left) { + self.brothers[1].score += 1; + } else { + self.brothers[0].score += 1; + } + return true; + } + return false; } }; |