Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🕹️ Multiplayer Square Tag

A Real-Time Multi-threaded Networked Game


📖 Project Overview

This project is a real-time, multiplayer networked game developed for the Network Programming module. It demonstrates high-performance synchronization of game states across multiple hosts using a robust Client-Server architecture.


🛠️ Technical Features

1. Multi-threaded Server Architecture

The server utilizes a dedicated ClientHandler thread for every connected user. This ensures:

  • Non-blocking Communication: The server can process inputs from Player A without making Player B wait.
  • High Responsiveness: Actions are processed in parallel, maintaining a "real-time" feel.

2. TCP/IP Socket Programming

We utilize Java's ServerSocket and Socket libraries.

  • Reliability: Uses the TCP protocol to ensure no "move" packets are lost or arrive out of order.
  • Stream-Based: Data is transmitted efficiently through PrintWriter and BufferedReader.

3. Custom Sync Protocol

The game uses a lightweight, custom messaging protocol to minimize latency:

  • MOVE:dx,dy → Client informs server of movement intent.
  • UPDATE:ID:X:Y → Server broadcasts the new "Source of Truth" to all clients.

4. Swing GUI & Background Rendering

A responsive front-end built with Java Swing that separates concerns:

  • Event Thread: Handles key presses and UI rendering.
  • Network Thread: Runs in the background to listen for server updates without "freezing" the window.

📋 Module Compliance

Requirement Implementation Status
Unique Title Multiplayer Square Tag
Thread Usage Implemented on both Server (Client Handlers) and Client (Network Listener)
Multi-host Tested across multiple devices using local IPv4 addressing
No Libraries Built using 100% standard Java SE libraries (java.net, java.io, java.awt)

🚀 How to Run

Prerequisites

  • Java JDK 8 or higher installed.

Execution Steps

  1. Start the Server: Run GameServer.java. The console will display: Game Server started on port 5000.
  2. Launch Clients: Run GameClient.java on one or more machines.
    • Note: For multi-host play, replace "localhost" in the code with the Server's IPv4 address (e.g., 192.168.8.x).
  3. Controls: Use the Arrow Keys to move your square.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages