update research collision
This commit is contained in:
+10
-5
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user