Skip to content

AlbinMath/2048-in-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 

Repository files navigation

2048 Game in Java (Swing)

This is a Java Swing-based implementation of the popular 2048 puzzle game. The game uses keyboard controls to slide and combine numbered tiles to reach the number 2048.

๐ŸŽฎ Features

  • Classic 2048 gameplay
  • Smooth tile movement and merging logic
  • Color-coded tiles
  • Keeps track of current and best scores
  • Win (2048) and Game Over detection
  • Option to restart the game using the R key

๐Ÿ–ฅ๏ธ Screenshots

2048 Game Screenshot

๐Ÿ”ง Requirements

  • Java Development Kit (JDK) 8 or later
  • Any Java IDE (e.g., IntelliJ IDEA, Eclipse) or terminal to compile and run

๐Ÿ“ฆ Download and Run

Option 1: Download ZIP

  1. Click the Download ZIP link or clone the repo:

    [git clone https://github.com/AlbinMath/2048-in-java.git]
    cd 2048-in-java
  2. Compile:

    javac Game2048.java
  3. Run:

    java Game2048

Option 2: Run in IDE

  1. Open the .java file in your favorite Java IDE.
  2. Compile and run the Game2048.java file.
  3. Use arrow keys to play.

๐ŸŽฎ Controls

Key Action
Arrow Keys Move tiles
R Restart game
Esc Exit game

๐Ÿ“ File Structure

.
โ”œโ”€โ”€ Game2048.java        # Main Java source file
โ”œโ”€โ”€ README.md            # This file
โ””โ”€โ”€ screenshot.png       # Optional screenshot

๐Ÿ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™Œ Credits

Built with ๐Ÿ’› using Java and Swing.

๐Ÿ“‚ Using this in Your GitHub Repository

To use this project in your GitHub repository:

  1. Create a new GitHub repository (if you haven't already).

  2. Add this project to your GitHub repo:

    git init
    git remote add origin https://github.com/yourusername/2048-java-swing.git
    git add .
    git commit -m "Initial commit - 2048 Java Game"
    git push -u origin main
  3. If you're using SSH key authentication, make sure your key is added to GitHub:

    • Generate key (if you haven't):
      ssh-keygen -t ed25519 -C "your_email@example.com"
    • Add it to the ssh-agent:
      eval "$(ssh-agent -s)"
      ssh-add ~/.ssh/id_ed25519
    • Copy the key and add it to GitHub under Settings > SSH and GPG keys:
      cat ~/.ssh/id_ed25519.pub
  4. Then, push using SSH:

    git remote set-url origin git@github.com:yourusername/2048-java-swing.git
    git push -u origin main

โœ… This makes it easy to collaborate, track changes, and share your 2048 game project publicly or privately using GitHub.

"# 2048-in-java"

About

๐ŸŽฎ A full-featured desktop version of the 2048 Game implemented in Java using Swing. This project includes keyboard control, smooth animations, score tracking, winning/losing messages, and a polished UI. Ideal for Java GUI practice or learning game logic implementation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages