-
Notifications
You must be signed in to change notification settings - Fork 0
/
mausMove.js
57 lines (49 loc) · 1.34 KB
/
mausMove.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
var mauss = document.getElementsByClassName("maus")
let mausNumber = 0
let mausXArray = []
function movemaus(mausX, Currentmaus, mauss) {
mauss[Currentmaus].style.left = mausX
if((mausX < 10 && mausX > 2) && (catY < 10)){
mauss[Currentmaus].style.display = "none"
mausBonus = true
}
if(gameOver){
return
}
setTimeout(function() {
mauss[Currentmaus].style.left = (mausX + "%")
if (mausX > -5) {
mausX -= 1;
movemaus(mausX, Currentmaus, mauss);
} else {
mauss[Currentmaus].style.display = "none";
}
}, 20 / gamespeed)
}
function spawnmaus(mausXArray, mausNumber, mauss){
if(gameOver){
return
}
setTimeout(function(){
if (Math.floor(Math.random() * 10) < 4){
mausXArray[mausNumber] = 95;
mauss[mausNumber].style.display = "block"
movemaus(mausXArray[mausNumber], mausNumber, mauss)
mausNumber++
if(mausNumber == 3){
mausNumber = 0
}
}
spawnmaus(mausXArray, mausNumber, mauss)
},RanomTime())
}
function RanomTime() {
number = (Math.random() + 1)* 2000 / gamespeed
return number
}
function DelayStart() {
setTimeout(function(){
spawnmaus(mausXArray, mausNumber, mauss)
},2000)
}
DelayStart()