Giter Site home page Giter Site logo

2048's Introduction

2048

https://2048-azure.vercel.app/

Overview

This is a super high level and shallow documentation.

This game is composed by two main data-structures, the Board and a Record of Tiles. The board will keep a snapshot of all tiles in the game (empty, obstacle, and tile). while the Record of tiles contains all the actual tiles' data indexed by id.

The record of tiles might seem redundant, but it was needed to allow me to animate a moving tile. When a tile is merged we update the value of the target tile and just update the position on the origin tile, this will allows me to keep the target tile in place with the new value while the origin tile is animated into the new position.

To move blocks we break the board into ranges where the tiles are free to move, ie. free of obstacles, and then merge them back into the board structure.

Move

A few future improvements

  1. Cleanup unnecessary tiles after movement - the record of tiles is holding to the tiles for longer than necessary
  2. Responsive layout - right now the size of tiles is fixed
  3. Improve logic to trigger defeat - if we start a 4x4 grid with 15 obstacles, we're not able to tell the user they lost because we only check for defeat after a movement.
  4. Way more tests!
  5. Better colors for dark mode.
  6. Better obstacle asset
  7. Add proper linting and formatting tools.

2048's People

Contributors

canastro 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.