This is the story of a typical student’s school day in 2020. Taken from personal experiences, the student wakes up to the sound of alarm, goes to their desk and begins zoom classes, which lasts all day long and late into the night. This all happens while chaos happens outside in the world.
// This is the story of a typical student's school day in 2020. Taken
// from personal experiences, the student wakes up to the sound of alarm, goes
// to their desk and begins zoom classes, which lasts all day long and late
// into the night. This all happens while chaos happens outside in the world.
//background images
var night;
var dayTime;
var rain;
var explosion;
var fire;
//room drawings
var room;
var laptop;
var laptopOn;
var person;
var personUp;
//sound variables
var alarm;
var rainSound;
var explosionSound;
var fireSound;
//variables for person
var persX = 114;
var persY = 257;
var dx = 15;
var frameCount = 0;
function preload() {
night = loadImage("https://i.imgur.com/CVsqShg.jpg");
dayTime = loadImage("https://i.imgur.com/p6oDy63.png");
rain = loadImage("https://i.imgur.com/8HtRKjL.jpg");
explosion = loadImage("https://i.imgur.com/pEYPUbF.jpg");
fire = loadImage("https://i.imgur.com/4Sw63js.png");
room = loadImage("https://i.imgur.com/vWPprEt.png");
laptop = loadImage("https://i.imgur.com/qVHI1Ji.png");
laptopOn = loadImage("https://i.imgur.com/qKDrh3W.png");
person = loadImage("https://i.imgur.com/Eq6Rz4S.png");
personUp = loadImage("https://i.imgur.com/s09ZZmK.png");
//load sound
alarm = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/alarm-clockk.wav")
rainSound = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/rainn.wav")
explosionSound = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/explosionn.wav")
fireSound = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/firee.wav")
}
function setup() {
createCanvas(500, 400);
imageMode(CENTER)
frameRate(5);
useSound();
}
function soundSetup() {
alarm.setVolume(0.8);
rainSound.setVolume(0.8);
explosionSound.setVolume(0.5);
fireSound.setVolume(0.8);
}
function draw() {
//drawing all the backdrops with their relative sounds
if (frameCount < 20) {
nightDraw();
alarm.play();
} else if (frameCount > 20 & frameCount < 80) {
dayTimeDraw();
} else if (frameCount > 80 & frameCount < 100) {
rainDraw();
rainSound.play();
} else if (frameCount > 100 & frameCount < 120) {
explosionDraw();
explosionSound.play();
} else if (frameCount > 120 & frameCount < 140) {
fireDraw();
fireSound.play();
} else {
nightDraw();
}
//drawing everything in the room
roomDraw();
personDraw();
personUpDraw();
laptopDraw();
laptopOnDraw();
frameCount += 1;
}
//all the backdrops
function nightDraw() {
image(night, width/2, height/2, 500, 400);
}
function dayTimeDraw() {
image(dayTime, width/2, height/2, 500, 400);
}
function rainDraw() {
image(rain, width/2, height/2, 500, 400);
}
function explosionDraw() {
image(explosion, width/2, height/2, 500, 400);
}
function fireDraw() {
image(fire, width/2, height/2 - 50, 500, 350);
}
//everything else in the room
function roomDraw() {
image(room, width/2, height/2, 500, 400);
}
function personDraw() {
if (frameCount < 30) {
image(person, persX, persY, 160, 40);
}
}
function personUpDraw() {
if (frameCount > 30) { //person gets up after alarm sounds
image(personUp, persX, persY, 40, 160);
if (frameCount < 67) {
persX += dx;
}
}
}
function laptopDraw() {
image(laptop, 430, 280, 150, 120);
}
function laptopOnDraw() {
if (frameCount > 70) { //laptop opens when person walks to desk
image(laptopOn, 430, 280, 150, 120);
}
}