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 (109)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Olga Kuzmins
Level 38
17 April, 09:31
Ребят, писала вам в раздел "Поддержка" в связи с проблемами в этой игре, но мне не ответили, мб тут заметят комментарий. В предпоследней задаче не отрисовывается счетчик очков и задачу не проходит валидацию. Я читерила и написала метод setScore в методе initialize, в итоге валидатор принял задачу и обнулил мне прогресс по всей игре. Теперь снова на 4-й задаче)) Может поможете мне с этим или хотя бы расскажите, чем игра заканчивается 😂
Иван
Level 16
6 March, 19:46
private void drawScene(){
        for(int x = 0; x < gameField.length; x++){
            for(int y = 0; y < gameField.length; y++){
                setCellColoredNumber(x, y, gameField[x][y]);
            }
        }
    }
private void setCellColoredNumber(int x, int y, int value){
        Color color = getColorByValue(value);
        if(gameField[x][y] == 0){
        setCellValueEx(x, y, color, "");
        }else{
        setCellValueEx(x, y, color, String.valueOf(gameField[x][y]));
        }
    }
не проходят 4й и 7й пункт, чего валидатору надо? где я чего не так вызываю?
ToTAmon Программист 1С at Медконсалт
4 March, 12:06
Не работает setScore().
8 January, 17:49
Пара вопросов появилась. Вот мы установили счетчик очков, но на сайте его нигде нет и когда из IDEA запускаю, то очки не меняются в самой игре, а только когда заканчиваешь ее, хотя по логики должно выводить. Как это исправить? И когда игра опубликована, то где менять её код, чтобы он изменялся и в опубликованной игре. А то у меня надписи корректно не отображаются на сайте и хочется пофиксить
YUREC
Level 36
10 February, 19:41
у меня вообще счетчика score на экране с игрой нет
Eduard System Engineer
21 June 2023, 11:43
При запуске на JavaRush не работает клава. Валидацию проходит, даже опубликовалась, только не управляется... В IDEA всё нормально работает.
YUREC
Level 36
8 February, 10:51
ага у меня такое тоже было на крестиках-ноликах - то что работает в IDEA не работает на сайте. Только у меня там часть кода по поводу вывода сообщения о ничьей не отрабатывала.
Михаил
Level 42
1 June 2023, 18:24
Не могу опубликовать, в чем может быть проблема?
Максим
Level 28
1 February 2023, 15:05
Marina-dm28
Level 38
3 January 2023, 17:52
А можно ли выложить игру в Git вместе с движком Game?
IrinaHonya
Level 45
17 August 2022, 11:21
Когда играешь на страничке опубликованной игры то нигде не вижу счетчик очков 😐 Это у всех так или только у меня?
Rexalifet
Level 23
29 September 2022, 06:17
Та же проблема. При чём, как в браузере, так и в телефоне
Vahagn
Level 40
7 July 2022, 06:00
а зачем вы про очки написали там нечего токого нету в игре