# 2048

poziom
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!
Komentarze (31)
Musisz się zalogować, aby dodać komentarz
Lê Thanh Bình
Poziom 0 , Viet Nam
15 sierpnia, 07:13
bủh
kevin
Poziom 0
30 czerwca, 02:09
buh
cheyenne
Poziom 0
17 czerwca, 21:59
hi
TaoLu
Poziom 20 , 泾县, China
13 marca, 15:24
I'm still unable to publish it...
TaoLu
Poziom 20 , 泾县, China
13 marca, 15:45
publish result is unknow!
Alex
Poziom 41 , Solar System
14 marca, 13:22
Please submit a question in the Help section and include your code. You can then send the link to your question to Support via support@codegym.cc
TaoLu
Poziom 20 , 泾县, China
14 marca, 15:00
Thank you i just comment this code on line 4 and it work
``//import javafx.application.*;``
Noah Brandin
Poziom 9 , Bielefeld
28 stycznia, 09:40
Ich bin Level 6 und weis immer noch nicht wo ich anfangen soll. In welchen Level lernt man sowas?
28 stycznia, 12:17
Normalerwiese startet man Java von Anfang (Level 0) an zu lernen. Welche genaue Frage haben Sie?
Dyrits
Poziom 22
I'm still unable to publish it...
Alex
Poziom 41 , Solar System
Please submit a question in the Help section, so everyone can see your code, then send the link to your question to support@codegym.cc
Ilia Kalugin
Poziom 25 , Novara, Italy
It looks like there is some kind of error in the verification. My code has passed all the stages of verification, but from a certain stage when I press Play - it gives an error "An error occurred: APP_PUBLISH_ERROR"
Alex
Poziom 41 , Solar System
Are you trying to run it on the website or in IntelliJ IDEA? Please submit a question in the Help section and include your code, then send the link to your question to support@codegym.cc
davin
Poziom 1 , Panama City, United States
are you guys the only guys here?
Rich
Poziom 23 , San Diego, United States
there aren't many people taking advantage of this feature of the course...
Agent Smith
Poziom 38
22 września 2020, 20:08
Nice and fun way to practice multidimensional arrays. 👨‍💻
Max
Poziom 16 , Hamburg, Germany
13 września 2020, 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) {
win();
}
else if (!canUserMove()) {
gameOver();
return;
}``````
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?