Draw the background color seperately instead of drawing each grass tile individually
This commit is contained in:
parent
038a287e96
commit
f8d532b4ae
10
index.js
10
index.js
@ -568,13 +568,15 @@ window.onload = function () {
|
|||||||
|
|
||||||
function render () {
|
function render () {
|
||||||
let mt = Maps.tile
|
let mt = Maps.tile
|
||||||
ctx.clearRect(0, 0, canvas.width, canvas.height)
|
ctx.fillStyle = '#0fa'
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height)
|
||||||
|
|
||||||
for (let i in Game.map.tiles) {
|
for (let i in Game.map.tiles) {
|
||||||
let tile = Game.map.tiles[i]
|
let tile = Game.map.tiles[i]
|
||||||
let index = parseInt(i)
|
let index = parseInt(i)
|
||||||
let y = Math.floor(index / Maps.width)
|
let y = Math.floor(index / Maps.width)
|
||||||
let x = Math.floor(index % Maps.height)
|
let x = Math.floor(index % Maps.height)
|
||||||
|
var draw_tile = true
|
||||||
|
|
||||||
if (tile === 1) {
|
if (tile === 1) {
|
||||||
ctx.fillStyle = '#fdd'
|
ctx.fillStyle = '#fdd'
|
||||||
@ -583,10 +585,12 @@ window.onload = function () {
|
|||||||
} else if (tile === 3) {
|
} else if (tile === 3) {
|
||||||
ctx.fillStyle = '#f3a'
|
ctx.fillStyle = '#f3a'
|
||||||
} else {
|
} else {
|
||||||
ctx.fillStyle = '#0fa'
|
draw_tile = false
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.fillRect(x * mt, y * mt, mt, mt)
|
if(draw_tile) {
|
||||||
|
ctx.fillRect(x * mt, y * mt, mt, mt)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
for (let i in Game.map.pathgen) {
|
for (let i in Game.map.pathgen) {
|
||||||
|
Loading…
Reference in New Issue
Block a user