The player doesn't move over a network. I uploaded the zip but here is the code.
global playerID = 3
global netid
global joined = 0
global upbutton = 10
global leftbutton = 20
global rightbutton = 30
global downbutton = 40
global host = 50
global join = 60
global forcex
global forcey
global playerjump = 0
global player = 3
global sprite
playerx = 0
playery = 0
#constant f= 100
WorldSetup()
LoadSprites()
CreateOrJoinNetwork()
//Get rid of the Host and Join buttons
deletesprite (host)
deletesprite (join)
do
moveplayer()
Sync()
loop
function WorldSetup()
// Project: mario
// Created: 2016-07-11
SetVirtualResolution ( 1024,768)
// show all errors
SetErrorMode(2)
CreateSprite ( LoadImage ( "level.png" ) )
// set window properties
SetWindowTitle( "Fighter" )
SetWindowSize( 1024, 768, 0 )
// set display properties
SetVirtualResolution( 1024, 768 )
SetOrientationAllowed( 1, 1, 1, 1 )
//SetPhysicsDebugOn()
SetPhysicsScale(1.0 / 1024.0)
SetPhysicsGravity(0,1000)
endfunction
function LoadSprites()
loadimage (player,"mario.png")
CreateSprite (player,3)
SetSpriteShape ( player, 2)
SetSpritePhysicsOn ( player, 2 )
SetSpriteScale ( player, 0.6, 0.6 )
SetSpritePhysicsRestitution ( player, 0)
SetSpritePhysicsCanRotate( player, 0 )
setspriteposition (player, 30,0)
loadimage (2,"mario2.png")
CreateSprite (2,2)
SetSpriteShape ( 2, 2)
SetSpritePhysicsOn ( 2, 2 )
SetSpriteScale ( 2, 0.6, 0.6 )
SetSpritePhysicsRestitution ( 2, 0 )
SetSpritePosition (2, 0,40)
LoadImage (10,"up.png" )
CreateSprite ( upbutton, 10 )
setspriteposition (upbutton,100,280)
LoadImage (20,"left.png" )
CreateSprite ( leftbutton, 20 )
setspriteposition (leftbutton,20,360)
LoadImage (30,"right.png" )
CreateSprite ( rightbutton, 30 )
setspriteposition (rightbutton,180,360)
LoadImage (40,"down.png" )
CreateSprite ( downbutton, 40 )
setspriteposition (downbutton,100,440)
loadimage (50, "host.png")
createsprite (host,50)
SetSpritePosition (host, 300, 300)
loadimage (60, "join.png")
createsprite (join,60)
SetSpritePosition (join, 500, 300)
endfunction
function moveplayer()
forcex=0
forcey=0
If button(leftbutton) = 1 then forcex = forcex -f
If button(rightbutton) = 1 then forcex = forcex +f
If button(upbutton) = 1 then playerjump = 1
If button(downbutton) = 1 then forcey = forcey +f
// print("force x = "+str(forcex)+" y = "+str(forcey))
SetSpritePhysicsForce(player,GetSpriteXByOffset(player),GetSpriteyByOffset(player),forcex,forcey)
if playerjump = 1
If button(upbutton) = 0
setSpritePhysicsVelocity(player,getSpritePhysicsVelocityX(player),-5*160)
playerjump = 0
endif
endif
endfunction
function CreateOrJoinNetwork()
rem *** Wait for button press ***
repeat
HostOrJoinNetwork()
sync()
until joined = 1
Endfunction
function HostOrJoinNetwork()
If button(host) = 1 and joined <> 1
netid = Hostnetwork("MyNetwork", "Hostmachine",1206)
joined = 1
playerID =2
endif
If button(join) = 1 and joined <> 1
clientname$ = str(getseconds())
netid = joinnetwork ("MyNetwork", clientname$)
joined = 1
playerID =3
endif
endfunction
function SetOwnSpriteDetails()
oldx# = GetSpriteX ( playerID )
oldy# = GetSpriteY ( playerID )
joyx# = getspritex(playerID)
joyy# = getspritey(playerID)
playerx# = joyx# + forcex
playery# = joyy# + forcey
x# = GetSpriteX ( playerID )
y# = GetSpriteY ( playerID )
SetSpritePosition ( playerID, GetSpriteX (playerID ) + ( joyx# / 5.0 ), GetSpriteY ( playerID) + ( joyy# / 5.0 ) )
SetViewOffset ( x# - 50, y# - 50 )
setnetworklocalfloat(netid,"x",playerx#)
setnetworklocalfloat(netid,"y",playery#)
endfunction
function UpdateNetwork()
clientid = getnetworkfirstclient(netid)
while clientid<> 0
playerx# = getnetworkclientfloat(netid,clientid,"x")
playery# = getnetworkclientfloat(netid,clientid,"y")
SetSpritePosition ( clientid+1,playerx#,playery#)
clientid = getnetworknextclient(netid)
endwhile
endfunction
Function button(sprite)
returnValue = 0 `reset value for check
If GetPointerX() > GetSpriteXByOffset( sprite ) - ( GetSpriteWidth( sprite ) / 2 )
If GetPointerX() < GetSpriteXByOffset( sprite ) + ( GetSpriteWidth( sprite ) / 2 )
If GetPointerY() > GetSpriteYByOffset( sprite ) - ( GetSpriteHeight( sprite ) / 2 )
If GetPointerY() < GetSpriteYByOffset( sprite ) + ( GetSpriteHeight( sprite ) / 2 )
If GetPointerState() = 1
returnValue = 1
Endif
Endif
Endif
Endif
Endif
EndFunction returnValue
Thank you for your time.