Unity
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
You must be logged in to post a comment.
Polraudio
Wheres the script?
FleshRenderStudios
I forgot to add it lol my bad :p will be up in 2 mins
Polraudio
I just thought of a way to make RPS's even more interesting using RPG elements. You get Rock, Paper, and Scissors to pick but each of them has a HP bar/value. So if one wins it takes off HP from the losing one. When the HP runs out you can no longer play that type.
FleshRenderStudios
hmm difficult to code (for me atleast it would be) but would be interested in seeing what that looks like 🙂 I just got to learning for and while loops my favorite part….. -_- oh btw check out my status 🙂
Polraudio
Title looks very awesome. If you want to add GUI theres a very awesome place where i learned how to make GUI. http://docs.unity3d.com/Manual/gui-Basics.html
FleshRenderStudios
ty but I don't have unity installed at the minute lol but yeah GUI is something i will look into after I finish my JS course 🙂