![]() ![]() * Called when 's' or down arrow is pressed - calls 'verticalMove' for every tile on the board with parameter 'down' */ public void down() * Called when 'w' or up arrow is pressed - calls 'verticalMove' for every tile on the board with parameter 'up' */ * Checks to see if the game is over - when the board is blacked out and none of the tiles can combine */ * Checks to see if the board is completely blacked out and if it is, it will nudge the players to restart */ * Spawns a 2 (or 4) at an empty space very time a move is made */ * Returns the board as a String - used in the GUI */ * Prints out the board onto the console - for testing purposes */ * Finds the highest tile on the board and returns it */ * Getter method that returns the score */ ![]() * Getter method that returns the board */ * Constructor for the Board - sets up a matrix with specified grid size */ ![]() * Default constructor for the Board - sets up a 4x4 matrix */ ![]() Most of the logic is also here, the class providing methods for spawning 2's and 4's at random locations, moving up, down, left and right, and letting players know when the game is over. I divided the game up into 3 classes: Board, Tile and Game.ĭescription: The Board class deals with the gameboard, setting up an array of 'Tile' elements, getting the current score and the highest tile, and putting the array in a string (to be used later in 'Game'). I uploaded all my code onto GitHub - check it out here: ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |