Minigames
Starting Date: 14/05/2025
Ending Date: 21/05/2025
This blog is about creating the minigames for the player to play and chance to win cash.
Objective
The goal is to create minigame for the minigame manager to choose from, the manager needs to display the correct minigame with the suitable controls to occur for the player to do.
​
The first objective is to create double or nothing minigame which is a basic game that the player can keep doubling their cash until they either keep what they've won or lose it all from a chance, this will involve the chance of failing to increase each time the player doubles their cash and a method for them to keep the prize cash.
​
The second objective is to create XIII minigame which is a multiplayer minigame that each player chooses card to reveal to gain cash, unless they reveal the coconut which will lead them to lose all their prize cash, this will involve the fruits and coconut being randomly generated in a certain card which will randomise the position, this will also involve providing unique values for each fruit for the player to gain cash depending on what fruit they revealed.
​
The final objective is to create tic-tac-stash minigame which is a single minigame that spins the blocks for the first time and allows the player to lock the blocks for the second spin, this will involve randomising the blocks' symbol, an action for the player to lock block to keep their symbol during the second spin and the win criteria of all the symbols being identical in certain lines (horizontal, vertical and diagonal lines).​
Techniques
State Pattern
The state pattern is a design pattern that can provide unique states for a object, this can be use for a player or a non-playable character to provide a current state depending on the activities occurring the game. A state machine is used to identify the current state and change the state from the current to the new state with the current state executing one last method before exiting and the new state executing one method after entering as the current state.
​
I use the state pattern similar towards the player state that uses the suitable minigame state as the current state once the player has read the rules, which allows the player to have all the controls they need when playing the game.
​
This is a useful method because each minigame has their own unique behaviour towards playing, meaning that a game state machine will provide the suitable player behaviour for the chosen minigame, leading the player to be able to play the minigames.
Coroutines
Coroutines are similar to method functions in a script, the key difference being that not every line of coding will be executed all at once and will wait until a certain activity in the coroutine is complete this can be either from waiting for certain seconds or until a conditional statement from the coroutine becomes true.
​
I used coroutines for all of the minigames in order for the codes to wait until the coroutines are complete, meaning that each minigame will prevent the player to do any actions until the minigame managers have completed the outcome of the minigame, when the minigame is also finished a coroutine will wait for a certain amount of time to inform the player the game is finished and display the outcome of the prize cash to the player.
​
This is useful for players to identify the outcome of the game and preventing players from doing any actions whilst the manager is calculating the outcome of the action itself, this leads the players to figure out they cash prize when the minigame is finished.
Game Loops
Game loops are sequencing patterns that can repeat the code that is inside of the game loop multiple times until the condition is met to stop looping, meaning that I don't need to repeat writing the code and instead use a game loop to write the code once.
​
I used game loops for both XIII and tic-tac-stash in order to repeat certain implementations in the game.
​
Towards XIII, I used a for loop which includes a do-while loop that randomly selects each fruit to be on a certain card and if there is a card that already has a fruit on then the code will randomly select a different card.
​
Towards tic-tac-stash, I used only for loops in order to randomly select a symbol for all of the blocks and once the game has finished then another for loop will be used for each of the winning lines to see if the player gains any cash.
​
This is useful because of reducing the amount of repeated coding in the game, meaning that the frame rate will stay low towards executing repeated line of code, which will lead to enhancing the performance of the minigames.
Challenges
Unnecessary Scenes
One challenge I had to face was realising that I didn't need any of the minigames as scenes, this is because each minigame scene only has a interface, meaning that I could just add these minigames in as interfaces.
​
This was time consuming for me because I need to ensure that the minigames work in the same scene as the board map, meaning there has to be more scripts and objects to be used in once scene.
​
This does allow me to reduce the amount of data to store and retrieve, however this can cause higher frame rates due to the minigames being displayed in the game as user interfaces, which can to possible performance issues for the player to experience frame lag.
Achieved
Double or Nothing Complete
Double or Nothing was completed by providing suitable states for the player to either double their cash or keep what they have along with coroutines that makes the player wait until the outcome has occurred.
​
The minigame provides a risk and reward for the player because they can keep on doubling their cash, however their chance of failing increases by a range of 1 to 10%, this leads the player to either have low risk and low reward by playing safe or high risk and high reward by constantly doubling the cash.
​
XIII Complete
XIII was completed by providing suitable states for the current player's turn and the inactive player for one player choosing either a card to reveal or skip their turn along with using game loops to ensure that there are suitable amount of fruits in randomised positions.
​
The minigame also provides risk and reward because the more cards they reveal the higher the chance of them revealing a coconut, however revealing high cash fruits such as watermelon provides a reward for the player to gain high amount of cash as long as the player wins. This can lead the player to use their skip for meaningful action towards avoiding a high chance of losing, leading players to either play risky to obtain a fruit or play safe to use the skip at the right moment.
Tic-Tac-Stash Complete
Tic-tac-stash was completed by providing suitable states for the player to lock certain blocks, a coroutine that waits for the first and second spin to be finished for the player to identify the outcome of the minigame and a for loop to randomise the symbol for each block and having the winning lines identify if the player has won cash.
​
The minigame provides even chances meaning that the player could see 7s which are very high rewards, meaning that the player could risk on locking in 7s to win high amount of cash or play safe by choosing the most common symbol that are displayed, this lead a risk and reward for the player's actions to occur them to win something in this minigame.
Conclusion
Overall, I learnt that each minigame has their own unique techniques to be implemented in order for the minigame to function for players to play and win cash, for instance each minigame needs their own state behaviour for the player to provide unique actions as well as implementing game loops, double or nothing didn't need any game loops as it only doubles the cash or loses it all, whereas XII requires the most unique game loops with for and do-while.
​
As a programmer, I should look back onto these minigames and identify the suitable implementations for future minigames such as the type of minigame (multiplayer or single player), the ruleset and the player actions that they need to input into the minigame.
​
If I'm making more minigames that I should rely on both coroutines, states and possibly game loops to provide suitable controls for each minigame and identify the results of each minigame.