Fix overlap in the "tower placement restriction visualization" by drawing it for each tile, instead of for each tower
This commit is contained in:
parent
038a287e96
commit
3233331722
27
index.js
27
index.js
|
@ -587,6 +587,11 @@ window.onload = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.fillRect(x * mt, y * mt, mt, mt)
|
ctx.fillRect(x * mt, y * mt, mt, mt)
|
||||||
|
|
||||||
|
if(tile != 1 && !getTowerAt(x, y) && !canPlaceTowerAt(x, y)) {
|
||||||
|
ctx.fillStyle = 'rgba(255, 0, 0, 0.45)'
|
||||||
|
ctx.fillRect(x * mt, y * mt, mt, mt)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
for (let i in Game.map.pathgen) {
|
for (let i in Game.map.pathgen) {
|
||||||
|
@ -599,28 +604,6 @@ window.onload = function () {
|
||||||
let tower = Game.towers[i]
|
let tower = Game.towers[i]
|
||||||
ctx.fillStyle = tower.icon
|
ctx.fillStyle = tower.icon
|
||||||
ctx.fillRect(tower.x * mt + 2, tower.y * mt + 2, 28, 28)
|
ctx.fillRect(tower.x * mt + 2, tower.y * mt + 2, 28, 28)
|
||||||
|
|
||||||
if (Game.state === 2 && Game.tower) {
|
|
||||||
// tower placement restriction visualization
|
|
||||||
for (let i = 0; i < 4; i++) {
|
|
||||||
let ax = tower.x
|
|
||||||
let ay = tower.y
|
|
||||||
if (i == 0) {
|
|
||||||
ax -= 1
|
|
||||||
} else if (i == 1) {
|
|
||||||
ax += 1
|
|
||||||
} else if (i == 2) {
|
|
||||||
ay -= 1
|
|
||||||
} else if (i == 3) {
|
|
||||||
ay += 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ax < 0 || ay < 0 || ay > Maps.height || ax > Maps.width) continue
|
|
||||||
if (getTileIn(Game.map.tiles, ax, ay) !== 0) continue
|
|
||||||
ctx.fillStyle = 'rgba(255, 0, 0, 0.45)'
|
|
||||||
ctx.fillRect(ax * mt, ay * mt, mt, mt)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i in Game.enemies) {
|
for (let i in Game.enemies) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user