Page 1 of 1

Update paddle position on 2nd client

Posted: Sat Sep 06, 2014 11:16 am
by uberSamji
Hi.

I am trying to add network play to my Pong game. I have a server which listens for position commands for a paddle over UDP. As the first paddle (paddle1) is moved in Pong 1, a clone paddle (netpaddle1), receives the co-ordinates of paddle1 to set its position in Pong game 2. The co-ordinates are transmitted to the server okay when paddle 1 is moved in Pong game 1, however, the paddle position is not updated in Pong game 2. I know I have done something fundamentally wrong, so I've attached both clients and the server for you guys to look at. Any guidance would be great. Thanks.

Pong game 1:

Code: Select all

function love.update(dt)
  paddle1:update(dt)
  client:transmitPaddle(paddle1)
  netPaddle1:setPos(client:receive())
end
Pong game 2:

Code: Select all

 
function love.draw()
  paddle2:draw()
  netPaddle1:draw()
end