-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhome.html
110 lines (109 loc) · 4.56 KB
/
home.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="game.js" type="text/javascript"></script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Dimension</title>
</head>
<body>
<div class="center"><p id="title"></p></div>
<div id="pane" style="width:null; height:null;">
<img src="images/box.svg" id="box" style="left:null; top:null;">
<img src="images/enemy.gif" class="enemy" id="enemy" style="left:0px; top:0px;">
<img src="images/enemy.gif" class="enemy" id="enemy" style="left:10px; top:0px;">
</div>
<!-- <div id="box" style="left:null; top:null;"><h2 class="center"></></h2></div> --->
<script>
//---Set play area based on screen size---
var screenHeight = document.documentElement.clientHeight - 35;
var screenWidth = document.documentElement.clientWidth - 35;
var screenHeightPX = document.documentElement.clientHeight - 20 + "px";
var screenWidthPX = document.documentElement.clientWidth - 20 + "px";
document.getElementById("pane").style.width = screenWidthPX;
document.getElementById("pane").style.height = screenHeightPX;
//---End play area---
//---Moves the enemy randomly---
function moveEnemy(){
$('.enemy').each(function(){
topAdjust = Math.floor((Math.random() * screenHeight) + 1);
leftAdjust = Math.floor((Math.random() * screenWidth) + 1);
$(this).animate({"top": topAdjust + "px", "left": leftAdjust + "px"}, {duration: 3000, specialEasing: {top: 'linear', left: 'linear'}});
//$(this).animate({"left": leftAdjust + "px"}, {specialEasing: "linear", queue: false });
});
}
setInterval(moveEnemy, 3000);
//---End move enemy---
//---Center Box---
document.getElementById("box").style.left = (document.documentElement.clientWidth) * .5 + "px";
document.getElementById("box").style.top = (document.documentElement.clientHeight) * .5 + "px";
//---End Center Box---
//---Title display when site loads---
titlefunc();
function titlefunc() {
document.getElementById("title").innerHTML = "P";
function t2() {document.getElementById("title").innerHTML = "PA";}
function t3() {document.getElementById("title").innerHTML = "PAC";}
function t4() {document.getElementById("title").innerHTML = "PACK";}
function t5() {document.getElementById("title").innerHTML = "PACKE";}
function t6() {document.getElementById("title").innerHTML = "PACKET";}
function t7() {document.getElementById("title").innerHTML = "PACKET ";}
function t8() {document.getElementById("title").innerHTML = "PACKET L";}
function t9() {document.getElementById("title").innerHTML = "PACKET LO";}
function t10() {document.getElementById("title").innerHTML = "PACKET LOS";}
function t11() {document.getElementById("title").innerHTML = "PACKET LOSS";}
setTimeout(t2, 250);
setTimeout(t3, 500);
setTimeout(t4, 750);
setTimeout(t5, 1000);
setTimeout(t6, 1250);
setTimeout(t7, 1500);
setTimeout(t8, 1750);
setTimeout(t9, 2000);
setTimeout(t10, 2250);
setTimeout(t11, 2500);
setTimeout(fadeTitle, 3000);
setTimeout(fadeD1, 3500);
function fadeTitle(){
$("#title").fadeOut();
}
function fadeD1(){
$("#box").fadeIn("slow");
}
control();
}
//--- End Title---
//---Box Control---
function control() {
var pane = $('#pane'),
box = $('#box'),
wh = pane.width() - box.width(),
wv = pane.height() - box.height(),
d = {},
x = 5;
function newh(v,a,b) {
var n = parseInt(v, 10) - (d[a] ? x : 0) + (d[b] ? x : 0);
return n < 0 ? 0 : n > wh ? wh : n;
}
function newv(v,a,b) {
var n = parseInt(v, 10) - (d[a] ? x : 0) + (d[b] ? x : 0);
return n < 0 ? 0 : n > wv ? wv : n;
}
$(window).keydown(function(e) { d[e.which] = true; });
$(window).keyup(function(e) { d[e.which] = false; });
setInterval(function() {
box.css({
left: function(i,v) { return newh(v, 65, 68); },
top: function(i,v) { return newv(v, 87, 83); }
});
wh = pane.width() - box.width();
wv = pane.height() - box.height();
}, 20);
}
//---End Box Control---
</script>
</body>
</html>