GithubHelp home page GithubHelp logo

shahpranshu27 / 2048_game Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 4 KB

The goal of the 2048 game is to combine tiles on a 4x4 grid to reach the tile with the number 2048

Jupyter Notebook 100.00%

2048_game's Introduction

#2048 game - Python (Tkinter)

Objective: The goal of the 2048 game is to combine tiles on a 4x4 grid to reach the tile with the number 2048.

Components:

-> Grid: The game is played on a 4x4 grid, where each cell can contain a tile with a number. -> Tiles: Tiles have numbers on them, initially starting with two random tiles with values 2 or 4. -> Movement: The player can use arrow keys (Up, Down, Left, Right) to move the tiles on the grid.

Game Logic:

-> When the player presses an arrow key, the tiles on the grid are moved in that direction. -> Tiles with the same number merge when they collide, doubling the value. -> After each move, a new tile with a value of 2 or 4 appears in an empty random cell. -> The game continues until the player wins (reaching 2048) or loses (no valid moves left).

Code Explanation:

-> The code defines a Board class that sets up the game's graphical interface using Tkinter. -> Tiles are represented as labels with appropriate colors and fonts. -> The Game class handles the game's logic, including random tile generation, tile movement, merging, and checking for win/loss conditions. -> The game is controlled using arrow keys, and the GUI is updated to reflect the game state. -> If the player reaches 2048, they win the game, and if there are no valid moves left, the game ends.

This code can be used as a starting point for creating a 2048 game in Python with Tkinter. You can enhance it by adding features like a score counter, a restart button, and animations for a better gaming experience.

2048_game's People

Contributors

shahpranshu27 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.