aboutsummaryrefslogtreecommitdiff
path: root/src/sim/static/tiles.js
blob: 203acb4e369acc74731d01c61c49a2999ffce392 (plain)
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
function Mountain() {
    this.name = "mountain"
}
Mountain.prototype.draw = function (x, y, size) {
    ctx.fillStyle = "gray"
    ctx.beginPath();
    ctx.moveTo(x * size + size / 2, y * size);
    ctx.lineTo(x * size, (1 + y) * (size));
    ctx.lineTo((1 + x) * (size), (1 + y) * (size));
    ctx.stroke();
    ctx.fill();
}
Mountain.prototype.update = function (game) {
    game.gold += 1
}

function Forest() {
    this.name = "forest"
}
Forest.prototype.draw = function (x, y, size) {
    ctx.fillStyle = "green"
    ctx.beginPath();
    ctx.moveTo(x * size + size / 2, y * size);
    ctx.lineTo(x * size, (1 + y) * (size));
    ctx.lineTo((1 + x) * (size), (1 + y) * (size));
    ctx.stroke();
    ctx.fill();
}
Forest.prototype.update = function (game) {
    var event = {}
    game.resources +=  Math.floor(Math.random() * 5)
}

function Town() {
    this.name = "town"
}
Town.prototype.draw = function (x, y, size) {
    ctx.fillStyle = "brown"
    ctx.stokeStyle = "brown"
    ctx.beginPath();
    ctx.moveTo(x * size + size / 2, y * size);
    ctx.lineTo(x * size, (1 + y) * (size));
    ctx.lineTo((1 + x) * (size), (1 + y) * (size));
    ctx.stroke();
    ctx.fill();
}
Town.prototype.update = function () {
    game.population += Math.floor(Math.random() * 4) - 1
}