-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
90 lines (82 loc) · 2.63 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
const buttonBox=document.querySelector('#buttonBox');
const infoModal=document.querySelector("#infoModal");
const notThing=document.getElementById('notThing');
const aboutme=document.getElementById('aboutme');
const ghost=document.querySelectorAll('#ghost');
const follow=document.getElementById('follow');
const amount=document.getElementById('amount');
const github=document.getElementById('github');
const close=document.querySelector("#close");
const body=document.getElementById('body');
const Name=document.getElementById('name');
const odiv=document.querySelector('.main');
const img=document.getElementById('img');
const box=document.getElementById('box');
const pr=document.getElementById('pr');
let number=0;
let gamount=0;
img.onclick=function(){
if (img.classList=='img') {
box.classList='box';
Name.classList='name';
amount.classList='amount';
}
img.classList='imgClick';
buttonBox.classList='buttonBox';
}
aboutme.onclick=function(){
pr.classList='none';
box.classList='box';
}
github.onclick=function(){
pr.classList='pr';
box.classList='none';
}
document.addEventListener('mousemove', function(e) {
let x = e.clientX;
let y = e.clientY;
let div_x=odiv.getBoundingClientRect().left;
let div_y=odiv.getBoundingClientRect().top;
if(x>=div_x & x<=div_x+800 & y>=div_y & y<=div_y+400){
follow.classList='none';
body.style.cursor='auto';
}
else{
body.style.cursor='none';
follow.classList='follow';
follow.style.left = x - 50 + 'px';
follow.style.top = y - 50 + 'px';
follow.style.backgroundPosition = -x + 'px ' + -y + 'px';
}
});
ghost.forEach(element => {
div_x=odiv.getBoundingClientRect().left;
div_y=odiv.getBoundingClientRect().top;
number+=1;
element.classList='ghost'+number;
const set=document.querySelector('.ghost'+number);
element.addEventListener('click', function(){
gamount+=1;
set.classList="none";
document.getElementById('dead'+gamount).classList='';
});
while (true) {
let x=Math.floor(Math.random() * ((body.getBoundingClientRect().right - 64) + 1));
let y=Math.floor(Math.random() * ((body.getBoundingClientRect().bottom - 64) + 1));
set.style.left=x+'px';
set.style.top=y+'px';
if(x>=div_x-50 & x<=div_x+850 & y>=div_y-50 & y<=div_y+450){
continue;
}else{
break;
}
}
});
notThing.addEventListener("click", function(){
infoModal.showModal();
infoModal.className="";
})
close.addEventListener("click", function(){
infoModal.className="none";
infoModal.close();
})