Created
September 11, 2015 14:44
-
-
Save bmoren/0efc47ba446e9dceac71 to your computer and use it in GitHub Desktop.
High/Low Snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//compare 2 values | |
var randStorage = 0; | |
var previousRandom = 0; | |
function setup() { | |
} | |
function draw() { | |
} | |
function mousePressed(){ | |
previousRandom = randStorage; | |
randStorage = random(0,100); | |
if (randStorage < PreviousRandom){ | |
print("new # is less than old #"); | |
} | |
print("previousRandom: " + previousRandom); | |
print("randStorage: " + randStorage); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//store a score | |
//how to store a previous value | |
var randStorage = 0; | |
var previousRandom = 0; | |
var score = 0; | |
function setup() { | |
} | |
function draw() { | |
} | |
function mousePressed(){ | |
previousRandom = randStorage; | |
randStorage = random(0,100); | |
//this is not the full solution, but just a piece, remember that you need to have the user choose to be higher or lower and react accordingly. | |
if (randStorage < PreviousRandom){ | |
print("new # is less than old #"); | |
score++ | |
}else{ | |
score = 0; | |
} | |
print("previousRandom: " + previousRandom); | |
print("randStorage: " + randStorage); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//how to store a previous value | |
var randStorage = 0; | |
var previousRandom = 0; | |
function setup() { | |
} | |
function draw() { | |
} | |
function mousePressed(){ | |
previousRandom = randStorage; | |
randStorage = random(0,100); | |
print("previousRandom: " + previousRandom); | |
print("randStorage: " + randStorage); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//How to store a random # on mouse click | |
var randStorage = 0; | |
function setup() { | |
} | |
function draw() { | |
print(randStorage); | |
} | |
function mousePressed(){ | |
randStorage = random(0,100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment