hp
toc

4096

2017-02-25, post № 160

games, Java, programming, #2016, #clone, #exponents, #jar, #powers of two

4096 is a Java-based clone of the well-known web and mobile game 2048, which itself clones 1024 and is similiar to THREES. The naming trend is quite obvious, though note that 2^{12} is a power of two where the exponent is divisible by three, further connecting to the aforementioned game.

In the game, you are faced with a 𝟦 ⨉ 𝟦 matrix, containing powers of two. By swiping in the four cardinal directions (e. g. pressing the arrow keys), you shove all the non-empty cells to that side. When two equal powers of two collide, they fuse together, adding. Once you shoved, an empty tile pseudo-randomly transforms to either a two-tile (𝟫𝟢%) or a four-tile (𝟣𝟢%).
Your objective at first is to reach the tile 4096, though the real goal is to achieve the highest score. Your score is the sum of all the collisions you managed to cause.

To play 4096, you can either download the .jar file or review and compile the game for yourself, using the source code listed below.

Controls

  • Up, down, left or right arrow key shoves the tiles,
  • ‘Escape’ restarts the game upon a loss,
  • ‘F11’ toggles fullscreen.
4096-1.png
4096-3.png
4096-4.png
Source code: Main.java
Jonathan Frech's blog; built 2024/08/31 22:59:44 CEST