Skip to content

JacobBatson/ChronoArena

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChronoArena

A real-time multiplayer arena game built in Java. Players compete on a grid-based map, capturing zones and collecting items to earn the highest score before time runs out.

Team Members: Jacob Batson, Kaab Dawit, Ben Delton, Thomas Mitropoulos


How to Run

1. Compile

javac -d out src/shared/*.java src/server/GameEngine.java src/server/LobbyPanel.java src/server/ClientHandler.java src/server/ServerMain.java src/client/*.java

2. Start the Server

Run this on one machine:

java -cp out server.ServerMain

A lobby window will open. Players connect first, then the operator sets the duration and clicks Start Game.

3. Connect Clients

Each player runs this on their own machine:

java -cp out client.ClientMain
  • Enter the server's IP address when prompted
  • Enter your player name

All players must be on the same network. Find the server's IP with:

ipconfig getifaddr en0   # macOS
ipconfig                 # Windows

Lobby

When the server starts, a lobby window opens before the game begins.

  • Players connect and their names appear in the lobby list automatically
  • The server operator chooses the game duration (1–10 minutes) using the spinner
  • Once at least one player is connected, the Start Game button becomes active
  • Clicking Start Game starts the countdown and switches the server window to the live game view
  • Players who connect after the game starts will still join mid-game

How to Play

Key Action
WASD or Arrow Keys Move
SPACE Fire Freeze Ray (if you have it)

Game Rules

Goal: Have the highest score when the timer runs out. Game duration is set by the server operator in the lobby (1–10 minutes).

Scoring

Action Points
Own a zone +2 per second (passive)
Pick up Energy item +10 instantly
Freeze an enemy Enemy loses -10

Zones (A, B, C)

  • Walk into a zone and stay to capture it (~3 seconds)
  • Once owned, it drips points into your score automatically
  • If an enemy enters your zone it becomes CONTESTED — no progress either way
  • If you leave your zone, you have a 5-second grace period before losing it
  • An unchallenged enemy in your zone will slowly steal it

Items

Item Color Effect
E — Energy Gold +10 points instantly
F — Freeze Ray Cyan Gives you the freeze weapon
S — Speed Boost Purple Move faster temporarily

Freeze Ray

  • Pick up the F item to arm your freeze ray
  • Press SPACE to fire — freezes the nearest enemy within 2 cells
  • Frozen enemy loses 10 points and cannot move for 3 seconds
  • You lose the weapon after firing (5-second cooldown)

Architecture

┌─────────────────────────────┐
│         SERVER              │
│  ServerMain (entry point)   │
│  LobbyPanel (pre-game UI)   │
│  GameEngine (game loop)     │
│  ClientHandler × N (TCP)    │
│  UDP receiver (actions)     │
└──────────┬──────────────────┘
           │  TCP: GameState broadcast (every tick)
           │  UDP: PlayerAction (move/freeze)
┌──────────┴──────────────────┐
│         CLIENT              │
│  ClientMain (entry point)   │
│  GamePanel (Swing GUI)      │
│  ServerListener (TCP recv)  │
└─────────────────────────────┘
  • TCP — reliable channel: join handshake, game state broadcasts, kill messages
  • UDP — low-latency channel: player movement and actions sent every keypress
  • Game loop — server ticks every 100ms; all actions queued and processed per tick
  • Sequence numbers — UDP packets are deduplicated and ordered to handle network jitter
  • Server authoritative — all game logic runs on the server; clients only render what they receive

Key Files

File Description
src/shared/ Serializable data models shared by client and server
src/server/GameEngine.java Game loop, zone logic, item spawning, scoring, freeze mechanics
src/server/LobbyPanel.java Server lobby UI — shows connected players, sets game duration
src/server/ClientHandler.java Per-client TCP thread — broadcasts GameState each tick
src/server/ServerMain.java Server entry point — TCP accept loop, UDP receiver, kill switch
src/client/GamePanel.java Swing GUI — renders grid, zones, players, items, HUD
src/client/ClientMain.java Client entry point — connects to server, sends UDP actions
src/client/ServerListener.java TCP listener thread — receives GameState and updates GUI

Configuration

Edit config.properties to change server settings:

# Change to the server machine's IP address when playing on multiple computers
server.ip=localhost
server.tcp.port=12345
server.udp.port=12346

Note: Game duration is not set here — it is chosen by the server operator in the lobby before the game starts (1–10 minutes).


Server Kill Switch

While the server is running, type into the server terminal:

kill <playerId> [reason]

Example: kill p1 AFK — forcibly disconnects that player. Player IDs are assigned in join order: p1, p2, p3, etc.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages