Recommended levellevel
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!
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Agent SmithLevel 24 , Riga
3 hours ago
Nice and fun way to practice multidimensional arrays. 👨‍💻
MaxLevel 16 , Hamburg
13 September, 14:34
I'm having problems with part 15 of this. I have implemented the gameOver() method and call it as described in the conditions, but the condition "The onKeyPress(Key) method must call the gameOver() method and do nothing else, if the canUserMove() method returns false" fails with the recommendation "Be sure that the onKeyPress(Key) method ends immediately after the call to the gameOver() method". The relevant code in the onKeyPress(Key) method:
if (getMaxTileValue() == 2048) {
        else if (!canUserMove()) {
after the
else if (!canUserMove())
, I am calling one of the methods that moves the gameField, as described in an earlier lesson. Can someone help me solve it?
DyritsLevel 18 , Die
31 July, 09:23
Why can't I publish it ?
AlexLevel 41
3 August, 13:35
Can you run the game without any issues? Do you get any errors when trying to publish the game? Please submit a question, with your code included, in the Help section.
DyritsLevel 18 , Die
4 August, 08:29
I can run the game, but can't publish it. APP_PUBLISH_ERROR: Task wasn't published. Publish result is unknown. I've already created a post in the help section.
AlexLevel 41
4 August, 12:35
There's no code or any information in your question (Help section) which might help us figure out why this happens. Are you able to add your entire code to your question in the Help section? Or have you already fully verified all parts of the game and cannot attach it?
DyritsLevel 18 , Die
5 August, 10:14
I've already verified every part of the game. But I will update my post with the code.
Rithik BhatLevel 7 , Hartford
23 June, 23:42
Hi, for the last task when I try to run and publish my code it gives an error saying app_publish_error. I don't know why it is doing this. Can someone please help? Thank you.
davinLevel 1 , Panama City
24 April, 15:57
28 December 2019, 16:06
I am getting an error that the initialize method is not calling setScreenSize(SIDE, SIDE). But I am? Help
    public void initialize() {
        setScreenSize(SIDE, SIDE);
Au IvanLevel 17 , Hong Kong
1 November 2019, 03:03
I have passed all the verification but cant publish the game: Application publish error APP_PUBLISH_ERROR: Task wasn't published. Publish result is unknown.
Rithik BhatLevel 7 , Hartford
24 June, 22:35
Hey, I had the same problem, but I got my code working by not using clone in the merge and compress row methods. I made another method that makes a copy of the row array and returns it.
shabarish kumarLevel 20 , Hyderabad
18 August 2019, 11:44
is there any way to find what are the values in Color class?
Teodor ClipaLevel 41 , Bucharest
8 May, 15:28
yes, select the Color name and press Ctrl+Shift
6 August 2019, 10:01
For the second last task, I am passing "" when the value is 0. But the task is not passing smh. The board displays correctly when I run it.