update research collision
This commit is contained in:
@@ -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.
|
// ! 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?
|
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()
|
frame()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-5
@@ -49,7 +49,7 @@ function updateMonster(monster, dt) {
|
|||||||
|
|
||||||
if (!monster.dead) {
|
if (!monster.dead) {
|
||||||
updateEntity(monster, dt)
|
updateEntity(monster, dt)
|
||||||
console.log('log TILE ', TILE)
|
|
||||||
// ! TILE ist immer nur eine feste Zahl "16"
|
// ! TILE ist immer nur eine feste Zahl "16"
|
||||||
if (
|
if (
|
||||||
overlap(player.x, player.y, TILE, TILE, monster.x, monster.y, TILE, TILE)
|
overlap(player.x, player.y, TILE, TILE, monster.x, monster.y, TILE, TILE)
|
||||||
@@ -354,8 +354,6 @@ function collectTreasure(t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateEntity(entity, dt) {
|
function updateEntity(entity, dt) {
|
||||||
entity.vehicle && console.log('log entity ', entity)
|
|
||||||
|
|
||||||
var wasleft = entity.dx < 0,
|
var wasleft = entity.dx < 0,
|
||||||
wasright = entity.dx > 0,
|
wasright = entity.dx > 0,
|
||||||
falling = entity.falling,
|
falling = entity.falling,
|
||||||
@@ -420,13 +418,20 @@ function updateEntity(entity, dt) {
|
|||||||
ty = p2t(entity.y),
|
ty = p2t(entity.y),
|
||||||
nx = entity.x % TILE,
|
nx = entity.x % TILE,
|
||||||
ny = entity.y % 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),
|
cellright = tcell(tx + 1, ty, mapWidth),
|
||||||
celldown = tcell(tx, ty + 1, 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?
|
// ? 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 (entity.dy > 0) {
|
||||||
if ((celldown && !cell) || (celldiag && !cellright && nx)) {
|
if ((celldown && !cell) || (celldiag && !cellright && nx)) {
|
||||||
entity.y = t2p(ty)
|
entity.y = t2p(ty)
|
||||||
|
|||||||
Reference in New Issue
Block a user