-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
72 lines (61 loc) · 1.23 KB
/
index.html
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
<style>
body {
background-color:black;
}
#dvdImg {
width:350px;
position:absolute;
top:0;
left:0;
}
</style>
<img src="images/dvd-1.png" id="dvdImg"/>
<script>
myY = 0;
myX = 0;
myYDown = true;
myXRight = true;
myColor = 1;
setInterval(function(){
myDVDLogo = document.getElementById("dvdImg");
if(myColor == 5){
myColor = 1;
}
if(myYDown == true){
myY++;
} else {
myY--;
}
if(myXRight == true){
myX++;
} else {
myX--;
}
if(myX == 0){
console.log("Bump on the left, swapping");
myXRight = true;
myDVDLogo.src = "images/dvd-"+myColor+".png";
myColor++;
}
if(myY == 0){
console.log("Bump on the top, swapping");
myYDown = true;
myDVDLogo.src = "images/dvd-"+myColor+".png";
myColor++;
}
if(myX == (window.innerWidth - myDVDLogo.width)){
console.log("Bump on the right, swapping");
myXRight = false;
myDVDLogo.src = "images/dvd-"+myColor+".png";
myColor++;
}
if(myY == (window.innerHeight - myDVDLogo.height)){
console.log("Bump on the bottom, swapping");
myYDown = false;
myDVDLogo.src = "images/dvd-"+myColor+".png";
myColor++;
}
myDVDLogo.style.top = myY;
myDVDLogo.style.left = myX;
}, 6);
</script>