Online gaming byte breakdown

Miscellaneous Forums/General Discussion/Online gaming byte breakdown

Am playing around with some multiplayer concepts from the ground up. Am going on the basis that my packets will be 255 ish bytes in the first instance, with a view to servicing 25 clients max in the first instance. breaking it down to 10 bytes per client, the client count will allow the client to determine where the client's person is on the server, any comments appreciated!

; player/client count: 1 byte
; player: x, y co -ords, 2 bytes
; shot anything: yes/no 1 byte
; projectile alive: 1 byte
; projectile x,y: 2 bytes
; player world count: 1 byte
; leaving 2 bytes for whatever

this is kind of a WIP with a view to developing an appreciation of B3D's capability kind of in conjunction with this thread:

http://www.blitzbasic.com/codearcs/codearcs.php?code=2182#comments

I appreciate I may be re-inventing the wheel, but it's nice to do things from the ground up ......

if your using 3d then I would say four bytes for X, Y, Z each as blitz uses floats and it will give better results.

Elite Multiplayer uses:
header x bytes (dependent on version)
X, Y, Z, rotation X, Y, Z 4 each
system 1 byte
galaxy 1 byte
Special action 1 byte
footer x bytes

thanks for the help EdzUp, yes I'm using 3D for this application. I'll revise my design (;-)

also try using bit switches for simple boolean properties.
e.g. you can use one byte for several things at once:

Bit 0-4 = 31 possible values, enough to tell you which one of your 25 players the message is coming from.
Bit 5 = projectile alive? yes/no
Bit 6 = player alive? yes/no
Bit 7 = applying force? yes/no

creative use of space will save you lots of bytes and even increase the number of players you can accomodate :)

now I haven't used Blitz3D in ages, but It's just a matter of masking out all the bits you don't want to get your result:

myByte            Mask                Result
%11011001    %00001111        %00001001

so if  you wanted the player number from my example above:

result = myByte AND %00001111
print result (9)

if you want to set a bit in myByte:

myByte = myByte OR %01000000
// this just set bit 6, and tells you that the player is dead


http://www.blitzbasic.com/Community/posts.php?topic=70577

More bit manipulation help

thanks, saving bytes by bit manip is a good way to get my packets down...