-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.js
63 lines (58 loc) · 1.59 KB
/
App.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
// import RogueIO from "./index.js";
import Options from "./src/core/options";
import RogueIO from "./src";
let { init, RNG, Map, Sprite, Game } = RogueIO;
RNG.setSeed("Miya");
let { canvas, context } = init();
let map = {};
var tileSize = 64,
numTiles = 9,
uiWidth = 4;
var w = tileSize * (numTiles + uiWidth),
h = tileSize * numTiles;
canvas.width = tileSize * (numTiles + uiWidth);
canvas.height = tileSize * numTiles;
canvas.style.width = canvas.width + "px";
canvas.style.height = canvas.height + "px";
canvas.style.fontSize = "15px";
context.font = "15px sans-serif";
context.imageSmoothingEnabled = false;
console.log(context, Map, canvas);
const _generateMap = () => {
var freeCells = [];
var digger = new Map.Digger(w, h);
console.log(digger);
var digCallback = function(x, y, value) {
if (value) {
return;
} /* do not store walls */
var key = x + "," + y;
freeCells.push(key);
map[key] = ".";
};
digger.create(digCallback.bind(this));
_drawWholeMap();
};
const _drawWholeMap = function() {
for (var key in map) {
var parts = key.split(",");
var x = parseInt(parts[0]);
var y = parseInt(parts[1]);
let sprite = Sprite({
x: x, // starting x,y position of the sprite
y: y,
radius: 5,
color: "#000", // fill color of the sprite rectangle
width: 1, // width and height of the sprite rectangle
height: 1,
render: function() {
this.draw();
// this.context.font = "50px"
}
});
// sprite.context.font = "14px sans-serif";
sprite.render();
}
};
_generateMap();
console.log(map);