BallDropGame

GitHub Pages Site

Home
Serial Client
Processing Client
WiFi Client
Ethernet Client

This project is maintained by tigoe

Ball Drop Game

A game to demonstrate TCP sockets

This is a multiplayer game in which players collaborate to keep a ball from hitting the ground. Each player has a paddle, and can bound the ball off her paddle. When the ball bounces off your paddle, you get a point. Only the first bounce counts, though; subsequent bounces don’t get you points. But if the ball bounces off another player’s paddle then back to yours, you score again. You can keep scoring forever by bouncing the ball back and forth.

Here’s a video of the game in action.

The game is a networked application. Players log in by making a TCP socket connection to the IP address of the computer on which the game is running. For example, if the game is running on a computer with the IP address 192.168.0.2, then you’d make a connection to 192.168.0.2 port 8080, and you’d be connected.

The simplest connection you can make to the game is via a command line interface, using netcat, like so:

$ nc 192.168.0.2 8080

The game itself, BallDropServer, is written in Processing, so you’ll need to download the Processing IDE in order to run it, or have someone run it for you (and tell you their IP address).

Clients

The game clients can be written in any programming environment, and for any hardware you wish, as long as your environment can connect to a network and make a TCP socket connection. I’ve written clients for a few platforms below:

Communication Protocol

When a client connects to the server, the server will send back a greeting and the instructions for controlling a paddle, as follows:

Key commands:
w: up, a: left, s: down, d: right
x: exit
h: print these instructions to client
i: toggle name/IP address
=xxxx\n : set name to xxxx
1 point for each time the ball hits a new paddle
(minimum 2 players)

The client can then send the following commands:

Game Play

The game starts when the first new player logs in. Balls will drop from the top of the screen, and remain in play until they reach the bottom of the screen. To score the most points, bounce the ball off as many paddles as you can.

The goal is to get the highest collective score.

The game ends when five balls have dropped. When the game is over, the group’s scores will be displayed.

The game in its current version does not send the player any information about the ball or the state of the other players. In order to play the game, you have to be physically present to view the screen of the computer on which the game is running.

High Score Table

Rank Section & Class Score
1 Section 2, Fall 2024 1894
N/A