Online gaming byte breakdown

Miscellaneous Forums/General Discussion/Online gaming byte breakdown

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

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