http://www.computerc...puzzle-maze-01/
Look in the mutliplayer bit.
There are 2 files.
Make the server then join 2 clients.
Move the 2nd client around.
On the first client you will not see it moving..
But if you move it then its fixed.
This shouldn't happen at all :s
I don't see a reason for it to happen.
Its not because I forget to render it.
Everytime something changes everything is re-rendered and resent.
For the 2nd computer to move, The first must be sent it as well.
Render is not sent to first computer till it moves
Started by libraryaddict, Jul 08 2012 01:51 AM
2 replies to this topic
#1
Posted 08 July 2012 - 01:51 AM
#2
Posted 08 July 2012 - 12:54 PM
The problem is your server
/>
Your moved() function which is called when a client moves only removes the client Char from the old position, doesn't place a new Char at its new position
now reDraw takes care of that though... but not fully, someitmes it would auto-correct itself through pings from what i've seen
But basically
you loop through the clients, you move each client and then send the array to them
so if client 2 moved you removed client 2's character
Loop Start client1
move client 1
send map to client1
Loop start clinet2
move client2
send map to client2
Notice the map you sent to client1 didn't move client2 yet, thus client2 is currently invisible
might fix that: loop throuhg all clients and move them, then send each client the new map
or you might just set the new char at the end of the moved() function already
btw, from moveClients function
function reDraw() -- Used for redrawing all clients into map and sending it out
for n=1,#Clients do
moveClient(n, Clients[n]["X"], Clients[n]["Y"], Clients[n]["Char"])
moveScreen(Clients[n]["ID"], Clients[n]["X"]-(Clients[n]["Wide"]/2), Clients[n]["Y"]-(Clients[n]["High"]/2))
draw(Clients[n]["ID"])
local Cool = {returnView(Clients[n]["ID"])}
rednet.send(Clients[n]["ID"], "draw"..textutils.serialize(Cool))
end
draw("Main")
local G = {returnView("Main")}
for n=1,#G do
term.setCursorPos(1,n)
term.write(G[n])
end
end
Your moved() function which is called when a client moves only removes the client Char from the old position, doesn't place a new Char at its new position
now reDraw takes care of that though... but not fully, someitmes it would auto-correct itself through pings from what i've seen
But basically
you loop through the clients, you move each client and then send the array to them
so if client 2 moved you removed client 2's character
Loop Start client1
move client 1
send map to client1
Loop start clinet2
move client2
send map to client2
Notice the map you sent to client1 didn't move client2 yet, thus client2 is currently invisible
function reDraw() -- Used for redrawing all clients into map and sending it out
for n=1,#Clients do
moveClient(n, Clients[n]["X"], Clients[n]["Y"], Clients[n]["Char"])
end
for n=1,#Clients do
moveScreen(Clients[n]["ID"], Clients[n]["X"]-(Clients[n]["Wide"]/2), Clients[n]["Y"]-(Clients[n]["High"]/2))
draw(Clients[n]["ID"])
local Cool = {returnView(Clients[n]["ID"])}
rednet.send(Clients[n]["ID"], "draw"..textutils.serialize(Cool))
end
draw("Main")
local G = {returnView("Main")}
for n=1,#G do
term.setCursorPos(1,n)
term.write(G[n])
end
end
might fix that: loop throuhg all clients and move them, then send each client the new map
or you might just set the new char at the end of the moved() function already
btw, from moveClients function
if Clients[n]["X"] == Clients[Client]["X"] and Clients[n]["X"] == Clients[Client]["X"] thenseems weird? did you mean "Y" at the latter part?
#3
Posted 08 July 2012 - 02:33 PM
Pinkishu, on 08 July 2012 - 12:54 PM, said:
The problem is your server
/>
Your moved() function which is called when a client moves only removes the client Char from the old position, doesn't place a new Char at its new position
now reDraw takes care of that though... but not fully, someitmes it would auto-correct itself through pings from what i've seen
But basically
you loop through the clients, you move each client and then send the array to them
so if client 2 moved you removed client 2's character
Loop Start client1
move client 1
send map to client1
Loop start clinet2
move client2
send map to client2
Notice the map you sent to client1 didn't move client2 yet, thus client2 is currently invisible
might fix that: loop throuhg all clients and move them, then send each client the new map
or you might just set the new char at the end of the moved() function already
btw, from moveClients function
function reDraw() -- Used for redrawing all clients into map and sending it out
for n=1,#Clients do
moveClient(n, Clients[n]["X"], Clients[n]["Y"], Clients[n]["Char"])
moveScreen(Clients[n]["ID"], Clients[n]["X"]-(Clients[n]["Wide"]/2), Clients[n]["Y"]-(Clients[n]["High"]/2))
draw(Clients[n]["ID"])
local Cool = {returnView(Clients[n]["ID"])}
rednet.send(Clients[n]["ID"], "draw"..textutils.serialize(Cool))
end
draw("Main")
local G = {returnView("Main")}
for n=1,#G do
term.setCursorPos(1,n)
term.write(G[n])
end
end
Your moved() function which is called when a client moves only removes the client Char from the old position, doesn't place a new Char at its new position
now reDraw takes care of that though... but not fully, someitmes it would auto-correct itself through pings from what i've seen
But basically
you loop through the clients, you move each client and then send the array to them
so if client 2 moved you removed client 2's character
Loop Start client1
move client 1
send map to client1
Loop start clinet2
move client2
send map to client2
Notice the map you sent to client1 didn't move client2 yet, thus client2 is currently invisible
function reDraw() -- Used for redrawing all clients into map and sending it out
for n=1,#Clients do
moveClient(n, Clients[n]["X"], Clients[n]["Y"], Clients[n]["Char"])
end
for n=1,#Clients do
moveScreen(Clients[n]["ID"], Clients[n]["X"]-(Clients[n]["Wide"]/2), Clients[n]["Y"]-(Clients[n]["High"]/2))
draw(Clients[n]["ID"])
local Cool = {returnView(Clients[n]["ID"])}
rednet.send(Clients[n]["ID"], "draw"..textutils.serialize(Cool))
end
draw("Main")
local G = {returnView("Main")}
for n=1,#G do
term.setCursorPos(1,n)
term.write(G[n])
end
end
might fix that: loop throuhg all clients and move them, then send each client the new map
or you might just set the new char at the end of the moved() function already
btw, from moveClients function
if Clients[n]["X"] == Clients[Client]["X"] and Clients[n]["X"] == Clients[Client]["X"] thenseems weird? did you mean "Y" at the latter part?
:|
Yet again you solve a brick wall of mine!
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











