Skip to main content

A Python implementation of the classic 2048 game

Project description

Py2048 - Terminal 2048 Game

A Python implementation of the classic 2048 puzzle game that runs in your terminal with colorful output!

Features

  • 🎮 Classic 2048 gameplay
  • 🌈 Colorful terminal output
  • ⌨️ Keyboard controls (WASD or arrow keys)
  • 📊 Score tracking
  • 🏆 Win detection (reach 2048!)
  • 💻 Cross-platform (Windows, Mac, Linux)

Installation

pip install py2048-game

How to Play

After installation, start the game with:

py2048
# or
2048

Controls

Key Action
W / ↑ Move Up
S / ↓ Move Down
A / ← Move Left
D / → Move Right
Q Quit
N New Game
H Help

Objective

Combine tiles with the same number to reach 2048!

  • Use arrow keys or WASD to move all tiles
  • When two tiles with the same number touch, they merge into one
  • After each move, a new tile (2 or 4) appears in a random empty spot
  • The game ends when you can't make any more moves

Play in Python

You can also use the game as a library:

from py2048 import Game2048

# Create a new game
game = Game2048()

# Make moves
game.move_up()
game.move_down()
game.move_left()
game.move_right()

# Check game state
print(game.get_score())
print(game.has_won())
print(game.is_game_over())

# Print the grid
print(game)

Screenshots

==============================
         2048 GAME
==============================

+------+------+------+------+
|      |  2   |      |      |
+------+------+------+------+
|      |  4   |  2   |      |
+------+------+------+------+
|  2   |  16  |  4   |  2   |
+------+------+------+------+
|  4   |  32  |  8   |  4   |
+------+------+------+------+

Requirements

  • Python 3.6 or higher

License

MIT License - feel free to use and modify!

Contributing

Contributions are welcome! Feel free to submit issues and pull requests.

Credits

Inspired by the original 2048 game by Gabriele Cirulli.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py2048_terminal-0.1.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py2048_terminal-0.1.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file py2048_terminal-0.1.0.tar.gz.

File metadata

  • Download URL: py2048_terminal-0.1.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for py2048_terminal-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0565e437444abec6e56e71cd1a4317e0b91fc626256f49c4c615eacce57ff370
MD5 1a689c865d11a05dde9162f5f2f5d5a9
BLAKE2b-256 b08a66e47a03b606d8e6d73866446b6d9645b769268872bbe371646b896bb49c

See more details on using hashes here.

File details

Details for the file py2048_terminal-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for py2048_terminal-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9579fcd201105defecc03a55b8872f96bc8d366d7de95bb40a92771928e64c4c
MD5 d445b9eb48b7ac05442c78b09460f01e
BLAKE2b-256 a004c0b5bb8dd1a688e0243507be3f738150df7acbbd7619e28b22c5804420e8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page