A Java racing-game project developed in three stages, progressing from Swing-based animation to local two-player gameplay and finally to TCP client-server multiplayer.
The repository is preserved as an earlier engineering project and is structured to show how the application evolved as new requirements were introduced.
The first stage focuses on graphical rendering and animation with Java Swing.
Two car sprites are displayed in a JFrame/JPanel interface and rotated through 16 directional images in 22.5-degree increments. A Swing Timer drives repeated repainting of the panel.
Key concepts:
- Java Swing
JFrameandJPanel- sprite-based rendering
- timer-driven animation
- resource loading
The second stage develops the animation prototype into a complete local two-player racing game.
It introduces:
- keyboard-controlled movement for two cars;
- speed and direction state;
- track boundaries and collision handling;
- car-to-car collision detection;
- sequential checkpoints and race completion;
- engine, crash, win and loss audio;
- a dedicated game-update thread;
- on-screen controls and speed information.
The red car and yellow car are controlled independently from the same keyboard.
The final stage restructures the game into separate Client, Server and Shared packages and introduces multiplayer communication over TCP.
Two client instances connect to a server running on localhost:4000. The server assigns each client a car, waits for both players to be ready and exchanges serialised Car objects so that each client can maintain the opponent's latest state.
The multiplayer implementation includes:
- TCP sockets;
- client/server architecture;
- per-client server handlers;
- Java threads;
- object serialisation;
- shared game models and configuration;
- synchronisation of player state;
- a waiting lobby before both clients are ready.
Part 1/
└── RacingGame/
└── src/ Swing animation prototype
Part 2/
└── RacingGame/
└── src/ Local two-player racing game
Part 3/
└── RacingGame/
└── src/
├── Client/
├── Server/
└── Shared/
The three parts are intentionally retained to show the progression of the implementation rather than only the final state.
- Java
- Java Swing
- TCP sockets
- client-server architecture
- multithreading
- Java object serialisation
- event-driven input
- collision detection
- sprite animation
- audio playback
- object-oriented design
The project uses the Java standard library and does not depend on third-party libraries.
From Part 1/RacingGame/src:
javac *.java
java MainFrom Part 2/RacingGame/src:
javac *.java
java MainLocal controls:
| Car | Turn left | Turn right | Increase speed | Decrease speed |
|---|---|---|---|---|
| Red | W |
S |
Q |
A |
| Yellow | O |
K |
P |
L |
From Part 3/RacingGame/src, compile the source:
javac Client/*.java Server/*.java Shared/*.javaThen start the server:
java Server.TCPServerOpen two additional terminals and start one client in each:
java Client.TCPClientEach client controls its own car with:
W— turn leftS— turn rightQ— increase speedA— decrease speed
The multiplayer implementation currently expects the server to run on localhost using TCP port 4000.
This is an earlier Java project preserved as part of my public engineering portfolio.
Its main value is the progression from a small GUI and animation exercise into a stateful game and then into a networked client-server application. The final version combines user-interface programming, game-state management, concurrency, serialisation and socket communication within one project.