From 09e4c2dc4b7e1c42e754f417bcb750e51760ffe1 Mon Sep 17 00:00:00 2001 From: StrangeD0s Date: Sun, 19 Feb 2023 17:25:18 +0100 Subject: [PATCH] update research collision --- js/main.js | 3 --- js/update.js | 15 ++++++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/js/main.js b/js/main.js index b4bb3d2..0eda6ba 100644 --- a/js/main.js +++ b/js/main.js @@ -193,9 +193,6 @@ function main() { // ! Vielleicht kann ich statt des setup() an dieser Stelle auch eine gameStart() Funktion erstellen, die beim erstmaligen Start alles erledigt. Später wird dann ja immer die _initLevel() aufgerufen. setup(currentLevel.levelData) // ! Was brauche ich hier, damit das variabel alle Level laden kann? - //console.log('log monsters ', monsters) - console.log('log updateVehicle ', vehicles) - frame() } diff --git a/js/update.js b/js/update.js index 3c4bf15..e52ed50 100644 --- a/js/update.js +++ b/js/update.js @@ -49,7 +49,7 @@ function updateMonster(monster, dt) { if (!monster.dead) { updateEntity(monster, dt) - console.log('log TILE ', TILE) + // ! TILE ist immer nur eine feste Zahl "16" if ( overlap(player.x, player.y, TILE, TILE, monster.x, monster.y, TILE, TILE) @@ -354,8 +354,6 @@ function collectTreasure(t) { } function updateEntity(entity, dt) { - entity.vehicle && console.log('log entity ', entity) - var wasleft = entity.dx < 0, wasright = entity.dx > 0, falling = entity.falling, @@ -420,13 +418,20 @@ function updateEntity(entity, dt) { ty = p2t(entity.y), nx = entity.x % TILE, ny = entity.y % TILE, - cell = tcell(tx, ty, mapWidth), //! Was ist das hier? + cell = tcell(tx, ty, mapWidth), //! Prüft ob eine Cell oben oder links angrenzt cellright = tcell(tx + 1, ty, mapWidth), celldown = tcell(tx, ty + 1, mapWidth), - celldiag = tcell(tx + 1, ty + 1, mapWidth) + celldiag = tcell(tx + 1, ty + 1, mapWidth) // ! logischerweise muss das prüfen, ob eine Cell unten rechts angrenzt // ? Ist das hier der Collision Check? + // entity.player && console.log('log cell ', cell) + // entity.player && console.log('log cellright ', cellright) + entity.player && console.log('log ny ', ny) + // entity.player && console.log('log celldiag ', celldiag) + + // ! Die Collision prüft einfach nur, ob an den Player eine Cell angrenzt (!0) oder nicht (0). + if (entity.dy > 0) { if ((celldown && !cell) || (celldiag && !cellright && nx)) { entity.y = t2p(ty)