Just another example with using Tempest to create a network game (basically a polished, bit more complex version of the Example provided):
`Network Multiplayer Testing
TYPE Stat
Name$ AS STRING
Connection$ AS STRING
Status$ AS STRING
ID AS INTEGER
ENDTYPE
TYPE Client
Name$ AS STRING
Msg$ AS STRING
ENDTYPE
TYPE NetworkStat
IP$ AS STRING
Host$ AS STRING
MaxPlayers AS INTEGER
ENDTYPE
User AS Stat
Network AS NetworkStat
Network.MaxPlayers = 10
DIM Clients(Network.MaxPlayers) AS Client
Connect()
CreatePlayers()
MAKE MATRIX 1,1000,1000,10,10
POSITION MATRIX 1,-500,0,-500
AppSettings()
DO
Control(User.ID)
Camera(User.ID)
HandleNetwork()
Display()
Refresh()
LOOP
FUNCTION Connect()
INPUT "User Name: ",User.Name$
INPUT "Client or Host? (C/H)",User.Status$
User.Status$ = UPPER$(User.Status$)
IF User.Status$ = "C"
INPUT "Enter the IP Address of the host: ",User.Connection$
Connected = TJoin(User.Connection$,User.Name$)
ELSE
IF User.Status$ = "H"
INPUT "Enter the IP Address you wish to host on: ",User.Connection$
Connected = THost(User.Connection$,Network.MaxPlayers,User.Name$)
ELSE
PRINT "Invalid Option"
WAIT 4000
END
ENDIF
ENDIF
IF Connected = 0
PRINT "Failed to connect to IP, closing application."
WAIT 4000
END
ENDIF
User.ID = TGetThisID()
ENDFUNCTION
FUNCTION CreatePlayers()
FOR x = 1 TO Network.MaxPlayers
MAKE OBJECT CUBE x,10
POSITION OBJECT x,0,5,0
IF NOT TPlayerExist(x) THEN HIDE OBJECT x
NEXT x
ENDFUNCTION
FUNCTION AppSettings()
SYNC ON
SYNC RATE 0
AUTOCAM OFF
HIDE MOUSE
ENDFUNCTION
FUNCTION Control(Obj)
IF KEYSTATE(17)=1
MOVE OBJECT Obj,.5
ENDIF
IF KEYSTATE(31)=1
MOVE OBJECT Obj,-.5
ENDIF
IF KEYSTATE(30)=1
MOVE OBJECT LEFT Obj,.3
ENDIF
IF KEYSTATE(32)=1
MOVE OBJECT RIGHT Obj,.3
ENDIF
ROTATE OBJECT Obj,WRAPVALUE(OBJECT ANGLE X(Obj)+(MOUSEMOVEY()*0.1)),WRAPVALUE(OBJECT ANGLE Y(Obj)+(MOUSEMOVEX()*0.1)),0
ENDFUNCTION
FUNCTION Camera(Obj)
POSITION CAMERA OBJECT POSITION X(Obj),OBJECT POSITION Y(Obj),OBJECT POSITION Z(Obj)
ROTATE CAMERA OBJECT ANGLE X(Obj),OBJECT ANGLE Y(Obj),OBJECT ANGLE Z(Obj)
MOVE CAMERA -100
PITCH CAMERA UP 90
MOVE CAMERA 20
PITCH CAMERA DOWN 90
ENDFUNCTION
FUNCTION Display()
TEXT 0,0,STR$(SCREEN FPS())
FOR x = 1 TO Network.MaxPlayers
IF TPlayerExist(x)
TEXT 0,x*15,TGetPlayername(x)+"("+STR$(x)+")"
ENDIF
NEXT x
ENDFUNCTION
FUNCTION Refresh()
TSYNC
SYNC
ENDFUNCTION
FUNCTION HandleNetwork()
IF TConnected()
n = TNewPlayer()
IF n > 0 THEN SHOW OBJECT n
TPutFloat OBJECT POSITION X(User.ID)
TPutFloat OBJECT POSITION Y(User.ID)
TPutFloat OBJECT POSITION Z(User.ID)
TPutFloat OBJECT ANGLE X(User.ID)
TPutFloat OBJECT ANGLE Y(User.ID)
TSendAll
REPEAT
msg = TGetMessage()
IF msg
from = TGetSender()
x# = TGetFloat()
y# = TGetFloat()
z# = TGetFloat()
xa# = TGetFloat()
ya# = TGetFloat()
IF OBJECT EXIST(from)
POSITION OBJECT from,x#,y#,z#
ROTATE OBJECT from,xa#,ya#,0
ENDIF
ENDIF
UNTIL NOT msg
ENDIF
ENDFUNCTION
Tested it with 5 other users and it worked fine. Great work once again Benjamin!