-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.html
80 lines (76 loc) · 3.22 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Sand Game JS</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css"
rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
<style>
/* override xx-large breakpoint */
@media (min-width: 1400px) {
.container {
max-width: 1140px;
}
}
</style>
<script defer src="dist/sand-game-js.umd.js"></script>
<link rel="stylesheet" type="text/css" href="dist/sand-game-js.css" />
<script>
// global variables, accessible from browser console
var sandGame = null;
var brushes = null;
document.addEventListener('DOMContentLoaded', () => {
if (window.SandGameJS !== undefined) {
const root = document.getElementById('sand-game-root');
const config = { version: 'dev', debug: true };
const controller = window.SandGameJS.init(root, config);
sandGame = controller.getSandGame();
controller.addOnInitialized(s => {
sandGame = s;
});
brushes = window.SandGameJS.brushes;
console.log('Globals:');
console.log(' sandGame, brushes');
console.log('Examples:');
console.log(' sandGame.graphics().drawLine(10, 10, 300, 150, 2, brushes.sand);');
console.log(' sandGame.graphics().draw(100, 20, brushes.meteor);');
} else {
const placeholder = document.getElementById('sand-game-placeholder-content');
placeholder.innerHTML = '<span style="color: red; font-weight: bold;">' +
'Failed to load the game. Possible reasons:<br>' +
'• Your browser may not support modern JavaScript<br>' +
'• Internet connection<br>' +
'• A server side problem' +
'</span>';
}
});
</script>
</head>
<body>
<main role="main" class="container">
<h1>Sand Game JS</h1>
<div id="sand-game-root">
<!-- Sand Game JS placeholder -->
<div style="user-select: none;">
<div>
<button disabled class="btn" type="button" style="min-width: 4em; line-height: 2; padding: 0 0.4em 0 0.4em; font-size: 75%; border: none; background-color: rgb(230, 230, 230); color: black;"> </button>
</div>
<div style="height: 70vh; display: flex; align-items: center; justify-content: center; margin-top: 4pt; padding: 2em; outline: 1px solid #b7b7b7;">
<div id="sand-game-placeholder-content">
Loading...
</div>
</div>
<div style="height: 20vh"></div>
</div>
</div>
</main>
<footer class="container" style="font-size: small">
<p>
<a href="https://github.com/Hartrik/sand-game-js">https://github.com/Hartrik/sand-game-js</a>
</p>
</footer>
</body>
</html>