Thanks to visit codestin.com
Credit goes to github.com

Skip to content

rakeebh7233/JavaPong

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🏓 Java Multiplayer Pong

A multiplayer Pong game built in Java with Swing GUI and a MariaDB/MySQL backend for tracking scores and maintaining a leaderboard.


✨ Features

  • 🎮 Two-player multiplayer Pong over a TCP socket connection
  • 🖥️ Swing GUI for login, waiting room, game, and end screen
  • 🏆 Leaderboard stored in a MariaDB database
  • 📊 Tracks wins/losses per player
  • ⏱️ Real-time paddle & ball synchronization via client-server messaging

🗂️ Project Structure

JavaPong/
├── JavaProjectClient/src/javaprojectclient
| ├── Ball.java # Ball movement
│ ├── GameGUI.java # Game screen + rendering + client networking
│ ├── JavaProjectClient.java # Client entry point (login + waiting room)
| ├── Paddle.java
| ├── Score.java
├── JavaProjectServer/src/javaprojectserver
│ ├── JavaProjectServer.java # Server (game coordinator + DB integration)
└── README.md # Project documentation

⚙️ Requirements

  • Java JDK 8+
  • MariaDB/MySQL running locally on port 3306
  • Database named JPong with a table Leaderboard

Database Schema

CREATE DATABASE JPong;

USE JPong;

CREATE TABLE Leaderboard (
    username VARCHAR(50) PRIMARY KEY,
    numWins INT DEFAULT 0,
    numLoss INT DEFAULT 0
);

🚀 How to run

🔧 Configuration

The server currently connects to:

private static final String URL = "jdbc:mariadb://localhost:3306/JPong";
private static final String USERNAME = "root";
private static final String PASSWORD = "1234";

👉 Update these in JavaProjectServer.java to match your database credentials.

1️⃣ Start the Server

cd javaprojectserver
javac JavaProjectServer.java
java javaprojectserver.JavaProjectServer

2️⃣ Start the Clients

Open two terminals (or machines) and run:

cd javaprojectclient
javac JavaProjectClient.java GameGUI.java
java javaprojectclient.JavaProjectClient

3️⃣ Connect

  • Enter a username and the server IP (e.g., localhost) in the login screen.
  • First player will wait in the Waiting Room until Player 2 joins.
  • Once connected, the game starts automatically.

🎮 Controls

  • ⬆️ Arrow Up → Move paddle up
  • ⬇️ Arrow Down → Move paddle down

📊 Leaderboard

At the end of each game:

  • Winner’s win count is incremented.
  • Loser’s loss count is incremented.
  • The updated leaderboard is displayed in the End Screen.

👨‍💻 Authors

  • Nihal Rahman
  • Rakeeb Hossain

About

Java Multiplayer Pong game w/ networking and MySQL for persistent leaderboard tracking.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages