Michael Mohan
In Cue Ball, you can attempt to pot balls in a 3D snooker simulator. The aim of the game is to clear the snooker table in as fast a time as possible. The quicker you can clear the table, the better your score will be, although your score will be decreased if you perform any illegal moves. You can also lose the game if you pot the balls in the wrong order. To play you can orient the direction of the cue ball and then hit it to try and pot the other balls.
The game can be played above. it is also available on itch.io here. The code, artwork and executable are available on GitHub here. Some screenshots of the game are shown below. There is also a video below to give a brief overview of the game. A description of the design process is then given along with some details about original plans, difficulties and techniques learned.




















Design
The big change in the development of this game is that, in contrast to the first Unity game I worked on, this was 3D. Initially I planned to do a game somewhat like the game Kula World for the original PlayStation (a platform game where you control a beach ball around different stages collecting objects, where the physics changes as the ball traverses the different part of the level), but it felt too derivative. I stay may play with the idea of changing the physics in a future game, but instead I decided to do something different while playing around with the 3D physics options in Unity. I decided to create a snooker simulator where you play the cue ball. This allowed me to make use of the built in 3D physics properties available in Unity.
One of the main issues I ran into when changing from 2D to 3D games, was that if I wanted to create any objects more complex than basic shapes, I would have to use some sort of 3D modelling software. I was and still am reluctant to get too wrapped up in this as it is a whole other skill set that I could sink a lot of time into having to become adept at on its own. Fortunately the snooker balls themselves were just spheres so I was able to avoid this problem but I wasn’t so lucky when creating the snooker table. I used ProBuilder, which is now a part of Unity that can be imported, to attempt this. Initially, I thought the snooker table would be a relatively simple shape to create, but it wasn’t as simple as I would have thought. ProBuilder can be useful for greyboxing and creating prototypes for shapes, but when they become more complex than block structures it can be more difficult. As the snooker table had convex areas and holes, it was taking longer than I would have liked. As a result, I instead reverted to building the table shape in Unity using a number of cubes. While this was a bit basic in execution, and meant that the pockets were square instead of circular, it did the job fairly well.
I initially added a skybox as a background to the game around the table, but I end up adding fog in order to give the game a more ethereal theme. As a result the camera’s field of view is restricted to only the table and anything outside is black. I had to play around with the physics a bit to get the movement of the balls to seem more realistic. Initially, the balls would kind of just stop when they hit the edges and also not really slow down and stop naturally and instead keep moving slowly until they hit an edge or were potted. Fortunately, I could attach physics materials to the objects to play around with their bounciness, friction and drag. I can also add a force to an object if it has a rigid body physics component applied, so this was used to give the player an initial impulse force when you hit it to give it the explosive movement. In order to check whether the balls were potted or fell off the table, I was able to check whether they collided with the bottom part of the table or whether their y position was below a certain amount. I could also use the collider to check whether the cue ball hit any other balls during a move.
I restricted the ability to move the cue ball while it was in motion by checking the magnitude of its velocity. I set it to be hittable when the velocity was suitably small enough but not when it had completely stopped in order to avoid having to wait too long for the ball to stop. While I restricted the ability to hit the ball, I still allow the player to rotate around it while it is moving. I order to implement the ability to orientate the ball, I had to change the camera position. It is set by default to follow ball by being set to the position of the ball with a bit of an offset to be behind and slightly above it. I was able to use the RotateAround function to have the affect of moving the ball. First I needed to set the camera to be facing the ball. Then I had a rotation value set which was incremented or decremented depending on whether the left or right buttons were pressed. Then, with the RotateAround function, I could set the position of the camera relative to the position of the ball and the rotation value. I also implemented the ability to see the snooker table from a bird’s eye view to have a better view of the balls when they were moving and in case it was more difficult to gauge the angles from the cue ball’s point of view. To do this, I set the cameras position to be above the table and set it to be facing downwards on the y axis. With some more time, I would have liked to have given the player the ability to hit the ball while in top down view mode, but as its direction of movement was dependant on the camera’s position (which is different in top down mode), it would have needed a bit of reworking to be functional.
The balls have to be potted in the right order. Initially, the coloured balls can only be potted alternating with the red balls, but 2 cannot be potted consecutively. This was fairly easy to check by having a variable to check whether the last ball potted was red or coloured. After the red balls were all gone, it was a bit more involved. At this point, the coloured balls need to be potted in a specific order. I have come across a similar problem in the CrimePeeper game when checking the input for a sequence of characters to trigger the Criminal mode with the Konami Code. To check the order of the balls potted, a sequence was stored as an array of strings, ordered by colour. Then, when a ball was potted, I could check its current position in the array to see if it was the right colour. Then, I could increment a position pointer for the array which would have began at the start. This pointer will keep moving through the array as you pot the balls in order, or will be reset if the wrong ball is potted or all the balls are potted.
A timer was created for the game by initialising a value to 0 then finding out the amount of time that has passed since the last frame and incrementing by that amount. This value could then be added to a text object to display it in the game, with the value in seconds being converted to minutes and seconds using the modulus operator and the Mathf.Floor method. A score is generated when the player completes the game which is dependent on the timer value as well as the amount of hits it takes to complete the game. The score decreases as the time increases, so in order to implement this, a linear mapping was applied to drop the score from an initial maximum value. This was decreased asymptotically towards a limit of 0 in order to allow the player to play the level for a long time without the score moving into the negative values. After some testing around with different scoring setups, the maximum value was set to 2,000. To generate the score, first, the time in seconds and the amount of hits were multiplied together. Then this combined value was combined with the max value in the following equation: maxScore - ((maxScore * combined)/(maxScore + combined)). This way, the maximum score is taking away a value that is increasing more and more towards 2000 as the combined score increases. This is possible because the numerator is increasing at a larger rate than the denominator.
Artwork And User Interface
As mentioned above, the main headache with the objects in the game was in creating the 3D model of the snooker table, so there wasn’t as much of a need for 2D artwork in this game. However, I did create a logo for the game. This time, instead of using GIMP like in the CrimePeeper game, I used Photoshop instead. After the last game, this time I gave myself a bit more time to set up the different UI elements for the game. There are 3 different game over screens. One for completing the level and clearing the snooker table, one for losing after potting the balls in the wrong order, and one for losing the Time Trial mode (see the Konami Code entry below). I also added a separate help screen that can be accessed from the main menu, as the rules for the game were a bit more complex and needed more space in order to be elucidated. In the game itself there are various pop ups. There is the timer of course, which is displayed at the top of the screen. This is changed to a red countdown timer for the Time Trial mode. I added in a display to inform when the ball has suitably slowed down enough to move. This was added fairly late in the development process, but after some playing around with the final game, I am happy with the decision as I would tend to be tapping the space button as the ball was moving waiting to be able to go again. The display is a nice touch and stays on the screen while the ball is waiting to be hit again so it also gives some feedback for when you have hit the ball. For some illegal moves, a penalty is added to the timer. This is accompanied by a corresponding pop up to state how many seconds have been added to the timer. For these displays, they will appear on the screen for 2 seconds before disappearing again. This is a bit better than the previous game that rely of the user to press a button for these sorts of pop ups to go away. This is still used for the displays used to inform that the Konami Code has been triggered, but I feel that this is more relevant here as the player may need more time to read the displays whereas the penalty is more to inform the player that an illegal move has been made.
Konami Code
For this game, the Konami Code unlocks a Time Trial mode that gives you 10 minutes to clear the snooker table and complete the game. When Time Trial mode is toggled on, the timer will changed to count down instead of up. The time begins as soon as the level begins and keeps ticking away even if you go back to normal mode, so the player can’t clear most of the table and then give themselves 10 minutes to pot the last ball. If you complete time trial mode, the score you get will be the same score as in the normal mode, dependent on the time taken and number of hits, but if you have the Time Trial mode activated and more than 10 minutes have passed, you will lose the game. As the Konami Code was implemented in the previous game, I was able to use the same approach as before to handle input and display the information about the Time Trial mode when it is toggled on and off. This time, the functionality that the Konami Code triggers is more influential to the game, and it may have been worth considering actually including it as an extra option for the game type in the main menu instead. Nonetheless, it can be triggered on and off at will by using the immortal keys up, up, down, down, left, right, left, right, b, a, enter!