jQuery-only working game like “Threes” (or “1024”, or “2048”, or…)

Emanuele Feronato Game design, Javascript

Did you play Threes or one of its “inspired-by” games like 1024 or 2048?

There is a grid filled with numbers, and you have to make them slide up, down, left and right. If two numbers with the same value get in touch, they merge into a new number which is the sum of previous number.

Have a look at the free 2048 game to see what I mean.

Here you will find a jQuery only version of 2048 using only sliding «div»s to make it work – I did not even use an array to store grid information – with only a different way to calculate the score and the “combo” feature: placing three “two”s in a row won’t give you a “4” and a “2” but an “8”. A smart way to quickly get higher numbers.

Try the game:

Slide numbers with WASD keys. What’s your best score?

And this is the jQuery only source code:

I did not include any comment because a jQuery only game is just an exercise. Soon I will show you how to make an HTML5 version of the game with some popular framework, and you’ll get commented code.

Meanwhile you can download the source code of the game.

Comments 9

  1. Pingback: Game 2048 « Jogos, Quebra-Cabe├žas, Tutoriais para Games – WacaWaca

  2. PlayGB

    Very good, thanks for sharing the source code, but I have a question. If I develop HTML5 or jQuery games, they can stole my source code and modify the game, right? Is there a way to protect the code and resources?

  3. Pingback: Best of JavaScript, HTML & CSS – Week of March 24, 2014 | Flippin' Awesome

  4. Pingback: How to create a complete HTML5 “2048″ game with Phaser - Emanuele Feronato

Leave a Reply

Your email address will not be published. Required fields are marked *