This repository has been archived on 2026-04-30. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Tortuga/docs/pseudocode.txt
T

75 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
-------------------------
--send info about the specified client to all clients
--use this for new connections, movement, etc.
SendClientData(int playerID):
for (clientMap):
Send(it.channel, clientMap[playerID])
end
end
NewClientData := SendClientData
--send all info about the server to the specified client
--send this to new connections
SynchronizeClient(int playerID):
for (clientMap):
Send(clientMap[playerID].channel, it)
end
end