-
Notifications
You must be signed in to change notification settings - Fork 0
/
loading-screen.js
66 lines (58 loc) · 1.5 KB
/
loading-screen.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
import { loadingScreenMap } from "./maps/loading-screen.js";
import { TileSheet } from "./tile-sheet.js";
import { Player } from "./player.js";
let floorData = null;
let collidables = [];
loadingScreenMap.layers.forEach((layer) => {
layer.name === "floor"
? (floorData = layer.data)
: collidables.push(layer.data);
});
const settings = {
tileSetColumns: loadingScreenMap.tilesets[0].columns,
tileHeight: loadingScreenMap.tilesets[0].tileheight,
tileWidth: loadingScreenMap.tilesets[0].tilewidth,
mapWidth: loadingScreenMap.width,
mapHeight: loadingScreenMap.height,
};
const image = new Image();
image.src = "./maps/tileset_dungeon.png";
const playerImage = new Image();
playerImage.src = "./sprites/Char_3.png";
const enemyImage = new Image();
enemyImage.src = "./sprites/Char_4.png";
export class LoadingScreen {
constructor(canvas) {
this.canvas = canvas;
this.ctx = canvas.getContext("2d");
this.image = new Image();
this.image.src = "./maps/tileset_dungeon.png";
this.tileSheet = new TileSheet(settings, canvas, floorData, image);
this.player = new Player(
"player",
canvas,
0,
20,
20,
playerImage,
3
);
this.enemyPlayer = new Player(
"zombie",
canvas,
(canvas.width / 2) + (canvas.width / 5),
20,
20,
enemyImage,
3
)
}
createBackground() {
this.tileSheet.drawTiles();
}
draw() {
this.createBackground();
this.enemyPlayer.draw();
this.player.draw();
}
}