Creating the variables for the slot images
First, we will need to declare the the images into a variable and then store them into an array.
Don’t be scared! It looks long and squiggly because of the links. These are where the images are located online. I do recommended hosting them locally. I just used links because I was lazy. Now, we need to store them into an array. Here’s an example below.
Start Game Function
For every reel, I have created a time interval that stop the function after the counter variable has reached a specific number. The counter is set at zero and a 1 is added every 10 milliseconds. While counter is less 140 in this case, epromA the random number variable selects an item the array based on the index value. I have repeated this same context for the other two slot reels.
Before the ending of the 3rd slot reel, the random number variables for all the reels are compared for wins using if/else statements. You can pretty much set it to what ever you like. I also have the slot machine deduct a number of credits at the begining. If there are no wins, no credits are added.