-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap.js
39 lines (33 loc) · 1.01 KB
/
map.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
export class Map{
constructor(game){
this.game = game;
this.x = this.y = 0;
this.image;
this.width;
this.height;
this.imageIndex;
this.dimensions;
this.setWorld(this.game.assetManager.images[8]);
}
setWorld(world){
this.image = world;
//set x and y to 0
this.x = this.y = 0;
this.imageIndex = this.game.assetManager.images.indexOf(this.image);
this.dimensions = this.game.assetManager.imageDimensions[this.imageIndex];
this.width = this.dimensions[0];
this.height = this.dimensions[1];
}
render(ctx){
ctx.drawImage(this.image,
this.game.camera.viewportX,
this.game.camera.viewportY,
this.game.camera.viewportWidth,
this.game.camera.viewportHeight,
this.x,
this.y,
this.game.camera.viewportWidth,
this.game.camera.viewportHeight
)
}
}