-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex_single_canvas.html
122 lines (102 loc) · 3.25 KB
/
index_single_canvas.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
<!doctype html>
<!-- 021B21 032C36 065F73 E8DFD6 FF2A1D-->
<html>
<head>
<title></title>
<meta charset='utf-8' />
</head>
<style>
html, body {
background-color: #021B21;
margin: 0;
width: 100%;
height: 100%;
}
.input_block {
position:relative;
text-shadow: 1px 1px #065F73;
font-size: 12pt;
font-family: Verdana;
color: #E8DFD6;
width: 100%;
}
.input_style {
font-size: 12pt;
font-family: Verdana;
color: #065F73;
width: auto;
}
.button_style {
font-size: 12pt;
font-family: Verdana;
color: #065F73;
}
</style>
<body>
<div class="input_block">
<canvas id='editor'>Обновите браузер</canvas>
<div style="position: absolute; left: 1vw; bottom: 1vh; " id="input_div">
<!-- <div style="display: inline-block;">Ваш код для сохрания игры:</div> -->
<!-- <input value="123" style="display: inline-block;"/> -->
<p>
Код для сохранения и загрузки игры: <input value="123" class="input_style" id="code" onclick="this.select();"/><input type="button" value="Загрузить" id="load_btn" class="button_style"/>
</p>
</div>
</div>
<script type="text/javascript" src="utils.js"></script>
<script type="text/javascript" src="world_class.js"></script>
<script type="text/javascript" src="editor.js"></script>
<script type="text/javascript">
//WTF??
var vendors = ['webkit', 'moz'];
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'];
}
var editor_canvas = document.getElementById("editor");
var w = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
editor_canvas.width = w;
editor_canvas.height = h * 1.0;
var cx = null;
var currentTime = 0, lastTime = (new Date()).getTime();
var angle = 0;
var world = new World();
function InputController(){
this.setCode = function(code){
document.getElementById("code").value = code;
}
this.getCode = function(){
document.getElementById("code").value;
}
this.hideCodeField = function(hide){
if(hide){
document.getElementById("input_div").style.visibility = "hidden";
} else {
document.getElementById("input_div").style.visibility = "visible";
}
}
}
document.getElementById("load_btn").onclick = function(){
deserialize(document.getElementById("code").value);
}
init_editor(editor_canvas, new InputController());
window.onresize = function(event) {
cx.canvas.width = window.innerWidth;
cx.canvas.height = window.innerHeight;
};
function mainLoop(){
currentTime = (new Date()).getTime();
var delta = (currentTime - lastTime) / 1000;
lastTime = currentTime;
cx.clearRect(0, 0, editor_canvas.width, editor_canvas.height);
game_loop(cx, delta, world);
requestAnimationFrame(mainLoop);
}
if ( (typeof (editor_canvas.getContext) !== undefined)) {
cx = editor_canvas.getContext('2d');
mainLoop();
}
</script>
</body>
</html>