From 811b6e5b784d0f5a1c94d48cc5282df8e557de19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20K=C3=B6hring?= Date: Wed, 15 Feb 2023 13:01:45 +0100 Subject: [PATCH] shine light from the sky --- src/App.vue | 20 +++++++- src/assets/field.css | 68 ++++++++++++++++++---------- src/level/blockExt.ts | 103 +++++++++++++++++++++++++----------------- src/level/blockGen.ts | 12 ++--- src/level/def.ts | 38 ++++------------ src/level/index.ts | 37 +++++++++++++-- src/vite-env.d.ts | 1 + 7 files changed, 172 insertions(+), 107 deletions(-) diff --git a/src/App.vue b/src/App.vue index 9306f83..3b5fe3d 100644 --- a/src/App.vue +++ b/src/App.vue @@ -31,6 +31,7 @@ const floorY = computed(() => Math.floor(y.value)) const tx = computed(() => (x.value - floorX.value) * -BLOCK_SIZE) const ty = computed(() => (y.value - floorY.value) * -BLOCK_SIZE) const rows = computed(() => level.grid(floorX.value, floorY.value)) +const lightBarrier = computed(() => level.sunLight(floorX.value)) const arriving = ref(true) const walking = ref(false) @@ -125,10 +126,24 @@ const move = (thisTick: number): void => { lastTick = thisTick } +function calcBrightness(level: number, row: number) { + const barrier = lightBarrier.value[row] + let delta = barrier - level - (floorY.value - 3) + + if (delta > 3) delta = 3 + else if (delta < 0) delta = 0 + + return `sun-${delta}` +} + onMounted(() => { lastTick = performance.now() move(lastTick) }) + +function log(...args: any[]) { + console.log(...args) +}