-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOverworld.js
More file actions
42 lines (38 loc) · 891 Bytes
/
Overworld.js
File metadata and controls
42 lines (38 loc) · 891 Bytes
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
class Overworld {
/**
*
*/
constructor(config) {
// super();
this.element = config.element;
this.canvas = this.element.querySelector(".game-canvas");
this.ctx = this.canvas.getContext("2d");
}
init() {
console.log("Overworld", this);
const image = new Image();
image.onload = () => {
this.ctx.drawImage(
image, //image to draw pictures from
0, //start x: top left x
0 //start y: top left y
);
console.log("end image onload");
};
image.src = "./images/maps/DemoLower.png";
// place some game objects
const hero = new GameObject({
x: 5,
y: 6,
});
const npc1 = new GameObject({
x: 7,
y: 9,
src: "./images/characters/people/npc1.png",
});
setTimeout(() => {
hero.sprite.draw(this.ctx);
npc1.sprite.draw(this.ctx);
}, 200);
}
}