diff --git a/examples/multi/client.cl b/examples/multi/client.cl index e898fa8..95cecfb 100644 --- a/examples/multi/client.cl +++ b/examples/multi/client.cl @@ -70,7 +70,7 @@ class PlayerLobby inherits Thread { init(c: Client): SELF_TYPE { { client <- c; self; } }; run(): Object { - while true loop + while true loop -- TODO: add exit condition case client.recv() of message: PlayerPosition => player_update(message); message: CoinPosition => coin_update(message); @@ -149,7 +149,7 @@ class Main { screen_width: Int <- maxX * cell_size; screen_height: Int <- maxY * cell_size; - client: Client <- new Client.init("127.0.0.1", 8081, new MessageHelper).connect(); + client: Client <- new Client.init("127.0.0.1", 8080, new MessageHelper).connect(); lobby: PlayerLobby <- new PlayerLobby.init(client); pthread: PThread <- new PThread; @@ -165,11 +165,13 @@ class Main { keyW: Bool <- raylib.isKeyPressed(raylib.keyW()), keyS: Bool <- raylib.isKeyPressed(raylib.keyS()), message: PlayerInput <- new PlayerInput.init(lobby.player_id(), keyA, keyD, keyW, keyS) - in lobby.send(message); -- if need optimizations we can ignore when all keys are false + in lobby.send(message); raylib.beginDrawing(); raylib.clearBackground(raylib.raywhite()); + -- TODO: add score UI + lobby.draw(raylib); raylib.endDrawing(); diff --git a/examples/multi/message.cl b/examples/multi/message.cl index 932f88f..7ad00f6 100644 --- a/examples/multi/message.cl +++ b/examples/multi/message.cl @@ -1,3 +1,5 @@ +-- TODO: add disconnect message/quit + class MessageHelper inherits Serde { deserialize(input: String): Tuple (* Message, String *) { let kind: String <- input.substr(0, 1), diff --git a/examples/multi/server.cl b/examples/multi/server.cl index 9346e86..5ea0139 100644 --- a/examples/multi/server.cl +++ b/examples/multi/server.cl @@ -41,6 +41,7 @@ class Player inherits Thread { update(input: PlayerInput): Object { { + -- TODO: keep players within bounds if (input.keyA()) then pos_x <- pos_x - size_x else if (input.keyD()) then pos_x <- pos_x + size_x else if (input.keyW()) then pos_y <- pos_y - size_y else @@ -191,7 +192,7 @@ class PlayerLobby inherits Thread { class Main { linux: Linux <- new Linux; - server: Server <- new Server.init(8081, new MessageHelper).listen(10); + server: Server <- new Server.init(8080, new MessageHelper).listen(10); pthread: PThread <- new PThread; lobby: PlayerLobby <- new PlayerLobby.init(server); lobby_thread: Int <- pthread.spawn(lobby);