forked from Geovannarc/doctorvid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
255 lines (216 loc) · 7.26 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
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, minimal-ui, shrink-to-fit=no" />
<meta name="color-scheme" content="dark" />
<title>Doctorvid</title>
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap" rel="stylesheet" />
<style type="text/css">
html {
height: 100%;
min-height: 100%;
max-height: 100%;
}
body, input, textarea, select {
font: normal 30px sans-serif;
}
body {
background: #000;
padding: 0;
margin: 0;
color: #fff;
height: 100%;
min-height: 100%;
max-height: 100%;
overflow: hidden;
}
#divParent {
padding: 0;
margin: 0;
display: table;
}
#divGame {
padding: 0;
margin: 0;
width: 100%;
min-width: 100%;
height: 100%;
min-height: 100%;
display: table-cell;
vertical-align: middle;
}
canvas {
margin: 0 auto;
}
#div {
font: normal 10px 'Press Start 2P';
pointer-events: none;
width: 0;
height: 0;
overflow: hidden;
position: absolute;
z-index: -1;
}
</style>
</head>
<body>
<div id="div">1234567890!:?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</div>
<div id="divParent"><div id="divGame"></div></div>
<script type="text/javascript" src="phaser-2.6.2.min.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript" id="loaderScript">
//<![CDATA[
"use strict";
var game = new Phaser.Game((window.larguraJogo || window.gameWidth || 1280) | 0, (window.alturaJogo || window.gameHeight || 720) | 0, Phaser.AUTO, "divGame"),
divParent = null, divGame = null, loadedScripts = 0, fading = false, fadeGraphics = null, fadeTween = null;
function init() {
game.input.maxPointers = 1;
// Keep the game running even after switching tabs
game.stage.disableVisibilityChange = true;
// https://phaser.io/docs/2.6.2/Phaser.ScaleManager.html
// Due to a few issues in the scaling performed by Phaser 2.6.2, we will do it ourselves!
// And since we are doing it manually, just turn off all automatic options...
game.scale.compatibility.orientationFallback = "viewport";
game.scale.compatibility.noMargins = true;
game.scale.pageAlignHorizontally = false;
game.scale.pageAlignVertically = false;
// https://phaser.io/docs/2.6.2/Phaser.ScaleManager.html#startFullScreen
game.scale.fullScreenScaleMode = Phaser.ScaleManager.USER_SCALE;
game.scale.scaleMode = Phaser.ScaleManager.USER_SCALE;
function updateScale() {
var windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
var windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
divParent.style.width = windowWidth + "px";
divParent.style.height = windowHeight + "px";
// If we are not in a desktop environment, or we are in full screen mode, apply the scale regardless the screen dimensions
var width, height;
if (!game.device.desktop || windowWidth <= game.width || windowHeight <= game.height || game.scale.isFullScreen) {
var ratioJogo = game.width / game.height;
var ratioTela = windowWidth / windowHeight;
if (ratioTela > ratioJogo) {
// Vertical borders on each side
height = windowHeight;
width = ((game.width * (windowHeight / game.height)) + 0.5) | 0;
} else {
// Horizontal borders above and below
width = windowWidth;
height = ((game.height * (windowWidth / game.width)) + 0.5) | 0;
}
game.scale.setUserScale(width / game.width, height / game.height);
} else {
width = game.width;
height = game.height;
game.scale.setUserScale(1, 1);
}
// Phaser creates a div inside divGame when in fullscreen mode...
var div = divGame.getElementsByTagName("div");
if (div && div.length && div[0])
div[0].style.paddingTop = ((windowHeight > height) ? ((windowHeight - height) >> 1) : "0") + "px";
game.scale.refresh();
}
if (!divParent) {
divParent = document.getElementById("divParent");
divGame = document.getElementById("divGame");
window.addEventListener("resize", updateScale);
}
updateScale();
}
function toggleFullScreen() {
if (game.scale.isFullScreen)
game.scale.stopFullScreen();
else
game.scale.startFullScreen(false);
}
function fade(from, to, callback, duration, context) {
if (fadeTween)
fadeTween.stop(false);
if (fadeGraphics)
fadeGraphics.destroy(true);
fading = true;
game.input.enabled = false;
fadeGraphics = game.add.graphics();
fadeGraphics.fixedToCamera = true;
fadeGraphics.beginFill(0x000000, 1.0);
fadeGraphics.drawRect(0, 0, larguraJogo, alturaJogo);
fadeGraphics.endFill();
fadeGraphics.alpha = (from >= 1 ? 1 : (from > 0 ? from : 0));
fadeTween = game.add.tween(fadeGraphics).to({ alpha: (to >= 1 ? 1 : (to > 0 ? to : 0)) }, duration > 0 ? duration : 500, Phaser.Easing.Sinusoidal.InOut, true);
fadeTween.onComplete.add(function () {
fading = false;
if (fadeGraphics) {
// When fading out, leave the graphics
// on the screen, until it is destroyed.
if (!to) {
fadeGraphics.destroy(true);
fadeGraphics = null;
} else {
game.stage.backgroundColor = "#000000";
}
fadeTween = null;
game.input.enabled = true;
if (callback)
callback.apply(context || window);
}
});
}
function fadeIn(callback, duration, context) {
fade(1, 0, callback, duration, context);
}
function fadeOut(callback, duration, context) {
fade(0, 1, callback, duration, context);
}
function stopFade() {
fading = false;
game.input.enabled = true;
if (fadeTween) {
fadeTween.stop(false);
fadeTween = null;
}
if (fadeGraphics) {
fadeGraphics.destroy(true);
fadeGraphics = null;
}
}
function scriptLoadingFinished() {
var i, name, level, levels = (window.telas || window.levels || ["menu"]), proto;
if (++loadedScripts < levels.length)
return;
proto = {
init: init
};
for (i = 0; i < levels.length; i++) {
name = levels[i];
if (name.toLowerCase().indexOf(".js") >= 0)
name = name.substr(0, name.length - 3);
level = window[name];
level.prototype = proto;
game.state.add(name, level);
}
game.state.start("menu");
}
(function () {
var i, script, loaderScript = document.getElementById("loaderScript"),
level, levels = (window.telas || window.levels || ["menu"]);
for (i = 0; i < levels.length; i++) {
level = levels[i];
if (level.toLowerCase().indexOf(".js") >= 0)
level = level.substr(0, level.length - 3);
if (level === "menu")
continue;
script = document.createElement("script");
script.setAttribute("type", "text/javascript");
script.onload = scriptLoadingFinished;
script.setAttribute("src", level + ".js");
document.body.insertBefore(script, loaderScript);
}
// Simulate the onload event for menu.js
scriptLoadingFinished();
})();
//]]>
</script>
</body>
</html>