MODEDIT Can you please in future make use of the program tags like I have it now
SetVirtualResolution ( 1280, 800 )
setphysicsscale(1) //belongs resolution! default 1 unit = 1 meter
SetPhysicsGravity(0 , 0)
LoadImage ( 1, "red.png" )
LoadImage ( 2, "red.png" )
LoadImage ( 3, "feild1.jpg" )
loadimage (4, "ball.png")
CreateSprite ( 3, 3 )
CreateSprite (20,4)
SetSpritePositionByOffset(20,300,300)
CreateSprite ( 11, 1 )
SetSpritePosition ( 11, 100, 200 )
CreateSprite ( 12, 2 )
SetSpritePosition ( 12, 350, 200 )
SetSpritePhysicsOn (12,2)
SetSpriteDepth(12,0)
SetSpritePhysicsCanRotate (12,0)
SetSpritePhysicsMass (12,60)
setspritephysicsisbullet(12,1)
SetSpritePhysicsFriction(12,0.1)
SetSpritePhysicsRestitution(12,0.25)
SetSpritePhysicsDamping(12,0.25)
SetSpritePhysicsOn (11,2)
SetSpriteDepth(11,0)
SetSpritePhysicsCanRotate (11,0)
SetSpritePhysicsMass (11,60)
setspritephysicsisbullet(11,1)
SetSpritePhysicsFriction(11,0.1)
SetSpritePhysicsRestitution(11,0.25)
SetSpritePhysicsDamping(11,0.25)
SetSpritePhysicsOn (20,2)
SetSpriteShape(20,1)
SetSpritePhysicsCanRotate(20,1)
SetSpritePhysicsIsBullet(20,1)
SetSpritePhysicsMass(20,1.000000)
SetSpritePhysicsFriction(20,0.349000)
// set some variables
State = 0
iType = 0
NetworkID = 0
// main loop
do
if State = 0
Print ( "Select green square to host a game" )
Print ( "Select red square to join a game" )
if GetPointerPressed ( ) = 1
hit = GetSpriteHit ( GetPointerX ( ), GetPointerY ( ) )
if ( hit = 11 )
NetworkID = HostNetwork ( "AGK Test Game", "Player 1", 4025 )
iType = 1
State = 1
localSprite = 11
remoteSprite = 12
endif
if ( hit = 12 )
randomplayername$="player"+str(random(1,10000))
NetworkID = JoinNetwork ( "AGK Test Game", randomplayername$ )
iType = 2
State = 1
localSprite = 12
remoteSprite = 11
endif
randomplayername$="player"+str(random(1,10000))
NetworkID = JoinNetwork ( "AGK Test Game", randomplayername$ )
ballSprite = 20
endif
endif
// in game
if State = 1 and NetworkID = 0 then print ("Network connection failed")
if State = 1 and NetworkID > 0
for activity=1 to activitycount
// printc(".")
next activity
inc activitycount
if activitycount>10 then activitycount=0
if IsNetworkActive ( NetworkID ) <> 0
id = GetNetworkFirstClient ( NetworkID )
while id <> 0
Print ( GetNetworkClientName ( NetworkID, id ) )
id = GetNetworkNextClient ( NetworkID )
endwhile
if GetPointerPressed ( ) = 1
x = GetPointerX ( )
y = GetPointerY ( )
if ( move = 0 )
move = 1
originalX# = GetSpriteX ( localSprite)
originalY# = GetSpriteY ( localSprite )
destinationX# = x
destinationY# = y
distanceX# = destinationX# - originalX#
distanceY# = destinationY# - originalY#
distanceFromAtoB# = sqrt ( ( distanceX# * distanceX# ) + ( distanceY# * distanceY# ) )
if ( distanceFromAtoB# <> 0.0 )
directionX# = distanceX# / distanceFromAtoB#
directionY# = distanceY# / distanceFromAtoB#
endif
endif
endif
if ( move > 0 )
newX# = originalX# + directionX# * move
newY# = originalY# + directionY# * move
if ( move < distanceFromAtoB# )
move = move + 15
else
move = 0
endif
SetSpritePosition ( localSprite, newX#, newY# )
endif
` this 2 line was missing -----
if iType=1 ` If Host
x3#=GetSpriteXByOffset(20)
y3#=GetSpriteYByOffset(20)
endif
cmessage = CreateNetworkMessage ( )
AddNetworkMessageFloat ( cmessage, newX#)
AddNetworkMessageFloat ( cmessage, newY# )
if iType=1 ` If Host
AddNetworkMessageFloat ( cmessage, x3#)
AddNetworkMessageFloat ( cmessage, y3# )
endif
SendNetworkMessage ( NetworkID, 0, cmessage )
dmessage = GetNetworkMessage ( NetworkID )
while dmessage <> 0
x2# = GetNetworkMessageFloat ( dmessage )
y2# = GetNetworkMessageFloat ( dmessage )
SetSpritePosition ( remoteSprite, x2#, y2# )
if iType=2 `If Client
x3# = GetNetworkMessageFloat ( dmessage )
y3# = GetNetworkMessageFloat ( dmessage )
SetSpritePosition ( 20, x3#, y3# )
endif
DeleteNetworkMessage ( dmessage )
dmessage = GetNetworkMessage ( NetworkID )
endwhile
endif
endif
Sync ( )
loop
`=======================================================
remstart
You coding wrong .
I correct it . copy and past to your code and run
remend