forked from RichoM/MiniMorphicJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpuzzle.html
48 lines (42 loc) · 1.29 KB
/
puzzle.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
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Puzzle demo</title>
</head>
<body style="margin: 0">
<h2 id="loading">Loading...</h2>
<canvas id="world" oncontextmenu="return false"></canvas>
<script src="js/core/KeyCode.js"></script>
<script src="js/core/Canvas.js"></script>
<script src="js/core/Form.js"></script>
<script src="js/core/EventHandler.js"></script>
<script src="js/core/Morph.js"></script>
<script src="js/core/World.js"></script>
<script src="js/core/Sprite.js"></script>
<script src="js/core/Ellipse.js"></script>
<script src="js/core/Button.js"></script>
<script src="js/puzzle/Puzzle.js"></script>
<script>
var puzzles = [];
// First we load all the images we're going to use
Form.load([
{ key: "puzzle", src: "images/puzzle_bevel.png" }
], function (forms) {
// Remove loading
document.body.removeChild(loading);
var world = new World();
for (var i = 0; i < 15; i++) {
function rnd(n) { return Math.random() * n; }
var puzzle = new Puzzle(forms[0]);
puzzle.center({
x: rnd(world.width()),
y: rnd(world.height())
});
puzzle.tint(rnd(255), rnd(255), rnd(255));
world.addMorph(puzzle);
puzzles.push(puzzle);
}
});
</script>
</body>
</html>