fix lighting and this one weird bug in player changes when ascending

This commit is contained in:
Norman Köhring 2023-03-03 19:48:57 +01:00
parent fc05b00775
commit 9d3912f98f
3 changed files with 8 additions and 5 deletions

3
.gitignore vendored
View file

@ -22,3 +22,6 @@ dist-ssr
*.njsproj
*.sln
*.sw?
# old source code for reference?!
src/old

View file

@ -50,7 +50,7 @@ export default function createLevel(width: number, height: number, seed = 'extre
if (changes) {
const maxLevel = levelOffset + height
changes.forEach(c => {
if (c.type !== 'exchange' || c.y < levelOffset || c.y > maxLevel) return
if (c.type !== 'exchange' || c.y < levelOffset || c.y >= maxLevel) return
_grid[c.y - levelOffset][c.x - columnOffset] = blockTypes[c.newType]
})
}

View file

@ -58,11 +58,8 @@ export default function useLightMap(
function drawLights() {
// used for everything above ground
const ambientLight = getAmbientLightColor()
const reflectedLight = ambientLight.slice(0, -1) + ', 50%)'
const surroundingLight = ambientLight.slice(-2)
const barrier = lightBarrier.value
// make light columns wider to illuminate surrounding blocks
const extra = Math.floor(B / 2)
ctx.fillStyle = ambientLight
for (let col = 0; col < W / B; col++) {
@ -75,8 +72,11 @@ export default function useLightMap(
ctx.fillRect(sx, sy, sw, sh)
}
// make light columns wider to illuminate surrounding blocks
const extra = Math.floor(B / 2)
const reflectedLight = ambientLight.slice(0, -1) + ', 50%)'
ctx.fillStyle = reflectedLight
for (let col = 0; col < W / B; col+=2) {
for (let col = 0; col < W / B; col++) {
const level = (barrier[col] - y.value) * B
const sw = B
const sh = level