66 lines
1.3 KiB
Plaintext
66 lines
1.3 KiB
Plaintext
Client:
|
|
loops
|
|
handles input from the user
|
|
handles graphics and sound
|
|
communicates with the server (how?)
|
|
|
|
-------------------------
|
|
|
|
Server:
|
|
loops
|
|
accepts new connections, disconnections, and handles loss of connections
|
|
holds the positions/data of all players
|
|
|
|
Player:
|
|
id
|
|
[graphical stuff]
|
|
position
|
|
velocity
|
|
avatarName
|
|
|
|
-------------------------
|
|
|
|
Player:
|
|
index --global index on the server
|
|
position
|
|
motion
|
|
image --avatar chosen by the player (later)
|
|
ShiftMotion(vector relativeMotion)
|
|
|
|
|
|
PlayerManager:
|
|
NewPlayer(index, avatar, x, y)
|
|
Update(delta) //all player objects
|
|
Synchronize(dataArray) //possible
|
|
|
|
-------------------------
|
|
|
|
Remember: Top down programming/K.I.S.S.
|
|
|
|
KeyDown:
|
|
up:
|
|
PlayerManager.ShiftMotion(playerIndex, up)
|
|
down:
|
|
PlayerManager.ShiftMotion(playerIndex, down)
|
|
...
|
|
end
|
|
|
|
Receive:
|
|
switch(message->type):
|
|
player update:
|
|
PlayerManager.Update(message)
|
|
end
|
|
|
|
-------------------------
|
|
|
|
TCP systems
|
|
|
|
TCPNetworkManager:
|
|
Init //opens the TCP server socket, and allocates the socket set
|
|
Quit //close the TCP server socket, and free the socket set
|
|
AcceptConnections //accept new connections
|
|
Send //send to a specific client, closing the connection if an error occured
|
|
SendAll //send to all clients
|
|
CheckSockets //non-blocking
|
|
GetSocket() //get a specific socket
|
|
total connections in the packet |