Skip to content

sulimu2/tetris-game

Repository files navigation

Tetris Game

Version

Current version: 1.1.0

Creating JAR files

Lightweight JAR (requires external libraries)

./package.sh

Standalone JAR (includes all dependencies)

./package-all.sh

Note on Headless Environments

If you're running this in a headless environment (like a remote server without X11), you'll need to either:

  1. Use X11 forwarding with SSH: ssh -X username@server
  2. Configure a virtual framebuffer: xvfb-run java -jar build/tetris-all.jar
  3. Set up a proper display environment

The game requires a graphical environment to run properly.

A Java SE GUI implementation of the classic Tetris game with user authentication and score tracking using MySQL database.

Features

  1. User authentication (login/register)
  2. Score tracking with high scores saved to MySQL database
  3. Leaderboard showing top 3 players
  4. Classic Tetris gameplay with all 7 tetromino shapes
  5. Controls for movement, rotation, and dropping pieces
  6. Pause/resume functionality
  7. Restart and exit options

Requirements

  • Java 8 or higher
  • MySQL Connector/J (provided in lib directory)
  • X11 display server (for GUI) or proper headless configuration

Database Setup

The application connects to a remote MySQL database with the following configuration:

  • Host: 212.64.21.134
  • Port: 3306
  • Database: tetris
  • Username: root
  • Password: Zdl200212.

You need to create the users table in the tetris database:

CREATE DATABASE IF NOT EXISTS tetris;
USE tetris;

CREATE TABLE users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    username VARCHAR(50) UNIQUE NOT NULL,
    password VARCHAR(50) NOT NULL,
    high_score INT DEFAULT 0
);

How to Run

Run from class files

java -cp "src/main/java:lib/*" tetris.Main

Run the standalone JAR (includes all dependencies)

java -jar build/tetris-all.jar

Run the lightweight JAR (requires lib directory)

java -jar build/tetris.jar

Note: You'll need to have the MySQL Connector/J JAR file in a lib directory. You can build the JAR files using the packaging scripts.

Game Controls

  • Left/Right Arrow Keys: Move piece horizontally
  • Down Arrow Key: Soft drop (move down faster)
  • Up Arrow Key: Rotate piece
  • Space: Hard drop (instantly drop piece)
  • P: Pause/Resume game
  • R: Restart game (when game is over)

Game Elements

  • Score tracking
  • Level progression (speed increases with score)
  • Line clearing with scoring:
    • 1 line: 100 points
    • 2 lines: 300 points
    • 3 lines: 500 points
    • 4 lines: 800 points

Changelog

See CHANGELOG.md for detailed version history.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published