|
|
@@ -0,0 +1,46 @@
|
|
|
+/**Decompose game into the different parts
|
|
|
+ * Clicking button will choose R,P,or S - check frameIndexes
|
|
|
+ * Image will show on screen based on button clicked
|
|
|
+ * Computer will choose R P or S - random(2,0) - 0,1,2
|
|
|
+ * Image for Computer's choice shown frameIndex (0,1,2)
|
|
|
+ * Win conditionals will be analyzed - if() conditions
|
|
|
+ * Result is shown (win or lose or tie)
|
|
|
+ **/
|
|
|
+
|
|
|
+/**Look at RPS1 Animations for frameIndex:
|
|
|
+ * 0 - paper
|
|
|
+ * 1 - rock
|
|
|
+ * 2 - scissors
|
|
|
+ **/
|
|
|
+
|
|
|
+//Scene - Initialize When Scene Starts
|
|
|
+//Nothing picked yet, so big images should be hidden
|
|
|
+RPS1.visible(false);
|
|
|
+RPS2.visible(false);
|
|
|
+//results says "Will You Play?"
|
|
|
+//Ninja could change it to a welcome text
|
|
|
+results.text("Welcome to RPS v.1.0");
|
|
|
+
|
|
|
+//paperButton - Mouse Click Event [0]
|
|
|
+//generate the computer's choice
|
|
|
+var compChoice = random(0,2);
|
|
|
+
|
|
|
+//Show your choice on RPS1
|
|
|
+RPS1.frameIndex(0);
|
|
|
+RPS1.visible(true);
|
|
|
+
|
|
|
+//Show computer's choice on RPS2
|
|
|
+RPS2.frameIndex(compChoice);
|
|
|
+RPS2.visible(true);
|
|
|
+
|
|
|
+//Win Conditionals:
|
|
|
+
|
|
|
+if (compChoice == 1) { //Comnputer chose rock [1]
|
|
|
+ result.text("You Win!");
|
|
|
+} else if (compChoice == 2) { //Computer chose scissors [2]
|
|
|
+ results.text("You lost!");
|
|
|
+} else { //Do we need to type the condition? If it didn't choose rock
|
|
|
+ //or scissors, it must have chosen paper
|
|
|
+ results.text("It's a tie!")
|
|
|
+}
|
|
|
+
|