Shuffleboard Game

This was an assignment for my Java GUI course. We used Java Swing to create a "shuffleboard" game. It works as a two player game to see who can get the highest score with their stones. The further your stone stops the higher your score, as long as you don't hit any walls or fall outside the boundaries. Each player gets 4 stones to shoot. There is fully implemented collision detection so each stone bounces off the other appropriately. There is also satisfying friction so the stones stop properly. To toss a stone click on it and drag backwards. The length of the line you create determines how fast the stone is shot. The stone will be shot in the direction the line is facing. If a stone falls out of bounds it will lose its colour and not count towards the total points.

All of the collision implementation was provided by my professor. He provided all the math logic behind his implementation, so I could make my own, but at the time I was too busy and was glad he provided it. Everything else was created by me, except the wood image (which was found on a stock website). We were required to make an Undo button, which undid only the previous move. However, I made it so you could undo as many times as there were turns. As well we needed to make a Replay button. I managed to make it work even if you had hit Undo many times previously. I did this by storing each shot's information (direction and speed). Whenever the replay button was pressed, the undo button was used then the shot was simply executed again using the stored information. The exact same shot is always executed. The amount of friction and colours of the player's can be modified to the user's liking. A major requirement was curve shots. We were required to implement it so that if you clicked and dragged from the edge of a stone, it would curve in the opposite direction. For example if you clicked on the right of the stone, as it moved upward it would curve towards the left. This means with skill you could go around another stone without bumping into it. This was done by modifying the horizontal velocity of the stone as it traveled.

I have included an executable JAR file in the zip containing the source files. You can download it here. You can play the game with the JAR file or open the project in Eclipse or another IDE. I have also included the original assignment web page to see what was required of us. Everything asked was implemented.

Shuffleboard