A Virtual Fruit Machine
Introduction
The aim of this project was to create an interactive simulation of a fruit machine using VRML and a scripting language (JavaScript). The kind of fruit machine that it was intended to create is fruit machine’s that are commonly known as "one arm bandit’s" or "slot machine’s". The basic idea behind the slot machine is based on the principle that we have a lever, which, when pulled rotates the reels. When each reel lands on an identical symbol the user wins money.
The basic fruit machine is then placed into a virtual room. This room contains 6 fruit machines, each of which costs a different amount to use, and therefore, has different winning amounts also.
Specification
The model should contain:
Design
In this section I will describe the main design decisions that were made during the project. Emphasis goes on the interactive objects.
Given the specification it is obvious that there are many objects. Therefore, given the Object-Oriented approach offered by the VRML language I decided to separate components into objects, this process is called prototyping. Each of these prototypes should be a self-contained component which can then be brought together to form the model. This allows me to concentrate on one feature at a time, and learn the VRML language in an incremental level. I chose to use the following prototypes:
Static
Interactive
Room
The room is where all of the objects will be stored. The room must contain multiple fruit machines and representations of light-shades and stools. It must also have a picture on the wall that credits the user.
Tracking Interface
The tracking interface is used to represent the money a user currently has. Therefore, the tracking interface must:
Fruit machine
This is the most important model within the VRML project it has the following features:
Non Interactive features
The basic shape for the fruit machine should be pretty basic. The fruit machine should have a lever on its side. The machine will obviously have to have reels, which will be embedded inside the machine. The machine should also have hold buttons, one for each reel. These will be located under each reel.
Interactive Features
More Credit
The credit object is simply a picture on the wall displaying a person holding money. It is the point that will be used to credit the users money it is very simple and does two things:
Implementation
In this section I will outline how each prototype was implemented. In this section I will focus on the interaction in each of the objects rather than the structures used to build tem.
Static Prototypes
The static Prototypes were built using simple shapes. Each of the walls, the roof and the floor in the room are represented as a Box primitive. A stool is simply a set of cylinders with different sizes and orientations. A light-shade is also a set of primitive shapes connected together to form its appearance.
Tracking Interface
The tracking interface was taken from Dr Jankovic’s lecture notes. It has 2 prototypes the proximity sensor ( to allow it to always appear) and the interface. I therefore altered the interface to allow me to represent the money that the user currently had. It was also used to indicate to the user the amount of money that they had last won. I altered the interface by giving it event ins that would be triggered by using the actual fruit machine:
EventIn SFInt32 machineUsed
This event in is sent to the tracking interface via a fruit machine. The fruit machine sends a value of how much the tracking interface should deduct from the user’s credit. The tracking interface then activates its script and deducts the amount given from the users credit and then displays the new credit.
EventIn SFInt32 won
This event is similar to the one above. It is also sent via a fruit machine indicating that a fruit machine has been won and the tracking interface should credit the user the specific amount.
EventIn SFTime creditUser
This event in tells the tracking interface that it needs to credit the user with £10.00. Its type here is insignificant, it is there for simplicity. This is because we can easily route it from a touch sensor to the tracking interface. When the eventIn occurs a corresponding function is called within the scripts that credits the user by £10.00.
EventOut SFInt32 currentCredit
This event out is used with the script defined inside the tracking interface. Every time the users credit changes the users currentCredit event out is triggered sending the amount of credit they have. This should be received by a fruit machine which can then decide whether to disable itself based on whether the user has enough money to play.
Fruit Machine
Lever Animation
Animating the lever being pulled was simply achieved by routing a touchSensor to an orientation Interpolator
Field SFInt32 winRate & useRate
These simple fields specify how much the win rate is and what the use rate is. That is each different win that can occur will be a multiple of the win rate.
EventOut SFInt32 userWon
This specifies that the user has triggered 3 identical symbols and that the user has won. The value passed out is a multiple of the winRate (it is between winRate and 5*winRate because there are 5 symbols per reel). This is routed to the tracking interfaces won eventIn.
EventOut SFInt32 userPlayed
This is triggered when the user pulls the lever. It represents that the user has used the machine. It is passed the value of the filed useAmount.
EventIn SFInt32 credit
The value sent in this EventIn should represent the amount of money the user has. When a value is passed in this eventIn, the credit function gets called in the script. This function tests whether the user has enough money to play the machine, if they do not if disables the touch sensor on the lever, making the machine inoperable.
Scripting
This prototype contains a lot of scripting mostly for the rotation of the reels. When the user pulls the lever the reels need to be rotated to a specific symbol. The symbol gets decided via the script and the script then triggers the rotation via a rotationInterpolator. The decision process chooses a random number between 1 and 5. Each successive reel rotates for half a second more than the previous. When a reel has finished rotating a sound is then played. The reel rotations can be calculated by each symbol in the reel having a number. When we need to get to a get to a given number, we calculate the offset from the current number and rotate the reel by this amount multiplied by the 360 degrees / 5.
When all reels have been rotated the script then checks whether the user has won or not. If the user has won it triggers the eventOut userWon with the specified amount. It also triggers a sound to be played.
The script also decides when a hold sequence should occur. A hold sequence occurs every 5 goes. A counter is set up inside the script and when it reaches 5 a hold is triggered. This simply sets touchSensors attached to the hold buttons to true, and enabled the colorInterpolator which blinks the buttons yellow and white, it also enables an audio clip which repeats until the machine is used again.
Results and Conclusions
I am quite pleased with what I have achieved in the given time that I had to produce the project. The user can play a fruit machine by simply clicking on the lever and the reel rotation is animated. The use of sounds aids to the users experience.
However, there are a few problems with the model of the fruit machine. Firstly when hold mode is enabled if the user clicks on a hold button it doesn’t always revert to yellow. If the user clicks on the button at a certain point it may turn white. I believe this was due to the fact that the colorInterpolator is switched off after the call to set the colour to yellow, even though the calls are ordered the other way around inside the script.
Another problem with the fruit machine is that if the user click on the lever before the current reels have finished rotating it interrupts the current cycle. This also results in the sounds not being played in the correct order. A fix to this problem would be to disable the lever whilst the reels are rotation
If I had more time I would improve the visual look and feel of the fruit machine. I would also have liked to implement nudge buttons aswell as hold buttons. It would have also been nice to concentrate more on the environment within which the machines were kept, which may have also included creating other machines that can be found in an arcade for example