-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
52 lines (40 loc) · 1.53 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
console.log("file loaded");
var possible_moves = ["rock", "paper", "scissors"];
var playerChoice, outcome;
var user_input;
function play(){
user_input = document.getElementById("user-input");
playerChoice = user_input.value;
console.log(playerChoice);
compare();
}
function compare(){
var i = Math.floor(Math.random()*3);
var computerChoice = possible_moves[i];
if(playerChoice === "rock" || playerChoice === "paper" || playerChoice === "scissors"){
if(playerChoice === computerChoice){
outcome = playerChoice + " vs. " + computerChoice + ". tied bro try again";
} else if(playerChoice === "paper" && computerChoice === "rock" || playerChoice === "scissors" && computerChoice === "paper" || playerChoice === "rock" && computerChoice === "scissors") {
outcome = playerChoice + " vs. " + computerChoice + ". damn you won";
} else outcome = playerChoice + " vs. " + computerChoice + ". haha you lost";
}
else outcome = "what? you have to pick either rock, paper, or scissors";
var outcome_div = document.getElementById("outcome");
outcome_div.innerHTML = outcome;
}
// processing
var canvas;
var hue = 200;
function setup(){
canvas = createCanvas(windowWidth, windowHeight);
canvas.position(0, 0);
canvas.style("z-index: -5;");
colorMode(HSB, 360, 100, 100);
}
function draw(){
background(hue, 15, 100);
hue = map(mouseX, 0, width, 150, 250);
}
function windowResized(){
resizeCanvas(windowWidth, windowHeight);
}