-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscriptold.js
More file actions
68 lines (62 loc) · 2.1 KB
/
scriptold.js
File metadata and controls
68 lines (62 loc) · 2.1 KB
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
const monster = document.getElementById('monster');
const inputUsuario = document.getElementById('input-usuario');
const inputClave = document.getElementById('input-clave');
const body = document.querySelector('body');
const anchoMitad = window.innerWidth / 2;
const altoMitad = window.innerHeight / 2;
let seguirPunteroMouse = true;
body.addEventListener('mousemove', (m) => {
if (seguirPunteroMouse) {
if (m.clientX < anchoMitad && m.clientY < altoMitad) {
monster.src = "asset/imagens/idle/2.png";
} else if (m.clientX < anchoMitad && m.clientY > altoMitad) {
monster.src = "asset/imagens/idle/3.png";
} else if (m.clientX > anchoMitad && m.clientY < altoMitad) {
monster.src = "asset/imagens/idle/5.png";
} else {
monster.src = "asset/imagens/idle/4.png";
}
}
})
inputUsuario.addEventListener('focus',()=>{
seguirPunteroMouse = false;
})
inputUsuario.addEventListener('blur',()=>{
seguirPunteroMouse = true;
})
inputUsuario.addEventListener('keyup',()=>{
let usuario = inputUsuario.value.length;
if(usuario >= 0 && usuario<=5){
monster.src = 'assets/imagens/read/1.png';
}else if(usuario >= 6 && usuario<=14){
monster.src = 'assets/imagens/read/2.png';
}else if(usuario >= 15 && usuario<=20){
monster.src = 'assets/imagens/read/3.png';
}else{
monster.src = 'assets/imagens/read/4.png';
}
})
inputClave.addEventListener('focus',()=>{
seguirPunteroMouse = false;
let cont = 1;
const cubrirOjo = setInterval(() => {
monster.src = 'asset/imagens/cover/'+cont+'.png';
if(cont < 8){
cont++;
}else{
clearInterval(cubrirOjo);
}
}, 60);
})
inputClave.addEventListener('blur',()=>{
seguirPunteroMouse = true;
let cont = 7;
const descubrirOjo = setInterval(() => {
monster.src = 'asset/imagens/cover/'+cont+'.png';
if(cont > 1){
cont--;
}else{
clearInterval(descubrirOjo);
}
}, 60);
})