You may have seen the 2048 game running on iOS and Android. Here’s a version made with Xojo, which I call 2K that runs on Desktop, Web and iOS.
This Xojo clone attempts to emulate the iOS gameplay, which is very simple. You start with two tiles on the grid, which can be either a 2 or a 4. You can slide the tiles either up, down or left, right. Tiles that have he same number are combined into a single new tile whose number is the sum of the tiles. After each slide, a new tile (randomly a 2 or 4) is added to an open position on one of the edges. The newly added tile is highlighted.
So if you slide a row that has two 4 tiles, it will combine to a single 8 tile. You get the value of the combined tile added to your score. The game is over when you have no more moves.
For reference, this is what the original iOS version looks like on an iPad:
This is the Xojo desktop app:
Most of what you see on the window are Canvas controls, including the logo, score, high score, tile grid and arrows.
The current position of the tiles is stored in a simple 4×4 array called Grid. There are methods that process a slide for each direction, moving tiles and combining them as necessary (SlideUp, SlideDown, SlideLeft, SlideRight).
And the high score is saved to a text file so it can be reloaded.
Web and iOS, too!
There are also web and iOS version that you can also try. Both are largely designed the same as the desktop version, but using WebCanvas/iOSCanvas controls.
Have fun playing the game and feel free to send me your enhancements.
Interested in making games with Xojo? Read on…