random fruit baby
This file contains 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
let fruit1, fruit2, fruit3, fruit4, fruit5, fruit6; | |
let vid1, vid2, vid3, vid4, vid5, vid6; | |
function preload() { | |
fruit1 = loadSound('onepercent.wav'); | |
fruit2 = loadSound('hypergendered.wav'); | |
fruit3 = loadSound('void.wav'); | |
fruit4 = loadSound('caterpillar.wav'); | |
fruit5 = loadSound('waterbirth.wav'); | |
fruit6 = loadSound('commune.wav'); | |
} | |
var seed = 987654; | |
function myRandom() { | |
//console.log("start", seed); | |
seed = (seed * seed).toString(); | |
//console.log("after squaring/string", seed); | |
while (seed.length < 10) { | |
seed = '0' + seed; | |
} | |
//console.log("after zero padding", seed); | |
seed = seed.substr(2, 6); | |
//console.log("after substr", seed); | |
seed = parseInt(seed); | |
//console.log("after parseint", seed); | |
return seed / 1000000; | |
} | |
function setup() { | |
createCanvas(windowWidth, windowHeight); | |
vid1 = createVideo('fruit1.mp4', vidLoad); | |
vid1.hide(); | |
vid2 = createVideo('fruit2.mp4', vidLoad); | |
vid2.hide(); | |
vid3 = createVideo('fruit3.mp4', vidLoad); | |
vid3.hide(); | |
vid4 = createVideo('fruit4.mp4', vidLoad); | |
vid4.hide(); | |
vid5 = createVideo('fruit5.mp4', vidLoad); | |
vid5.hide(); | |
vid6 = createVideo('fruit6.mp4', vidLoad); | |
vid6.hide(); | |
} | |
function vidLoad() { | |
vid1.play(); | |
vid1.loop(); | |
vid2.play(); | |
vid2.loop(); | |
vid3.play(); | |
vid3.loop(); | |
vid4.play(); | |
vid4.loop(); | |
vid5.play(); | |
vid5.loop(); | |
vid6.play(); | |
vid6.loop(); | |
} | |
function draw() { | |
let thing = int(5 * myRandom()); | |
let vids = [vid1, vid2, vid3, vid4, vid5, vid6]; | |
// console.log(thing); | |
background(0); | |
image(vids[thing], 0, 0, windowWidth / 3, windowHeight / 2); | |
image(vids[thing], windowWidth / 3, 0, windowWidth / 3, windowHeight / 2); | |
image(vids[thing], 2 * windowWidth / 3, 0, windowWidth / 3, windowHeight / 2); | |
image(vids[thing], 0, windowHeight / 2, windowWidth / 3, windowHeight / 2); | |
image(vids[thing], windowWidth / 3, windowHeight / 2, windowWidth / 3, windowHeight / 2); | |
image(vids[thing], 2 * windowWidth / 3, windowHeight / 2, windowWidth / 3, windowHeight / 2); | |
} | |
function mousePressed() { | |
let sound = int(5 * myRandom()); | |
let messages = [fruit1, fruit2, fruit3, fruit4, fruit5, fruit6]; | |
// console.log(sound); | |
if (mouseX > 0 && mouseX < windowWidth / 3 && mouseY > 0 && mouseY < windowHeight / 2) { | |
messages[sound].play(); | |
} else if (mouseX > windowWidth / 3 && mouseX < 2 * windowWidth / 3 && mouseY > 0 && mouseY < windowHeight / 2) { | |
messages[sound].play(); | |
} else if (mouseX > 2 * windowWidth / 3 && mouseX < windowWidth && mouseY > 0 && mouseY < windowHeight / 2) { | |
messages[sound].play(); | |
} else if (mouseX > 0 && mouseX < windowWidth / 3 && mouseY > windowHeight / 2 && mouseY < windowHeight) { | |
messages[sound].play(); | |
} else if (mouseX > windowWidth / 3 && mouseX < 2 * windowWidth / 3 && mouseY > windowHeight / 2 && mouseY < windowHeight) { | |
messages[sound].play(); | |
} else if (mouseX > 2 * windowWidth / 3 && mouseX < windowWidth && mouseY > windowHeight / 2 && mouseY < windowHeight) { | |
messages[sound].play(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment