New account registrations are disabed. This website is now an archive. Read more here.

Unity    Posted January 19, 2015 by FleshRenderStudios

Rock Paper Sciissors (Incomplete for Unity)

Introduction

Just a small amount of script that outlays a basic rock, paper, scissors game.

 

Needs extra work to be able to be used in Unity!! (this is the base JavaScript version)

License Terms

Attribution 3.0 Unported - You must attribute the work in the manner specified by the author or licensor. Commerical use allowed.

Frequently Asked Questions

– Uses JavaScript to create a simple minigame
– Will not work in Unity without extra code

Instructions

Copy + Paste + Add extra code

 

var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
	computerChoice = "rock";
} else if(computerChoice <= 0.67) {
	computerChoice = "paper";
} else {
	computerChoice = "scissors";
} console.log("Computer: " + computerChoice);

var compare = function(choice1, choice2)
{
 if (choice1 === choice2)
 {
    return "The result is a tie!";
 }
 else if (choice1 === "rock")
 {
     if (choice2 === "scissors")
     {
         return "rock wins";
     }
     else
     {
         return "paper wins"
     }
 }
 else if (choice1 === "paper")
 {
     if (choice2 === "rock")
     {
         return "paper wins";
     }
     else
     {
         return "scissors wins"
     }
 }
 else if (choice1 === "scissors")
 {
     if (choice2 === "rock")
     {
         return "rock wins";
     }
     else
     {
         return "scissors wins"
     }
 }
}
compare(userChoice, computerChoice)

Author Notes

Feel free to adapt this for Unity

Comments (6)

Leave a Reply

FleshRenderStudios

  • Posted about 10 years ago

  • Engine
    Unity
  • Category
    Minigames
  • License
    Attribution 3.0 Unported
  • Version
    v0.5

Stats

1,227 views

6 comments

Tags

n-a