-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshoot.html
More file actions
68 lines (68 loc) · 1.9 KB
/
shoot.html
File metadata and controls
68 lines (68 loc) · 1.9 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
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Space Shooter</title>
<style>
#range{
position: absolute;
top: 0; left: 0;
background: url(http://pic.58pic.com/58pic/13/17/93/44G58PICAwu_1024.jpg);
background-size: 100%;
cursor: crosshair;
width: 100%;
height: 100%;
}
#img1{
position: absolute;
border: none;
left: 0;
padding: 10px;
height: 50px;
width: 50px;
}
#score{
font: 16px normal arial, verdana, sans-serif;
color: #ffffff;
padding: 10px;
}
</style>
</head>
<body>
<div id="range">
<div id="score"></div>
<img src="http://img.sootuu.com/vector/2006-4/20064249177514.jpg" alt="Fire!" id="img1"/>
</div>
<script>
var timer = null;
var e1 = null;
var score = 0;
var shots = 0;
function moveIt() {
if(parseInt(e1.style.left) > (screen.width - 150)) {
e1.style.left = 0;
}
e1.style.left = parseInt(e1.style.left) + 6 + 'px';
e1.style.top = 100 + (80 * Math.sin(parseInt(e1.style.left)/50)) + 'px';
timer = setTimeout(moveIt, 25);
}
function scoreUp() {
score++;
}
function scoreboard() {
document.getElementById("score").innerHTML = "Shots: " + shots + " Score: " + score;
}
window.onload = function () {
e1 = document.getElementById("img1");
e1.onclick = scoreUp;
document.getElementById("range").onclick = function () {
shots++;
scoreboard();
}
scoreboard();
e1.style.left = '50px';
moveIt();
}
</script>
</body>
</html>