Rubiks Cube Simulator

Click Here to see the source

This was my term project for my Graphical User Interfaces course. The assignment was to use swing to create a rubiks cube simulator. The minimum requirement was to just show 1 face at a time, and this could be done by only having 9 blocks on the screen and those blocks could be buttons so in that case no graphics programming would be necessary. Since I have a mild obsession with Rubiks Cubes (my record solve time at the time of posting is 39 seconds 🙂 ) and I was very comfortable with Swing, even before the class, I decided to go all out with this project.

The main area is just a JPanel, however did alot of custom drawing in the JPanel. It also included some math to determine which button was being hovered based on the mouse position. The backend was pretty fun to write. Even though the cube is build up of 26 blocks it was easier to think of it as 54 subfaces. I just had to make sure all those faces were manipulated correctly for each operation. Then for drawing the 27 faces which happened to be on those sides were drawn.

I additionally had several extra mechanics in the sidebar such as as undo button and a move counter. In tournaments a single move is one turning of a face, regardless if it’s a quarter or semi turn. So I accounted for this in my move counter. It even resets the move if you do an eniter turn. It aspect of the sidebar which I’m most happy with is the fact that’s it’s configurable. There are several extra features but you can choose which ones go in the sidebar.

The last thing I’d like to talk about is that you don’t need to use the mouse. Everything is also mapped to keyboard shortcuts. So I guess in theory if one was trying to solve the cube as fast as possible they could do so by just typing a series of commands on the keyboard,

One Comment

  1. Reply
    Hebergement web September 6, 2016

    That s because those letters are how the Rubik s cube community talks about different algorithms. It s sort of already a standard, and was never meant to be used as controls for a game.

Leave a Reply

Your email address will not be published. Required fields are marked *

Status Completed
Development Period March 2013 – May 2013
Target Platform PC, Mac
Development Plaform Java Swing