2048

Recommended levellevel
5+
Once upon a time there lived a young Italian named Gabriele Cirulli. He was a student of programming. One day, while doing a coding exercise, he made a breakthrough in the gaming industry entirely by accident. How did he manage to do that? To complete the exercise, he chose to write a game with something similar to an existing puzzle game called "Threes". Gabriele, who named the game "2048", spent two days on its implementation. The game was free and staggeringly successful! Even if you haven't played 2048 yourself, your friends and acquaintances most likely have. Or you've seen people playing it on public transport. Remember those colorful numbered tiles that filled smartphone screens several years back? That's 2048! The game's name isn't random. 2048 is 2 raised to the 11th power. In the game, everything is based on powers of two. The rules are short and sweet: you have a 4x4 board divided into square tiles. A tile with a value of 2 (probability of 90%) or 4 (probability of 10%) appears in each round. All the tiles can be moved to one of the four sides. If two tiles with the same value "collide", they merge and the tile value doubles. The objective is to get a tile whose value is 2048. The player loses if another move is no longer possible. What's so special about the game? First of all, it's very easy to play in a browser or on a smartphone. Let's create our own version of the game right on CodeGym. Who knows? Maybe after doing this you will also accidentally invent your own wildly successful puzzle game? Carry on!
Comments (42)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
17022
Level 23 , Guangzhou, China
4 June, 02:24
有没有game类的代码,继承了game,没看到game在哪
Anonymous #11482420
Level 0 , France
3 March, 09:37



Anonymous #11482420
Level 0 , France
3 March, 09:36


Anonymous #11482420
Level 0 , France
3 March, 09:35
vous parler tous englais ou coi
Anonymous #11388504
Level 2 , Granbury, United States
8 September 2023, 01:32
Part 17 says "I think you long ago noticed the line at the bottom of the game board: "Score: 0"." However there is no score displayed even after I implement the changes.
Anonymous #11138917
Level 2 , China, China
8 September 2023, 10:04
I use ↑↓→, the reaction is different
朱柔蓁
Level 1 , Taiwan
19 August, 04:54
me too, there is no score even i finish the whole game.
Anonymous #11388504
Level 2 , Granbury, United States
7 September 2023, 14:47
Part 3 says "A void createGame() method..." with no indication that it needs to be private.
Anonymous #11138917
Level 2 , China, China
4 September 2023, 09:13
I attempted to run the code, and when I used the "moveUp()" function, the outcomes didn't match my expectations. Consequently, I made some adjustments to my code in an attempt to address the issue correctly. However, even after applying the provided example to solve the problem, the results still didn't align with what I had anticipated. Furthermore, I noticed that the changes made to the two-dimensional array after calling "moveUp" didn't follow the "rotateClockwise()" method as expected, which left me feeling somewhat puzzled. Regrettably, due to space constraints, I'm unable to share my code here. If it's possible, could you please reach out to me via email? I would greatly appreciate any guidance or assistance you can provide. My email address is: moryforcola@outlook.com Thank you very much for your help.
WuYtao
Level 0 , United States
22 August 2023, 17:45
没有初始代码吗
Cute Killer
Level 13 , 浙江, 中国
19 April 2022, 17:09
为什么游戏无法在idea上运行
John Squirrels Website Admin at CodeGym
20 April 2022, 10:51
你遇到什么问题?请你把显示错误的截图发给我。
leonjusinov0070
Level 1 , Germany, Germany
26 February 2022, 12:55
Hallo