-
Notifications
You must be signed in to change notification settings - Fork 1
/
OverworldMap.js
65 lines (61 loc) · 1.92 KB
/
OverworldMap.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
class OverworldMap {
constructor(config) {
this.gameObjects = config.gameObjects;
this.walls = config.walls || {};
this.lowerImage = new Image();
this.lowerImage.src = config.lowerSrc;
this.upperImage = new Image();
this.upperImage.src = config.upperSrc;
}
drawLowerImage(ctx, cameraPerson) {
ctx.drawImage(this.lowerImage, utils.withGrid(10.5)-cameraPerson.x, utils.withGrid(6)-cameraPerson.y);
}
drawUpperImage(ctx, cameraPerson) {
ctx.drawImage(this.upperImage, utils.withGrid(10.5)-cameraPerson.x, utils.withGrid(6)-cameraPerson.y)
}
}
window.OverworldMaps = {
MainMap: {
lowerSrc: "./images/mapLower.png",
upperSrc: "./images/mapUpper.png",
gameObjects: {
hero: new Person({
x: utils.withGrid(4),
y: utils.withGrid(5)
}),
sunflower1: new GameObject({
src: "./images/sunflower.png",
x: utils.withGrid(15),
y: utils.withGrid(7)
}),
sunflower2: new GameObject({
src: "./images/sunflower.png",
x: utils.withGrid(8),
y: utils.withGrid(3)
}),
sunflower3: new GameObject({
src: "./images/sunflower.png",
x: utils.withGrid(9),
y: utils.withGrid(6)
}),
sunflower4: new GameObject({
src: "./images/sunflower.png",
x: utils.withGrid(10),
y: utils.withGrid(4)
}),
sunflower5: new GameObject({
src: "./images/sunflower.png",
x: utils.withGrid(13),
y: utils.withGrid(2)
})
// ,
// walls: {
// //"16, 16": true
// [utils.asGridCoords(7, 6)]: true,
// [utils.asGridCoords(8, 6)]: true,
// [utils.asGridCoords(7, 7)]: true,
// [utils.asGridCoords(8, 7)]: true
// }
}
}
}