Hey there benjamin. I finaly got all my router problems fixed and the example game works between me and my friend.
I built a world with world maker. I didnt put any objects in, just some fog, a sky, and some hills.
I then merged it into your example program and changed some of your code.
I run the program twice. I choose host on the first one and client on the second. I have them both connect to 127.0.0.1
They both come up fine, but i cant see the other person in either one.
here is the source code, all of your functions are at the very bottom.
`Constants --------------------------------
#constant MAXPLAYERS 10
#constant SENDGAP 100
`------------------------------------------
`Types ------------------------------------
type playerstates
keyup as boolean
keydown as boolean
endtype
`------------------------------------------
`Data -------------------------------------
global OURID as integer
global LASTSENT as integer
global PLAYER_ANGLE_Y as float
dim playerdata(MAXPLAYERS) as playerstates
`------------------------------------------
`Ask for choice of mode
print "1. Host"
print "2. Join"
Input "Choice: ", choice
`If no choice then quit
if choice=0 then end
`If choice is 1 then host a multiplayer game
if choice=1
`Ask for username and IP to host on
input "Nickname: ", nick$
input "IP: ", ip$
`If either variable is empty, set a default
if nick$="" then nick$ = "Host"
if ip$="" then ip$ = "0.0.0.0"
`Host the multiplayer game
result = THost(ip$, MAXPLAYERS, nick$)
`If hosting failed then report to user and quit
if not result
print "Failed to host game"
wait key
end
endif
endif
`If choice is 1 then join
if choice=2
`Ask for username and IP to host on
input "Nickname: ", nick$
input "IP: ", ip$
`If either variable is empty, set a default
if nick$="" then nick$ = "Client"
if ip$="" then ip$ = "0.0.0.0"
`Join the multiplayer game
result = TJoin(ip$, nick$)
`If hosting failed then report to user and quit
if not result
print "Failed to join game"
wait key
end
endif
endif
`Retrieve our ID in the game and store it
OURID = TGetThisID()
`Set up sync
sync on
sync rate 60
hide mouse
autocam off
gosub worldload
rem Create a cube
Make Object cube OURID,10
position object OURID,x=info(32),y=info(33),z=info(34)
do
`Output the framerate
text 0, 0, "Screen FPS: "+str$(screen fps())
`Show who is online
for x=1 to MAXPLAYERS
if TPlayerExist(x)
text 0, x*13, TGetPlayername(x)+"("+str$(x)+") is connected."
endif
next x
`Update everything
HandleControls()
HandleCamera()
if TConnected() then HandleNetwork()
HandleMovement()
`Let Tempest update itself
TSync
`Refresh the screen
Sync
loop
worldload:
set normalization on
dim name$(525)
dim map(500,9)
dim info(60)
dim htmap(100,100)
dim texmap(100,100)
rem get the files
homedir$=get dir$()
set dir "C:Program FilesworldmakerNew Foldermaps"
rem loading the arrays for this world
load array "first",name$(0)
load array name$(505),info(0)
load array name$(506),map(0)
load array name$(507),htmap(0,0)
load array name$(508),texmap(0)
mx#=val(name$(511)):my#=val(name$(512)):mz#=val(name$(513))
matnum=int(val(name$(510)))
set dir homedir$
set camera range 10,9000
set light range 0,9000
rem sky and clouds
htx=info(1)*info(3)
htz=info(2)*info(3)
if info(46)=0 then info(46)=10000
make object sphere 599,info(46)
position object 599,mx#+int(htx*0.5),0,mz#+int(htz*0.5)
set object 599,1,1,0,0,0,info(20),0
set dir homedir$
set dir "C:Program FilesworldmakerNew Foldersky"
load image name$(516),21
set dir homedir$
texture object 599,21
if info(13)=1
make object sphere 598,0.8*info(46)
position object 598,mx#+int(htx*0.5),0,mz#+int(htz*0.5)
set object 598,1,1,0,0,0,info(20),0
set dir homedir$
set dir "C:Program FilesworldmakerNew Foldersky"
load image name$(517),22
set dir homedir$
texture object 598,22
show object 598
set alpha mapping on 598,50
endif
rem end sky and clouds
rem texturing the matrix
name$(502)=name$(502)
tilx=info(1)
tilz=info(2)
nt=info(1)*info(2)
set dir "C:Program FilesworldmakerNew Foldermedia"
rem tile the single image
if info(25)=0 then info(25)=1
rem load texture map
if file exist(name$(502))=1 and info(26)<2 then load image name$(502),325
set dir homedir$
make matrix matnum,htx,htz,info(1),info(2)
position matrix matnum,mx#,my#,mz#
prepare matrix texture matnum,325,1,1
set matrix trim matnum,val(name$(503)),val(name$(504))
set matrix matnum,0,info(44),1,2,1,1,1
update matrix matnum
rem set heights
nt=info(1)*info(2)
for t=1 to nt
for x=0 to info(1)
for z=0 to info(2)
set matrix height matnum,x,z,htmap(x,z)
next z
next x
next t
rem set individual textures
for x=0 to info(1)-1
for z=0 to info(2)-1
set matrix tile matnum,x,z,texmap(x,z)
next x
next z
set matrix texture matnum,0,1
update matrix matnum
rem set light 0
set directional light 0,info(9),info(10),Info(11)
color light 0,info(6),info(7),info(8)
set ambient light info(5)
color ambient light rgb(info(27),info(28),info(29))
fog on
fog distance info(14)
fog color rgb(info(16),info(17),info(18))
set normalization on
rem calculate normals
update matrix matnum
rem undims the arrays you don't need anymore
undim name$(525)
undim map(500,9)
undim htmap(100,100)
undim texmap(100,100)
return
function HandleMovement()
for x=1 to MAXPLAYERS
if OURID<>x and object exist(x)
if playerdata(x).keyup then move object x, 1
if playerdata(x).keydown then move object x, -1
endif
next x
endfunction
function HandleControls()
if upkey() then move object OURID, 1
if downkey() then move object OURID, -1
if leftkey() then dec PLAYER_ANGLE_Y
if rightkey() then inc PLAYER_ANGLE_Y
yrotate object OURID, PLAYER_ANGLE_Y
x#=Object Position x(OURID)
z#=Object position z(OURID)
y#=Get Ground height(1,x#,z#)+5
rem Finally, position our cube.
Position object OURID, x# , y# , z#
`This shows how the host can boot a player
if spacekey()
TKillPlayer 2
repeat : until not spacekey()
endif
`This shows how to disconnect
if shiftkey()
TDisconnect
repeat : until not shiftkey()
endif
endfunction
function HandleCamera()
xPos# = cos(270-PLAYER_ANGLE_Y) * 50 + object position x(OURID)
zPos# = sin(270-PLAYER_ANGLE_Y) * 50 + object position z(OURID)
position camera xPos#, 30, zPos#
point camera object position x(OURID), 10, object position z(OURID)
rem Keep the camera above the ground.
if Camera Position y()<Get Ground height(1,Camera Position x(),Camera Position z())+10 then Position camera Camera position x(),Get Ground height(1,Camera Position x(),Camera Position z())+20,Camera Position z()
endfunction
function HandleNetwork()
`Player states
`Send
if LASTSENT+SENDGAP<timer()
TPutFloat object position x(OURID)
TPutFloat object position z(OURID)
TPutFloat object position y(OURID)
TPutFloat PLAYER_ANGLE_Y
TPutByte upkey()
TPutByte downkey()
TSendAll
LASTSENT = timer()
endif
`Receive
repeat
newMsg = TGetMessage()
if newMsg
from = TGetSender()
x# = TGetFloat()
z# = TGetFloat()
y# = TGetFloat()
yA# = TGetFloat()
playerdata(from).keyup = TGetByte()
playerdata(from).keydown = TGetByte()
XVAL = x#
ZVAL = z#
if object exist(from)
position object from, x#, y#, z#
yrotate object from, yA#
endif
endif
until not newMsg
endfunction
here is a screenshot of whats happening. the cubes are in the same corner, looking at the same spot, but they cant see each other. the picture may take a little bit to load.
here are the logs:
host log:
Tempest v1.0 Free Release
[15:22:45] Attempting to host...
-----------------Settings-------------------
Name : matt
Local IP Address: 127.0.0.1
Remote IP Address: ?.?.?.?
Local Port: 3999
Remote Port: ?
---------------------------------------------
[15:22:45] Game started
[15:23:42] dude has joined
[15:23:48] Recv error 10054
[15:23:48] Recv error 10054
[15:23:48] Recv error 10054
[15:23:48] Recv error 10054
[15:23:48] Recv error 10054
[15:23:48] Recv error 10054
[15:23:48] Recv error 10054
[15:23:49] Recv error 10054
[15:23:49] Recv error 10054
[15:23:49] Recv error 10054
[15:23:49] Recv error 10054
[15:23:49] Recv error 10054
[15:23:49] Recv error 10054
[15:23:49] Recv error 10054
[15:23:49] Recv error 10054
[15:23:49] Recv error 10054
[15:23:50] Recv error 10054
[15:23:50] Recv error 10054
[15:23:50] Recv error 10054
[15:23:50] Recv error 10054
[15:23:50] Recv error 10054
[15:23:50] Recv error 10054
[15:23:50] Recv error 10054
[15:23:50] Recv error 10054
[15:23:50] Recv error 10054
[15:23:50] Recv error 10054
[15:23:50] Recv error 10054
[15:23:51] Recv error 10054
[15:23:51] Recv error 10054
[15:23:51] Recv error 10054
[15:23:51] Recv error 10054
[15:23:51] Recv error 10054
[15:23:51] Recv error 10054
[15:23:51] Recv error 10054
[15:23:51] Recv error 10054
[15:23:51] Recv error 10054
[15:23:52] Recv error 10054
[15:23:52] Recv error 10054
[15:23:52] Recv error 10054
[15:23:52] Recv error 10054
[15:23:52] Recv error 10054
[15:23:52] Recv error 10054
[15:23:52] Recv error 10054
[15:23:52] Recv error 10054
[15:23:52] Recv error 10054
[15:23:53] Recv error 10054
[15:23:53] Recv error 10054
[15:23:53] Recv error 10054
[15:23:53] Recv error 10054
[15:23:53] Recv error 10054
[15:23:53] Recv error 10054
[15:23:53] Recv error 10054
[15:23:53] Recv error 10054
[15:23:53] Recv error 10054
[15:23:53] Recv error 10054
[15:23:54] Recv error 10054
[15:23:54] Recv error 10054
[15:23:54] Recv error 10054
[15:23:54] Recv error 10054
[15:23:54] Recv error 10054
[15:23:54] Recv error 10054
[15:23:54] Recv error 10054
[15:23:54] Recv error 10054
[15:23:54] Recv error 10054
[15:23:55] Recv error 10054
[15:23:55] Recv error 10054
[15:23:55] Recv error 10054
[15:23:55] Recv error 10054
[15:23:55] Recv error 10054
[15:23:55] Recv error 10054
[15:23:55] Recv error 10054
[15:23:55] Recv error 10054
[15:23:55] Recv error 10054
[15:23:55] Recv error 10054
[15:23:56] Recv error 10054
[15:23:56] Recv error 10054
[15:23:56] Recv error 10054
[15:23:56] Recv error 10054
[15:23:56] Recv error 10054
[15:23:56] Recv error 10054
[15:23:56] Recv error 10054
[15:23:56] Recv error 10054
[15:23:56] Recv error 10054
[15:23:57] Recv error 10054
[15:23:57] Recv error 10054
[15:23:57] Recv error 10054
[15:23:57] Recv error 10054
[15:23:57] Recv error 10054
[15:23:57] Recv error 10054
[15:23:57] Recv error 10054
[15:23:57] Recv error 10054
[15:23:57] Recv error 10054
[15:23:57] Recv error 10054
[15:23:58] Recv error 10054
[15:23:58] Recv error 10054
[15:23:58] Recv error 10054
[15:23:58] Recv error 10054
[15:23:58] Recv error 10054
[15:23:58] Recv error 10054
[15:23:58] Recv error 10054
[15:23:58] Recv error 10054
[15:23:58] Recv error 10054
[15:23:59] Recv error 10054
[15:23:59] Recv error 10054
[15:23:59] Recv error 10054
[15:23:59] Recv error 10054
[15:23:59] Recv error 10054
[15:23:59] Recv error 10054
[15:23:59] Recv error 10054
[15:23:59] Recv error 10054
[15:23:59] Recv error 10054
[15:24:00] Recv error 10054
[15:24:00] Recv error 10054
[15:24:00] Recv error 10054
[15:24:00] Recv error 10054
[15:24:00] Recv error 10054
[15:24:00] Recv error 10054
[15:24:00] Recv error 10054
[15:24:00] Recv error 10054
[15:24:00] Recv error 10054
[15:24:00] Recv error 10054
[15:24:01] Recv error 10054
[15:24:01] Recv error 10054
[15:24:01] Recv error 10054
[15:24:01] Recv error 10054
[15:24:01] Recv error 10054
[15:24:01] Recv error 10054
[15:24:01] Recv error 10054
[15:24:01] Recv error 10054
[15:24:01] Recv error 10054
[15:24:02] Recv error 10054
[15:24:02] Recv error 10054
[15:24:02] Recv error 10054
[15:24:02] Recv error 10054
[15:24:02] Recv error 10054
[15:24:02] Recv error 10054
[15:24:02] Recv error 10054
[15:24:02] Recv error 10054
[15:24:02] Connection with player 2 lost(Timed out)
[15:25:11] dude has joined
[15:25:16] Recv error 10054
[15:25:16] Recv error 10054
[15:25:16] Recv error 10054
[15:25:16] Recv error 10054
[15:25:16] Recv error 10054
[15:25:16] Recv error 10054
[15:25:16] Recv error 10054
[15:25:16] Recv error 10054
[15:25:16] Recv error 10054
[15:25:16] Recv error 10054
[15:25:17] Recv error 10054
[15:25:17] Recv error 10054
[15:25:17] Recv error 10054
[15:25:17] Recv error 10054
[15:25:17] Recv error 10054
[15:25:17] Recv error 10054
[15:25:17] Recv error 10054
[15:25:17] Recv error 10054
[15:25:17] Recv error 10054
[15:25:18] Recv error 10054
[15:25:18] Recv error 10054
[15:25:18] Recv error 10054
[15:25:18] Recv error 10054
[15:25:18] Recv error 10054
[15:25:18] Recv error 10054
[15:25:18] Recv error 10054
[15:25:18] Recv error 10054
[15:25:18] Recv error 10054
[15:25:19] Recv error 10054
[15:25:19] Recv error 10054
[15:25:19] Recv error 10054
[15:25:19] Recv error 10054
[15:25:19] Recv error 10054
[15:25:19] Recv error 10054
[15:25:19] Recv error 10054
[15:25:19] Recv error 10054
[15:25:19] Recv error 10054
[15:25:19] Recv error 10054
[15:25:20] Recv error 10054
[15:25:20] Recv error 10054
[15:25:20] Recv error 10054
[15:25:20] Recv error 10054
[15:25:20] Recv error 10054
[15:25:20] Recv error 10054
[15:25:20] Recv error 10054
[15:25:20] Recv error 10054
[15:25:20] Recv error 10054
[15:25:21] Recv error 10054
[15:25:21] Recv error 10054
[15:25:21] Recv error 10054
[15:25:21] Recv error 10054
[15:25:21] Recv error 10054
[15:25:21] Recv error 10054
[15:25:21] Recv error 10054
[15:25:21] Recv error 10054
[15:25:21] Recv error 10054
[15:25:21] Recv error 10054
[15:25:22] Recv error 10054
[15:25:22] Recv error 10054
[15:25:22] Recv error 10054
[15:25:22] Recv error 10054
[15:25:22] Recv error 10054
[15:25:22] Recv error 10054
[15:25:22] Recv error 10054
[15:25:22] Recv error 10054
[15:25:22] Recv error 10054
[15:25:23] Recv error 10054
[15:25:23] Recv error 10054
[15:25:23] Recv error 10054
[15:25:23] Recv error 10054
[15:25:23] Recv error 10054
[15:25:23] Recv error 10054
[15:25:23] Recv error 10054
[15:25:23] Recv error 10054
[15:25:23] Recv error 10054
[15:25:23] Recv error 10054
[15:25:24] Recv error 10054
[15:25:24] Recv error 10054
[15:25:24] Recv error 10054
[15:25:24] Recv error 10054
[15:25:24] Recv error 10054
[15:25:24] Recv error 10054
[15:25:24] Recv error 10054
[15:25:24] Recv error 10054
[15:25:24] Recv error 10054
[15:25:25] Recv error 10054
[15:25:25] Recv error 10054
[15:25:25] Recv error 10054
[15:25:25] Recv error 10054
[15:25:25] Recv error 10054
[15:25:25] Recv error 10054
[15:25:25] Recv error 10054
[15:25:25] Recv error 10054
[15:25:25] Recv error 10054
[15:25:26] Recv error 10054
[15:25:26] Recv error 10054
[15:25:26] Recv error 10054
[15:25:26] Recv error 10054
[15:25:26] Recv error 10054
[15:25:26] Recv error 10054
[15:25:26] Recv error 10054
[15:25:26] Recv error 10054
[15:25:26] Recv error 10054
[15:25:26] Recv error 10054
[15:25:27] Recv error 10054
[15:25:27] Recv error 10054
[15:25:27] Recv error 10054
[15:25:27] Recv error 10054
[15:25:27] Recv error 10054
[15:25:27] Recv error 10054
[15:25:27] Recv error 10054
[15:25:27] Recv error 10054
[15:25:27] Recv error 10054
[15:25:28] Recv error 10054
[15:25:28] Recv error 10054
[15:25:28] Recv error 10054
[15:25:28] Recv error 10054
[15:25:28] Recv error 10054
[15:25:28] Recv error 10054
[15:25:28] Recv error 10054
[15:25:28] Recv error 10054
[15:25:28] Recv error 10054
[15:25:29] Recv error 10054
[15:25:29] Recv error 10054
[15:25:29] Recv error 10054
[15:25:29] Recv error 10054
[15:25:29] Recv error 10054
[15:25:29] Recv error 10054
[15:25:29] Recv error 10054
[15:25:29] Recv error 10054
[15:25:29] Recv error 10054
[15:25:30] Recv error 10054
[15:25:30] Recv error 10054
[15:25:30] Recv error 10054
[15:25:30] Recv error 10054
[15:25:30] Recv error 10054
[15:25:30] Recv error 10054
[15:25:30] Recv error 10054
[15:25:30] Recv error 10054
[15:25:30] Recv error 10054
[15:25:30] Recv error 10054
[15:25:31] Recv error 10054
[15:25:31] Connection with player 2 lost(Timed out)
[15:27:00] dude has joined
[15:28:11] Recv error 10054
[15:28:11] Recv error 10054
[15:28:11] Recv error 10054
[15:28:11] Recv error 10054
[15:28:11] Recv error 10054
[15:28:11] Recv error 10054
[15:28:11] Recv error 10054
[15:28:11] Recv error 10054
[15:28:12] Recv error 10054
[15:28:12] Recv error 10054
[15:28:12] Recv error 10054
[15:28:12] Recv error 10054
[15:28:12] Recv error 10054
[15:28:12] Recv error 10054
[15:28:12] Recv error 10054
[15:28:12] Recv error 10054
[15:28:12] Recv error 10054
[15:28:12] Recv error 10054
[15:28:13] Recv error 10054
[15:28:13] Recv error 10054
[15:28:13] Recv error 10054
[15:28:13] Recv error 10054
and here is the client log:
Tempest v1.0 Free Release
[15:19:23] Attempting to join...
-----------------Settings-------------------
Name : dude
Local IP Address: 127.0.0.1
Remote IP Address: 127.0.0.1
Local Port: 3998
Remote Port: 3999
---------------------------------------------
Players--------------------------------------
-> dude 127.0.0.1 3998 2 1
-> matt 127.0.0.1 3999 1 0
---------------------------------------------
[15:19:23] Game started
Players--------------------------------------
-> dude 127.0.0.1 3998 2 1
-> matt 127.0.0.1 3999 1 0
---------------------------------------------
Thats everything i could think of, if you need anymore information just let me know.
Thanks