-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
49 lines (42 loc) · 1.06 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
let img, imgEmpty;
let showGhost = true;
let ghostx = 200;
let ghosty = -20;
let ghostwidth = 600 * 0.8;
let ghostheight = 800 * 0.8;
let changeDirection;
function preload() {
img = loadImage('IMG/Geist.png');
imgEmpty = loadImage('IMG/Geist-empty.png');
}
function setup() {
let canvas = createCanvas(displayWidth, 0.6 * displayHeight);
canvas.parent('canvasForHTML');
}
function draw() {
const ghostCenter = {
x: ghostx + ghostwidth / 2,
y: ghosty + ghostheight / 2,
};
const distance = dist(ghostCenter.x, ghostCenter.y, mouseX, mouseY);
if (distance < 300) {
showGhost = false;
} else {
showGhost = true;
}
fill('#fbcfe8');
noStroke();
if (showGhost === true) {
// scale(0.3);
rect(0, 0, width, height);
image(img, ghostx, ghosty, ghostwidth, ghostheight);
console.log('showing ghost', showGhost);
} else {
rect(0, 0, width, height);
image(imgEmpty, ghostx, ghosty, ghostwidth, ghostheight);
console.log('not showing ghost', showGhost);
}
}
function next(adresse) {
window.location = adresse;
}