-
Notifications
You must be signed in to change notification settings - Fork 0
/
Script.js
73 lines (73 loc) · 1.97 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
var catsPics = {
0: {
name: "American Shorthair",
url: "https://i.ibb.co/ykGS2qH/American-Shorthair.png"
},
1: {
name: "British Shorthair",
url: "https://i.ibb.co/Tct9GVp/British-Shorthair.png"
},
2: {
name: "Maine Coon",
url: "https://i.ibb.co/MkCNBVk/Maine-Coon.png"
},
3: {
name: "Selkirk Rex",
url: "https://i.ibb.co/0JwqkBB/Selkirk-Rex-removebg-preview.png"
},
4: {
name: "Ragdoll",
url: "https://i.ibb.co/4SvgTfC/Khao-Manee.png"
},
5: {
name: "Toyger",
url: "https://i.ibb.co/nLfYG1C/Toyger.png"
},
6: {
name: "Cat 1",
url: "https://i.ya-webdesign.com/images/cats-image-white-background-png-1.png"
},
7: {
name: "Cat 2",
url: "https://www.pngonly.com/wp-content/uploads/2017/06/Cat-Sweet-PNG-File.png"
},
8: {
name: "Cat 3",
url: "https://lh3.googleusercontent.com/proxy/0CfSrL7NlqEa-sJgAsnfJHPMJECqlVp8Vp60Ha05IbPugdHPx2913ndWchdfTznJ8skvoXUb1a769H5O84TSzS54oBCxHhKnSocTmlumLuiCmPCDRRx4RevFcg"
},
9: {
name: "Cat 4",
url: "https://i2.wp.com/freepngimages.com/wp-content/uploads/2014/04/tabbycat_2.png?fit=220%2C220"
},
10: {
name: "Cat 5",
url: "https://pluspng.com/img-png/cat-png-cat-png-hd-1500.png"
}
};
var catPic;
var catX;
var catY;
var windowW = window.innerWidth;
var windowH = window.innerHeight;
function addCat() {
catPic = Math.floor(Math.random() * Object.keys(catsPics).length);
catX = Math.random() * windowW;
catY = Math.random() * windowH;
document.body.innerHTML += `<img src="${catsPics[catPic].url}" style="bottom: ${catY}px;right:${catX}px" alt="${catsPics[catPic].name}">`;
requestAnimationFrame(addCat)
cats = document.getElementsByTagName("img");
if (cats.length > 1000) {
if (cats[0].alt.charAt(0) == "A") {
console.log("An " + cats[0].alt + " was removed");
} else {
console.log("A " + cats[0].alt + " was removed");
}
cats[0].remove();
}
}
addCat();
//setInterval(addCat, 100);
window.addEventListener("resize", function() {
windowW = window.innerWidth;
windowH = window.innerHeight;
});