-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathexample13.html
More file actions
71 lines (55 loc) · 2.04 KB
/
Copy pathexample13.html
File metadata and controls
71 lines (55 loc) · 2.04 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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script src="../jaws-dynamic.js"></script>
<script src="../game_states/edit.js"></script>
<link type="text/css" rel="stylesheet" href="style.css" />
<title>Jaws Example #13 - WORK IN PROGRESS - isometric edit</title>
</head>
<body>
<canvas width=500 height=400></canvas>
<div id="jaws-edit">Editor output will show here.</div>
<div id="info">
<h1>press SPACE to start editor</h1>
</div>
<h3>jaws log</h3>
<div id="jaws-log"></div>
<script>
var blocks;
function Example() {
blocks = new jaws.SpriteList()
this.setup = function() {
// blocks.load(localStorage[title]) // Load saved sprites from localStorage
if(blocks.length == 0) { // No sprites in localStorage? Generate 5 randomly placed blocks!
for(var nr=5; nr--; ) {
blocks.push( new Grass({x: Math.random()*jaws.width-20, y: Math.random()*jaws.height-20}) )
}
}
jaws.on_keydown(["esc","space"], startEdit);
jaws.preventDefaultKeys(["space"])
startEdit();
}
this.draw = function() {
jaws.clear()
blocks.draw()
}
}
function startEdit() {
jaws.switchGameState(
new jaws.game_states.Edit({constructors: [Grass, Dirt], game_objects: blocks, grid_size: [30,15], isometric: true, title: window.location.href})
)
}
var Grass = function(options) { options.image = "isometric_grass.bmp"; options.scale_image=2; jaws.Sprite.call(this, options) }
var Dirt = function(options) { options.image = "isometric_dirt.bmp"; options.scale_image=2; jaws.Sprite.call(this, options) }
jaws.onload = function() {
Grass.prototype = new jaws.Sprite({})
Grass.prototype.constructor = Grass
Dirt.prototype = new jaws.Sprite({})
Dirt.prototype.constructor = Dirt
jaws.assets.add(["isometric_grass.bmp", "isometric_dirt.bmp"])
jaws.start(Example)
}
</script>
</body>
</html>