Server and Client on one instance of a game

@kfrajer I can’t use any libraries in APDE, because of a bug I’ve reported. I can still use Android version in desktop PDE. Though I wish the APDE libraries were fixed. I write code mostly on my phone. I am currently testing it on a game of Pong (because it’s easy to write). I want to have a working network on something simple before I implement it to DubTank 2. With friends we’ve been able to run 6 clients at once (4 being spectators) without any lag. Not sure, how DubTank 2 will handle things. It’s way more complicated game with more data to send to clients.

@Iqdev I thought that might be the way to go, but I wasn’t sure. It might be more useful to use bits.
In Pong I use only these commands:

Pong Command List

Bots don’t have clients. They’re there just so that the game works. However bots use commands as well, because why make things complicated?
By default all players can use commands (like admins), because the game is for testing only.

  • goto int:playerID float:position set a position to move towards
    (If a player doesn’t control a paddle, nothing happens)
  • restartround restarts current round (duh)
  • restartgame restarts whole game (duuuuh)
  • spectator become a spectator
  • paddle int:playerid int:paddleID Gain control of a paddle
    (If no player has control of a paddle, a bot takes over)
    (If a paddle is taken, nothing happens)
  • swappaddles Swap paddles between players (or bots)
  • **disconnect int:playerID disconnects a player
  • **set String:property float:value Set a value to something in game (i.e. set paddle0size 200)
  • timescale float:timescale Slows down a game or speeds it up. (Mainly so I can )
    For bot movement:
  • paddlegoto int:paddleID float:position sets a position to move towards for a paddle

That works just fine. There’s not much delay, because it is a simple game running on LAN.
On Android, I still haven’t decided between

  • Tap to target and move
  • Use a controler to move and the rest of the screen to aim and shoot
    Depends on how efective the nework will be…
    Maybe I’ll do both, toggle in settings in server creation.
DubTank 2 Command List

An admin (also the creator of the server) can control other palyers like this. Also I plan to use those commands to control the players character by sending them from their client. I can even control a bot by sending commands.
However this aproach has a big flaw. It can be used for cheating.

So I need 1 byte for command type and the rest as parameters. Chat is fine, because unless someone spams messages, there will be at most 1 message per second. And even if that’s the case, I can limit the amount of messages sent.

Well, I’ll have to learn to work with just bytes.