aboutsummaryrefslogtreecommitdiff
path: root/src/game.zig
diff options
context:
space:
mode:
authorJulien Dessaux2022-09-22 23:05:21 +0200
committerJulien Dessaux2022-09-22 23:05:21 +0200
commit085df94d383506dd44b6a27894b32501f9e1b5a9 (patch)
tree5e80361546f5dedd501778bb6c723b041f482ea5 /src/game.zig
parentBegan rewriting the game as a wasm4 cartridge (diff)
downloadgrenade-brothers-085df94d383506dd44b6a27894b32501f9e1b5a9.tar.gz
grenade-brothers-085df94d383506dd44b6a27894b32501f9e1b5a9.tar.bz2
grenade-brothers-085df94d383506dd44b6a27894b32501f9e1b5a9.zip
Implemented brothers movements
Diffstat (limited to '')
-rw-r--r--src/game.zig17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/game.zig b/src/game.zig
index 7dbba66..2f3dfcd 100644
--- a/src/game.zig
+++ b/src/game.zig
@@ -1,14 +1,16 @@
+const ball = @import("ball.zig");
+const brothers = @import("brothers.zig");
+const inputs = @import("inputs.zig");
const std = @import("std");
const utils = @import("utils.zig");
const w4 = @import("wasm4.zig");
-const ball = @import("ball.zig");
-const brothers = @import("brothers.zig");
-
pub const Game = struct {
ball: ball.Ball = undefined,
brothers: [2]brothers.Brother = undefined,
+ gamepads: [4]inputs.Gamepad = undefined,
playerSide: utils.side = undefined,
+
pub fn draw(self: *Game) void {
self.ball.draw();
self.brothers[0].draw();
@@ -20,8 +22,17 @@ pub const Game = struct {
pub fn reset(self: *Game) void {
self.brothers[0].reset(.left);
self.brothers[1].reset(.right);
+ self.resetRound();
+ }
+ pub fn resetRound(self: *Game) void {
self.ball.resetRound(.left);
self.brothers[0].resetRound();
self.brothers[1].resetRound();
}
+ pub fn update(self: *Game) void {
+ 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]);
+ }
};