Update paddle position on 2nd client

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
uberSamji
Prole
Posts: 3
Joined: Tue Aug 19, 2014 3:33 pm

Update paddle position on 2nd client

Post 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
Attachments
Pong2.love
Second client
(12.14 KiB) Downloaded 103 times
Pong1.love
First client
(12.14 KiB) Downloaded 105 times
PongServer.zip
The server
(1.67 KiB) Downloaded 100 times
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 54 guests