xxxxxxxxxx
//by Laura Konttinen
//http://www.laurakonttinen.net
let r, g, b, k1, k2, k3, k4;
let kuva;
let value = 0;
//let ennuste = 0;
let muoto = 178;
var ennusteet = ['black birds', 'rain', 'rabbits', 'water']; // a good sign
var omens = ['water', 'windows','pollen','rain']; // an omen
var ennustukset = ['not be poisoned', 'forget everything', 'gravitate towards corners', 'move slowly'];
var index = 0;
var i = 0;
// kuvien lataus
function preload() {
crow = loadImage('crow.jpg');
whitecrow = loadImage('whitecrow.jpg');
}
function setup() {
createCanvas(1000, 800);
frameRate(10);
// random värit
r = random(255);
g = random(255);
b = random(255);
kuva = crow;
k1 = 197;
k2 = 197;
k3 = 197;
k4 = 255;
words = ["your heart is pure", "your karma is 90% good", "you probably have a secret twin", "you should take the long way home"];
spring = ['meet a perfect stranger', 'improve dramatically', 'be satisfied', 'get a mysterious ache in your leg'];
june = ['laugh and not cry', 'be sorry you read the news', 'want to leave home', 'make a nest'];
autumn = ['understand', 'find an important stone', 'find a treasure no one else can', 'remember the day you have forgotten', 'be severely injured'];
//, 'take the long way home'];
}
function draw() {
background(225);
//ajat
let kk = month();
let pv = day();
let tunti = hour();
let minuutti = minute();
//tapahtuu aina:
image(kuva ,400, 200, 600, 600);
textSize(20);
fill(color('white'));
text("your lucky number is : " + minuutti, 750, 100);
fill(color(25,110,207,150));
rect(600,150,180,200);
textSize(22);
fill(color('white'));
text("a good sign:", 610,230);
text(ennusteet[index], 630, 270); // hyvät ennusteet
fill(color(178,25,207,170));
rect(800,150,180,200);
textSize(22);
fill(color('black'));
text("an omen:", 810,230);
fill(color('black'));
text(omens[index], 830, 270); // pahat merkit
fill(k3, k1, k3, k4);
ellipse(200,200,500,500);
// each time draw() is called, i is incremented by one
i = i + 1;
// joka 10. kerta tapahtuu
if (millis() > 60000) {
if (i % 10 === 0){
// fill with 50
textSize(36);
fill(249,0,0,0);
text("Warning!",50,650);
} else {
// muina kertoina tapahtuu
textSize(36);
fill(249,0,0);
text("WARNING! You are misusing the oracle!",230,650);
}
}
//perusennustukset
textSize(46);
fill(color('black'));
text("the oracle has calculated your fortune: ", 100, 70);
textSize(16);
fill(color('purple'));
text("disasters left in your life : " + pv, 100, 260);
text("steps to a secret treasure : " + 8+tunti, 100, 290);
text(kk + "% chance of a good night's sleep", 100, 320);
// ennen kesäkuuta
if (kk < 6) {
textSize(20);
fill(color('black'));
text("good news, this spring you will", 80, 150);
text(spring[index], 80, 180);
}
// kesäkuu
if (kk === 6) {
textSize(20);
fill(color('black'));
text("this summer you will", 80, 100);
text(june[index], 80, 125);
}
// loppuvuosi
if (kk > 6) {
textSize(20);
fill(color('black'));
text("by the end of the year you will", 80, 100);
text(autumn[index], 80, 125);
}
//jos 18. päivä
if (pv === 22) {
textSize(16);
fill(color('red'));
text("don't trust your lucky number today", 100, 700);
}
//ennustus
fill(value);
textSize(16);
textFont('Georgia');
text("today you will", 70, 550);
text(ennustukset[index], random(180,210), 550);
fill('purple');
text("because", 70, 590);
text(words[index], 70, 630);
//peittävä tausta
fill(k1, k2, k3, k4);
rect(0,0,1000,800);
// sumuinen oraakkeli
if (month() === 5) {
if (millis() > 70000) {
r=10;
fill(color('white'));
ellipse(500,750, r*frameCount/2, r*frameCount/2);
textSize(16);
textFont('Georgia');
fill(color('black'));
text("the oracle is gone", 440, 500);
}
if (millis() > 71000) {
text("the oracle is gone", 440, 500);
}
}
//kolmio
fill('black');
triangle(370, 470, 500, 270, 630, 470);
//kristallipallo
noStroke();
fill(r, g, b, 250);
ellipse(500, 400, 100, 100);
// kristallipallon värit, jos sitä painetaan
if(mouseIsPressed){
let d = dist(mouseX, mouseY, 500, 400);
if (d < 50) {
// Pick new random color values
r = random(255);
g = random(255);
b = random(255);
}
}
}
function mouseReleased() {
let d = dist(mouseX, mouseY, 500, 400);
if (d < 50) {
//asiat, joita tapahtuu kun päästää irti kristallipallon kohdalla
index = Math.floor(random(ennustukset.length));
index = Math.floor(random(0, omens.length));
index = Math.floor(random(0, ennusteet.length));
if (value === 0) {
value = 255;
} else {
value = 0;
}
//kuva vaihtuu
if (kuva === whitecrow) {
kuva = crow;
} else if (kuva === crow) {
kuva = whitecrow;
}
else {
kuva = crow;
}
//peittävä neliö muuttuu läpikuultavaksi
{
k1 = random(255);
k2 = random(255);
k3 = random(255);
k4 = random(0,100);
}
}
}