Coder Social home page Coder Social logo

vlkzmn / 2048_game Goto Github PK

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

My version of the game 2048. The game is implemented for both the desktop version and mobile devices. The playing field can be moved using the arrow keys on the keyboard or by swiping on the screen.

Home Page: https://vlkzmn.github.io/2048_game/

License: GNU General Public License v3.0

JavaScript 50.08% HTML 19.95% SCSS 29.97%

2048_game's Introduction

2048 game

My version of the game 2048. The game is implemented for both the desktop version and mobile devices. The playing field can be moved using the arrow keys on the keyboard or by swiping on the screen.

Technologies used

  • HTML5
  • CSS3
  • Sass (SCSS)
  • JavaScript

Game logic

  • The game field is 4 x 4 (16 cells), but it can be easily changed to any size in code
  • Each cell can be empty or contain one of the numbers: 2, 4, 8 ... 2^n
  • The game starts with 2 cells filled with 2 or 4
  • The game can be started by clicking the Start button
  • The player can move cells with keyboard arrows or swipe in screen
  • All the numbers are moved in the selected direction until all empty cells are filled in
    • 2 equal cells are merged into a doubled number
    • The merged cell can’t be merged twice during one move
  • The move is possible if at least one cell is changed after the move
  • After move 2 or 4 appears in a random empty cell. 4 probability is 10%
  • When 2048 value is displayed in any cell, win message will be shown.
  • The game over message will be shown if there are no more available moves.
  • Score is increased by the sum of all merged cells.
  • The game can be restarted by clicking the Restart button.

How to run the project locally

  • Fork and clone this repository
  • Run npm install in your terminal
  • Run npm start in your terminal to start the project locally

Reflections

The main goal of this project was to practice JavaScript and DOM manipulations and combine JavaScript with HTML and CSS.

The main task was to implement game logic and the ability to switch with a swipe. I had to think through all possible scenarios and ways to implement them.

Eventually I practiced in building more complex logic using knowledge I have gained so far until this point.

This project is inspired by original 2048 game

2048_game's People

Contributors

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