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_cli_game-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_cli_game-0.1.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py2048_cli_game-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_cli_game-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dc92cce11ad546952848e63b0fd2ea5510dd4e4712379a55d58a898e9b1091e6
MD5 33763a7590873648463822d5ccb7bd14
BLAKE2b-256 fdc2639137f678d5b2424405a25c2f17860762b8fa45031dc5780747f2d3115a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for py2048_cli_game-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cb8742cf365e22e64c0fb1940a90645c3b9e568a12b211c98a27fd99839c1bcf
MD5 b455c18f32daf8606bf9828275a555b6
BLAKE2b-256 68c0da03b3342d1a13040b507954f7e1f8d29804adbc9e5c21d0e3ad7abf4ad1

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