xxxxxxxxxx
96
let song;
function preload()
{
song = loadSound('Iyaz - Replay with lyrics.mp3');
}
function setup() {
getAudioContext(). suspend();
song.play();
song.loop();
createCanvas(400, 400);
background(0); //black background
let g = (200);
let r = (0);
let b = (0);
circle(100, 100, 5); //stars - start
circle(300, 350, 5);
circle(10, 380, 5);
circle(350, 40, 5);
circle(220, 220, 5);
circle(80, 300, 5);
circle(280, 120, 5);
circle(180, 20, 5);
circle(50, 30, 5);
circle(340, 260, 5);
circle(50, 200, 5);
circle(160, 350, 5); //stars - end
fill(r, g, b); //alien face - start
ellipse(200, 200, 200, 300);
fill(0);
ellipse(150, 150, 50, 120);
ellipse(250, 150, 50, 120);
stroke(0);
strokeWeight(4);
noFill();
curve(150, 200, 175, 270, 225, 270, 250, 200); //alien face - end
fill(255);
text('press the screen and wait for music!', 5, 395); //intructions
}
function draw() {
let g = (200);
let r = (0);
let b = (0);
let star = random(0, 1);
if (star < .5) {
circle(100, 100, 6); //stars - start
circle(300, 350, 6);
circle(10, 380, 6);
circle(350, 40, 6);
circle(80, 300, 6);
circle(180, 20, 6);
circle(50, 30, 6);
circle(340, 260, 6);
circle(50, 200, 6);
circle(160, 350, 6); //stars - end
} else {
circle(100, 100, 8); //stars - start
circle(300, 350, 8);
circle(10, 380, 8);
circle(350, 40, 8);
circle(160, 350, 8);
circle(80, 300, 8);
circle(180, 20, 8);
circle(50, 30, 8);
circle(340, 260, 8);
circle(50, 200, 8);
//stars - end
}
if (mouseIsPressed) {
userStartAudio();
stroke(r, g, b);
line(25, 50, 25, 80); //h(letter)
line(45, 50, 45, 80);
line(25, 65, 45, 65);
line(55, 50, 75, 50); //i(letter)
line(55, 80, 75, 80);
line(65, 50, 65, 80);
line (85, 50, 85, 70); //!
line(85, 78, 85, 80); //!
stroke(0);
}
}