Skip to content

This repository contains full tetris game implementation in Java swing and awt.

Notifications You must be signed in to change notification settings

Hasnatrasool163/Tetris-in-Java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java Tetris Game

This Tetris game is developed using Java's Swing and AWT libraries, offering a classic gaming experience with modern coding practices. The game features the traditional Tetris gameplay, including 7 different tetrominoes, with additional features such as pause, score tracking, line clearing, level progression, collision detection, and background music to enhance the playing experience.

Features

  • 7 Tetrominoes (Minos): Includes all classic Tetris blocks.
  • Game Controls: Easy-to-use keyboard controls for moving, rotating, and dropping tetrominoes.
  • Line Clearing: Complete lines to clear them from the board and earn points.
  • Levels: The game speed increases as you progress, offering a challenging experience.
  • Score System: Earn points by clearing lines and advancing through levels.
  • Pause/Resume: Players can pause the game at any moment and resume where they left off.
  • Collision Detection: Ensures a realistic gameplay experience.
  • Music and Sound Effects: Enhances gameplay with engaging audio.

ScreenShots

Screenshot (813)

Getting Started

Prerequisites

Ensure you have Java Development Kit (JDK) installed on your machine to run and compile the game. The game is developed and tested with JDK version 21.

Installation

  1. Clone the repository to your local machine using Git:

    git clone https://github.com/hasnatrasool163/Tetris-in-Java.git
  2. Navigate to the cloned directory:

    cd java-tetris-game
  3. Compile the Java files. For example, if your main class is in tetris.Game, you would run:

    javac tetris/Game.java
    javac Main.java
  4. Run the game:

    java tetris.Game
    java Main

How to Play

  • Move Left: Arrow key left /A
  • Move Right: Arrow key right / D
  • Rotate: Up arrow key / W
  • Drop: Down arrow key / S
  • Pause/Resume Game: Press 'SpaceBar'

The objective is to place the tetrominoes to create complete lines, which will then be cleared from the board. The game ends when the Tetris playfield is filled.

Built With

  • Java - The programming language used
  • Swing and AWT - Used for the GUI components

Authors

  • Muhammad Hasnat Rasool - Initial work - YourGitHub

Acknowledgments

  • Hat tip to anyone whose code was used
  • Inspiration
  • etc