From d75f862380cf62d15de4e102ef410ec83ececbdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20K=C3=B6hring?= Date: Fri, 17 Feb 2023 21:54:13 +0100 Subject: [PATCH] time-related brightness controlled by light-map --- src/App.vue | 10 ++++----- src/assets/field.css | 47 ++++++++++------------------------------- src/level/def.ts | 3 ++- src/util/useLightMap.ts | 42 ++++++++++++++++++++++-------------- src/util/useTime.ts | 2 +- 5 files changed, 45 insertions(+), 59 deletions(-) diff --git a/src/App.vue b/src/App.vue index 3496ffe..5730b00 100644 --- a/src/App.vue +++ b/src/App.vue @@ -11,13 +11,13 @@ import useInput from './util/useInput' import usePlayer from './util/usePlayer' import useLightMap from './util/useLightMap' -const { updateTime, time, clock } = useTime() +const { updateTime, time, timeOfDay, clock } = useTime() const { player, direction, dx, dy } = usePlayer() const { inputX, inputY, running, paused, help, inventory } = useInput() const level = createLevel(STAGE_WIDTH + 2, STAGE_HEIGHT + 2) const lightMapEl = ref(undefined) -let lightMap: ReturnType +let updateLightMap: ReturnType player.inventory.push( { name: 'Shovel', type: 'tool', icon: 'shovel', quality: 'bronze', amount: 1 }, @@ -144,7 +144,7 @@ const move = (thisTick: number): void => { y.value += dy_ * fallMultiplier } - lightMap.draw(floorX.value, floorY.value, tx.value, ty.value, time.value) + updateLightMap() lastTick = thisTick } @@ -171,14 +171,14 @@ onMounted(() => { canvas.width = (BLOCK_SIZE + 2) * STAGE_WIDTH const ctx = canvas.getContext('2d')! - lightMap = useLightMap(ctx) + updateLightMap = useLightMap(ctx, floorX, floorY, tx, ty, time, lightBarrier) lastTick = performance.now() move(lastTick) })