Devlog #1: Core Functionality


DEVLOG #1: Core Functionality (Trigger Warning: Bad Code)

The purpose of this first devlog is to demonstrate the mechanics behind the core gameplay loop of each of the game modes. It's important to note that all of the game modes rely heavily on Random.Range() for their core loop. Also, this devlog will mostly be focused on the code aspect, with some actual gameplay footage coming with the next devlog once all functionality is complete.

First, Blackjack. The main gameplay of this game mode revolves around drawing cards. This is done using the Random Number function with the range (1, 14). Another thing to note is that when calling Random.Range() using integers, the upper bound is exclusive, so the upper value needs to be one higher than the last wanted value.


This generated value is then used to determine two things: The card that is displayed on-screen, and the card's value. Both of these are done with switch statements that allow for handling both the face cards (which all have a value of 10) and the Ace (whose value varies depending on the player's current score).


When a player hits, these three functions are used to draw a card, add that card to the player's hand, and add that card's value to the player's current hand value.


Second, Craps.  The code for this game mode is remarkably simpler than for Blackjack. A random number between one and six is generated, and that value is then displayed on-screen.


Third, Roulette. Like Craps, not much is needed, but some extra work is needed to display the colour of each space as well as the number. This is done using a switch statement to handle the drawing of both the zero and double-zero spaces (which are green spaces on a standard roulette wheel), as to return a red or black for even and odd spaces, respectively.


Finally, Slots. In the code, a protected List containing every symbol in the game is instantiated. When the number generator calls a number, a switch statement decides which symbol to display by calling the necessary symbol from the List. This is repeated for all three positions on the slot wheel.


Each of these are displayed via the UnityEngine UI module, by controlling text boxes within the scene. An example here is BlackjackUI, which displays the hand and score of both the player and the dealer.


That about covers things. Make sure to tune in next week, when I hopefully manage stop procrastinating and actually add gambling into the game.

Leave a comment

Log in with itch.io to leave a comment.