As my first project as a Junior Applications Developer, I set out to learn to code in the best way I know how, by doing.  I ended up picking what was probably one of the hardest options I could pick, namely to replicate the sliding puzzle game, 2048. ( ) Of course I didn’t realize how hard it would be at the time, but after spending the first week alone working on the logic, I had already dug my hole.

2048, the sliding puzzle game, basically starts with a 4x4 grid filled with zeros. As you swipe the grid, values move toward one of the up, down, left or right sides. With every subsequent swipe, a randomly placed value of 2 or 4 is added to the grid. Any neighbouring matching values in the direction of the swipe are added to one another. This was done by swiping 2 tiles of equal value into each other, creating a new tile with double the value. Two 2 tiles became a 4, two 4’s an 8, and so on.

The goal? To create a 2048 tile.

Overall the logic was probably the most challenging part of my task, once the framework was set. . The logic consisted of many if statements that made the numbers “slide” properly, ie not combining with another number. This was probably the hardest part. Troubleshooting and allowing for all the possible conditions also proved difficult. However, the user interface was probably the toughest part, figuring out the labels, making everything display correctly, and programming all the buttons to not break. That was fun.

Anyway, it was a really fun project to work on, and I’m extremely happy for how it turned out, and I hope you enjoy playing it, as much as I did making it!

You can try it out here:

Please Wait...