After completing the lesson in which we created the flipping a coin game, we were tasked on creating a game of Rock, Paper, Scissors using Flash.
I started by creating a new document using Actionscript 3.0 and setting a black background. I then sourced the three images of hands in the form of rock, paper and scissors ready to edit in Photoshop. I created a silhouette of each hands and increased the saturation to create them completely white. These would be used as the games buttons corresponding to the players choice. Also, I changed the images into movie clips and changed their instance names to rock, paper and scissors respectively.
Next, I created a dynamic text box in the top left of the window. This would be used to display yours and the computers choice and whether you have won, drawn or lost. Also, I created an additional 3 dynamic text boxes in the top write to display the numbers of wins, draws and losses as you progress, allowing the player to keep track of the score.
I then moved on to the code.
The next variable is the players choice, which is a string which stores the instance name of the button clicked by the player. This is why it is important that the instance name matched the previous variable.
As it mentions in the code, the computer choice variable pulls a random choice from the choicesArray variable earlier created.
Lastly, to finish the function I created an If statement which holds all the possible outcomes by comparing the players choice to the computers choice and determining whether you have won, drawn or lost. Also, creating an output text which will be displayed to the player in the dynamic text box name “output.txt” which I created at the beginning.
An example of the game running is shown below, the player has chosen rock: