Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[oft] how 2 code 2 player pong over a network

19 views
Skip to first unread message

fir

unread,
Dec 6, 2017, 12:23:28 PM12/6/17
to
recently i run some test with my friend girl assistant koteq/cybergoth

the test app was 2 dots in window one i move with mouse other my assistant move and the other-person coordinates was sent per frame (via tcp socket)

i think i would like to make some kind of peer-to-peer pong game (two paddles and one ball) but the problem may be i guess the delay betwean sending and incoming packets

(i know what i ask is basic in network programming vut i never was coding it so i think i must rethink those basics and overall it is/should be interesting for every c programmer that want to touch a network at all)

i guess the typical pessymistic delay
between a time of sending and time of receiving may be 100 (200?) ms ..
if game is moderatelly dynamic i think the element like paddle or ball may move with speed of one screen width/height a second so the difference in a position then could be
1/10 or 1/5 of size of screen

right now i got no idea how to make simple code for that game that would minimalize the inpact of this deley
to players

how to code that?

should i code it in some symmetric way
make the delay be halved on two players or what?

bitrex

unread,
Dec 6, 2017, 4:57:05 PM12/6/17
to
You have to use some kind of client-side prediction; the two clients
can't be expected to be hard-synced to each other. That is to say the
packets being exchanged aren't used for a direct update of the paddle on
the other player's screen, but more as verification that what the other
client is doing already is correct.

References:

<https://en.wikipedia.org/wiki/Client-side_prediction>

<https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking>
0 new messages