Game2048

2048 game based on native JavaScript, HTML and CSS

Skills:
Game2048

How to play 2048

As with other 2048 games, the movement of numbers is controlled by the arrow keys on the keyboard, and the squares of the same number are merged until the number of 2048 appears.

Code Features

  • 2048 game based on native JavaScript, HTML and CSS.
  • All elements are generated by JavaScript without external references, such as images.
  • Trigger JavaScript functions by listening for keyboard events(keydown) to process DOM elements that display numbers for different key orientations.
  • Through the monitoring of numbers in the game, combined with CSS to achieve digital movement and animation.
  • Use global parameters to determine whether user operations are effective and maintain the stability of web pages.
  • Use localStorage to store the game progress, and the user can continue to play from the last progress next time.