This is an old revision of the document!
Table of Contents
2048 GUI
The AP Classroom 2048 is Text based, so here is an example of a GUI that you can use with your 2048 Lab solution.
Additional Methods For the Game2048 class
public int getScore()
returns the score.
public int[][] getBoard()
returns the gameBoard.
public int max()
returns the maximum element of the gameBoard.
Implementing Scoring
For the score to function the usual way, you need to modify each of the four merge
methods in the Game2048
class. Whenever two cells combine, add this number to the score. For example, if two 8's are combined, 16 should be added to the score.
A GUI Example
Here is an example that implements the KeyListener
class so the user can simply use the arrow keys to make a move.
Modify the paintComponent
method to change the fonts, colors, size, and appearance of the game.
Making an executable jar file
Any computer with the Java runtime installed can play your version of the 2048 Game.