Sunday, March 4, 2018

2048 Clone in Java, a Journal

I am revitalizing this blog to try and keep track (and think through) design choices with my next project in Programming 2. The first two projects were mostly a flop, and I wondered out loud to my friends if doing this would help me stay on track. This is essentially a rubber-ducky journal. If it helps anyone else, that's awesome, but it is mostly for me.

Our goal is to create a version of the math game 2048 with a themed spin on it. The theme we are assigned as default is Star Wars, but if we can come up with another theme, it will be an extra 5 points.

The original 2048 can be found here: http://2048game.com/
The Star Wars version we are mimicking is here: https://0x0800.github.io/2048-STARWARS/

I'm only starting to set up my class structure, of which I've determined I need at least 3 things.

  • The Game class will handle:
    • Game States - currentGame, gameOver (gameWin and gameLost), restartGame
    • Current score and best overall score
  • The Tile class will handle:
    • Tile borders and whether a tile can combine with another tile
    • Tile values
    • Tile colors/symbols
  • The Board class will handle: 
    • Number of tiles on the board
    • Tracking tile positions
    • Tracking empty tiles
    • Spawning new tiles
There is also an FXML document and a Controller class, since we're using JavaFX and SceneBuilder to create the UI and handle animations, soundFX, and music. Here's a rundown of what the game should have:

  1. Background music
  2. Animations
  3. Sound effects for each piece
  4. Tile must be abstract
  5. Must use an interface
  6. Must correctly keep track of current score, high score, and if the game was won or lost
  7. Bonus: A HELP function that will highlight possible moves
  8. Bonus: A theme other than Star Wars
  9. Bonus: A SWAP (cheat) function to allow for the swapping of two tiles
What I would like to add is an extendable panel that will display the values of the pieces, since we'll be working strictly with symbols. I think I can do so with the Gluon Navigation Drawer, but I'll need to research how it works and make sure it will do what I'm envisioning.

I'll update with my progress as this week goes on. Hopefully, with it being Spring Break for the next week, I'll have plenty of time to get some of the structure hammered out!