Created
October 7, 2015 15:51
-
-
Save danaabs/e9b6360090794e4b71f5 to your computer and use it in GitHub Desktop.
ASMR Array
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
var sun; | |
var angle = 0; | |
var ring = 7; | |
var volume = 0; | |
var speed = 1; | |
var tears = []; | |
function preload() { | |
asmr = loadSound('ASMR.mp3'); | |
eye = loadImage("eyeball.png"); | |
} | |
function setup() { | |
createCanvas(800, 700); | |
angleMode(DEGREES); | |
asmr.play(); | |
for (var i = 0; i < 2; i++) { | |
tears[i] = new Tear(); | |
} | |
} | |
border = { | |
x: 0, | |
x_1: 0, | |
y: 0, | |
y_1: 0, | |
l: 5, | |
yspeed: 1, | |
xspeed: 1, | |
display: function () { | |
fill (255); | |
noStroke(); | |
rect(this.x, this.y, this.l, this.l); | |
rect(this.x_1, this.y_1, this.l, this.l); | |
rect(this.x+795, this.y, this.l, this.l); | |
rect(this.x_1, this.y_1+695, this.l, this.l); | |
}, | |
move: function () { | |
this.x_1 += this.xspeed; | |
this.y += this.yspeed; | |
if (this.y > height) { | |
this.yspeed = -this.yspeed; | |
} | |
if (this.x_1 > width) { | |
this.xspeed =+ -this.xspeed; | |
} | |
if (this.y < 0) { | |
this.yspeed = -this.yspeed; | |
} | |
if (this.x_1 < 0) { | |
this.xspeed = -this.xspeed; | |
} | |
}, | |
// speedUp: function () { | |
// if (volume > 1) { | |
// this.xspeed = this.xspeed + .2; | |
// this.yspeed = this.yspeed + .2; | |
// } | |
// } | |
// if (this.x > 780) { | |
// this.xspeed = 0; | |
// this.yspeed = -3; | |
// this.y += this.yspeed; | |
// } | |
// if (this.y < 20 ) { | |
// this.yspeed = 0; | |
// this.xspeed = -3; | |
// this.x += this.xspeed; | |
// } | |
} | |
sun = { | |
x: 120, | |
y: 120, | |
diameter: 150, | |
speed: 0.4, | |
display: function() { | |
fill(255); | |
noStroke(); | |
ellipse(this.x, this.y, this.diameter, this.diameter); | |
noFill(); | |
stroke(255); | |
strokeWeight(0.15); | |
for (var i = 0; i < ring; i++) { | |
ellipse(this.x, this.y, this.diameter*i/1.5, this.diameter*i/1.5); | |
} | |
}, | |
move: function () { | |
this.x += random(-this.speed, this.speed); | |
this.y += random(-this.speed, this.speed); | |
if (mouseIsPressed) | |
sun.diameter = sun.diameter/.9 | |
else | |
sun.diameter = 120 | |
} | |
} | |
volume_button = { | |
x: 750, | |
y: 50, | |
diameter: 30, | |
display: function () { | |
fill(100); | |
noStroke(); | |
ellipse(this.x, this.y, this.diameter, this.diameter); | |
push(); | |
translate (0, 50); | |
ellipse(this.x, this.y, this.diameter, this.diameter); | |
pop(); | |
fill(255); | |
text("+", 747, 54); | |
text("-", 748, 103); | |
} | |
} | |
eyeball = { | |
display: function () { | |
if (volume > 0.8) { | |
fill(0, 25); | |
image(eye, 75, 80, 90, 90); | |
} | |
} | |
} | |
function Tear() { | |
this.x = 120; | |
this.y = 120; | |
this.display = function () { | |
if (volume > 1) { | |
fill(random(0, 50)); | |
stroke(255); | |
bezier(this.x, this.y, this.x-70, this.y+50, this.x+50, this.y+80, this.x, this.y); | |
} | |
} | |
this.move = function () { | |
if (volume > 1) { | |
this.y = this.y + speed; | |
} | |
} | |
} | |
function mousePressed() { | |
if (mouseX > 720 && mouseX < 780 && mouseY > 20 && mouseY < 80) { | |
ring = ring + 1; | |
volume = volume + 0.1; | |
} | |
if (mouseX > 720 && mouseX < 780 && mouseY > 70 && mouseY < 130) { | |
ring = ring - 1; | |
volume = volume - 0.1; | |
} | |
tears.push(new Tear()); | |
} | |
function draw() { | |
background(0, 8); | |
asmr.setVolume(volume); | |
border.display(); | |
border.move(); | |
// border.speedUp(); | |
sun.display(); | |
sun.move(); | |
volume_button.display(); | |
eyeball.display(); | |
for (var i = 0; i < tears.length; i++) { | |
tears[i].display(); | |
tears[i].move(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment