-
Notifications
You must be signed in to change notification settings - Fork 2
/
DRAFT1.js
67 lines (48 loc) · 1.39 KB
/
DRAFT1.js
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
Game = {
// Initialize and start our game
start: function() {
var assetsObj = {
"sprites": {
"http://i.imgur.com/yYqGbpK.png": {
tile: 16,
tileh: 22,
map: {
walker_start: [0, 0],
//walker_middle: [7, 0],
walker_end: [2, 0]
}
}
}
};
// Start crafty and set a background color so that we can see it's working
Crafty.init(600, 600);
//change bg
Crafty.background('url(http://www.psdgraphics.com/file/stars.jpg)');
//bar
Crafty.e('Floor, 2D, Canvas, Color')
.attr({x: 0, y: 500, w: 800, h: 10})
.color(255, 0 ,0);
Crafty.load(assetsObj, walker);
//function go() {
var walker = Crafty.e('2D, Canvas, walker_start, SpriteAnimation, Gravity, Twoway')
.reel("walking", 1000, [ //x, y
[0, 0], [1, 0], [2, 0]//, [0, 1], [1, 1], [2, 1], [0, 2], [1, 2],
//[2, 2], [0, 3], [1, 3], [2, 3]
])
.animate("walking", -1)
.gravity('Floor')
.twoway(7, 5);
//}
Crafty.viewport.follow(walker, 0, 300);
//sprite
/* var len = Crafty.e('2D, Canvas,Fourway, Gravity, Image')
.attr({x: 0, y: 0, w: 50, h: 50})
//.color('#F00')
.fourway(4) //move
.gravity('Floor')
.image("http://33.media.tumblr.com/7ffb83e85ab22032ffec4fa1dc40efaf/tumblr_inline_n5fmwpwGhK1sqx5ng.png");
*/
//camera viewpoint
//Crafty.viewport.follow(len, 0, 300);
}
}