Forum C# Pong ball.

Pong ball.

Postby koekwaus21 » April 23rd, 2010, 1:42 pm

Hello developers!

To learn more about playerio and how to make multiplayer games, im working with a Pong game.
Now i have it allmost working, i just need a moving ball. i tried some things but i can't get it working.


Can somebody tells me how i do this correctly (server-side and Client-side)?

i came this far: http://www.jscreations.nl/stage/playerio/pong/Pong_multi.html

Press Space to ready up.
When everybody is ready, will be a count down and the game will start.

Thanks,
koekwaus21
 
Posts: 1
Joined: April 1st, 2010, 1:47 pm

Re: Pong ball.

Postby fox1980 » April 26th, 2010, 3:44 pm

For such a small game and simple game you could get away with the clients calculating stuff, and sending results to the server for broadcast, but i will assume you're learning how to do it in a secure way that can't be hacked. So if i was you i would check in the client if the ball hit the bat, and then send the info that it hit, wich player bat it hit, and the collision coordinates to the server.

like:

Code: Select all
_connection.send("HIT","player1",100,20);


the server would calculate the according path the ball should take now and send it back to both clients. the info should contain the impact point and the destination point so clients can tween the ball between those coordinates.

something like:

Code: Select all
Broadcast("HITResult",100,20,200,40);


This is a quick and dirty solution and has flaws, but the point is: if you want an unhackable game, calculate everything server side. Clients send movement info, but the server should check if the move is valid, if the impact points the clients are reporting are valid, and be the one to take the decision. For example, in that game it's impossible for the same player to hit the ball 2 times in a row, before the ball hits a wall or the other player bat, so if the server get's some info like that it means either the player is cheating or there is a bug in your code.
fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm


Return to C#



cron