Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hasnatrasool163/tetris-in-java

This repository contains full tetris game implementation in Java swing and awt.
https://github.com/hasnatrasool163/tetris-in-java

awt-gui java javaawt javaswing javaswingsapp swing-gui tetris tetris-clone tetris-game tetrisgame

Last synced: about 1 month ago
JSON representation

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

Awesome Lists containing this project

README

        

# 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)](https://github.com/Hasnatrasool163/Tetris-in-Java/assets/153990457/805291a0-b07b-4f75-bad6-b0fa70fda65d)

## 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:

```bash
git clone https://github.com/hasnatrasool163/Tetris-in-Java.git
```

2. Navigate to the cloned directory:

```bash
cd java-tetris-game
```

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

```bash
javac tetris/Game.java
javac Main.java
```

4. Run the game:

```bash
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](https://www.java.com/) - The programming language used
- [Swing](https://docs.oracle.com/javase/tutorial/uiswing/) and [AWT](https://docs.oracle.com/javase/tutorial/awt/) - Used for the GUI components

## Authors

- Muhammad Hasnat Rasool - *Initial work* - [YourGitHub](https://github.com/hasnatrasool163)

## Acknowledgments

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