-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
146 lines (145 loc) · 5.86 KB
/
index.html
File metadata and controls
146 lines (145 loc) · 5.86 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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<html>
<head>
<title>Endless Pinball</title>
<script src='lib/planck-with-testbed.min.js'></script>
<script src='lib/three.js' type='text/javascript'></script>
<script src='lib/stats.min.js' type='text/javascript'></script>
<style>
body {
margin: 0px;
font-family: serif;
color: #2c2c2c;
cursor: crosshair;
}
#game, #map {
float:left;
}
#debug {
bottom: 0px;
font-family: monospace;
position: absolute;
z-index: 99;
color: #fff;
display: none;
}
#debug > div{
padding-left: 20px;
float: left;
}
a, p {
color: #fff;
text-decoration: none;
}
</style>
</head>
<body style='background-color: #000000'>
<div id='top' style='height: 600px; overflow: hidden;'>
<div id='game' style='width: 800px; height:600px;'></div>
</div>
<div id='debug'>
<div>THREE
<ul class='three'>
<li id='x-pos'></li>
<li id='z-pos'></li>
<li id='angle'></li>
</ul>
</div>
<div>Box2d
<ul class='box2d'>
<li id='x-pos'></li>
<li id='y-pos'></li>
<li id='table-x-pos'></li>
<li id='table-y-pos'></li>
<li id='angle'></li>
<li id='ball-lv'></li>
<li id='flipperangle'></li>
</ul>
</div>
</div>
<div style="position: absolute; bottom: 0px; left: 0px;">
<p>LCTRL/RCTRL</p>
<p>A/D, L/R Arrows</p>
<p>Touch L/R sides</p>
</div>
<div style='position: absolute; bottom: 0px; right: 0px'>
<span id="testbed-info"></span>
<span id="testbed-status"></span>
<button id="testbed-play" style="display: none"></button>
<a href='http://minkcv.com' target="_blank">minkcv.com</a><br>
</div>
<script>
var debug = !location.origin.includes('github.io');
var threed = document.getElementById('game');
var stats = new Stats();
stats.showPanel( 0 ); // 0: fps, 1: ms, 2: mb, 3+: custom
document.body.appendChild( stats.dom );
if (!debug) {
document.body.removeChild(stats.dom);
threed.style.float = 'none';
threed.style.marginLeft = 'auto';
threed.style.marginRight = 'auto';
document.getElementById('debug').style.display = 'none';
threed.style.width = '100%';
threed.style.height = '100%';
document.getElementById('top').style.height = '100%';
}
var touches = {};
var keysDown = [];
var keys = { right: "ArrowRight", left: "ArrowLeft", lshift: "ShiftLeft", rshift: "ShiftRight", r: "KeyR", a: "KeyA", d: "KeyD", lctrl: "ControlLeft", rctrl: "ControlRight", touchleft: "touchleft", touchright: "touchright"};
addEventListener("keydown", function(e) {
keysDown[e.code] = true;
}, false);
addEventListener("keyup", function(e) {
delete keysDown[e.code];
}, false);
addEventListener('resize', function(e) {
TH.resize(threed.clientWidth, threed.clientHeight);
}, false);
addEventListener('touchstart', function(e) {
e.preventDefault();
for (var c in event.changedTouches) {
var change = event.changedTouches[c];
var touch = { x: change.pageX, y: change.pageY };
touches[change.identifier] = touch;
if (touch.x < window.innerWidth / 2) {
keysDown["touchleft"] = true;
touch.left = true;
}
if (touch.x > window.innerWidth / 2) {
keysDown["touchright"] = true;
touch.right = true;
}
}
}, false);
addEventListener('touchend', function(e) {
e.preventDefault();
for (var c in event.changedTouches) {
var change = event.changedTouches[c];
var touch = { x: change.pageX, y: change.pageY };
delete touches[change.identifier];
if (touch.x < window.innerWidth / 2)
delete keysDown["touchleft"];
if (touch.x > window.innerWidth / 2)
delete keysDown["touchright"];
}
});
addEventListener('touchmove', function(e) {
e.preventDefault();
for (var c in event.changedTouches) {
var change = event.changedTouches[c];
var touch = touches[change.identifier];
if (change.pageX < window.innerWidth / 2)
if (touch.right)
delete keysDown["touchright"];
if (change.pageX > window.innerWidth / 2)
if (touch.left)
delete keysDown["touchleft"];
}
});
</script>
<script src='util.js' type='text/javascript'></script>
<script src='TH.js' type='text/javascript'></script>
<script src='PL.js' type='text/javascript'></script>
<script src='main.js' type='text/javascript'></script>
</body>
</html>