Skip to content
/ 2048 Public
forked from kubowania/2048

A game of 2048 in vanilla javaScript, HTML and CSS

Notifications You must be signed in to change notification settings

bobrecio/2048

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

2048

A game of 2048 in vanilla JavaScript, HTML and CSS

In this walkthrough, we make the very popular game 2048 in JavaScript, HTML and CSS! No canvas required! (Now with more accurate subtitles for programmers)

Full video walkthrough here

Rules of 2048:

2048 is played on a 4×4 grid, with numbered tiles that slide smoothly when a player moves them using the four arrow keys. Each time you slide, a new tile will randomly appear in an empty spot on the board. Tiles slide as far as possible in the chosen direction until they are stopped by either another tile or the edge of the grid. If two tiles of the same number collide while moving, they will merge into a tile with the total value of the two tiles that collided. The resulting tile cannot merge with another tile again in the same move.

Tools and Software I used in this video:

By creating this popular game we will learn the following javaScript Methods:

  • querySelector()
  • getElementById()
  • createElement()
  • appendChild()
  • push()
  • Math.floor()
  • Math.random()
  • length
  • innerHTML
  • parseInt()
  • filter()
  • Array()
  • fill()
  • concat()
  • keyCode
  • addEventListener()
  • removeEventListener()
  • setTimeout()
  • clearInterval()
  • setInterval()

If you did like this video, please do Like and Subscribe so I know to make others like this!

I would love to see what you have made so please do share your finished games with me on twitter! My handle is @ania_kubow.

MIT Licence

Copyright (c) 2020 Ania Kubow

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

*Translation: Ofcourse you can use this for you project! Just make sure to say where you got this from :)

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

A game of 2048 in vanilla javaScript, HTML and CSS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 82.7%
  • CSS 10.7%
  • HTML 6.6%