diff --git a/frontend/ascii_dungeon_crawler.js b/frontend/ascii_dungeon_crawler.js index 73f2978..24e8e5c 100755 --- a/frontend/ascii_dungeon_crawler.js +++ b/frontend/ascii_dungeon_crawler.js @@ -121,8 +121,6 @@ class DungeonCrawler { this.setupControls(); this.loadMap(); - this.render(this.player.x, this.player.y, this.player.orientation * PI_OVER_TWO); - this.renderCompass(); // // Start the game loop @@ -173,13 +171,12 @@ class DungeonCrawler { textureUrls.forEach((url, textureId) => { Texture.fromSource(url).then((texture) => { textures[textureId] = texture; - - if (textureLoadCount > textureUrls.length) { - return; - } - + console.log("here", { textureId, texture, textures }); textureLoadCount++; + if (textureLoadCount < textureUrls.length) { + return; + } this.rendering.firstPersonRenderer = new FirstPersonRenderer( this.rendering.firstPersonWindow, this.map, @@ -188,8 +185,9 @@ class DungeonCrawler { ); this.render(); this.renderMinimap(); + this.renderCompass(); - console.debug("renderer ready", texture); + console.debug("renderer ready", textures); }); }); } diff --git a/frontend/ascii_first_person_renderer.js b/frontend/ascii_first_person_renderer.js index 1a403c2..96d5943 100755 --- a/frontend/ascii_first_person_renderer.js +++ b/frontend/ascii_first_person_renderer.js @@ -397,21 +397,13 @@ export class FirstPersonRenderer { // appear first in the array, // enabling us to simply draw from back to front const collision = new RayCollision(); - result.collisions.unshift(collision); - collision.mapX = mapX; collision.mapY = mapY; collision.rayLength = rayLength; collision.tile = tile; collision.sampleU = sampleU; collision.side = side; - if (result.sprite) { - collision.sprite = true; - } - if (result.wall) { - collision.wall = true; - return; - } + result.collisions.unshift(collision); } // @@ -421,17 +413,6 @@ export class FirstPersonRenderer { // -------------------------- if (tile.wall) { result.hitWall = true; - - // - // DELETE BELOW - result.wallCollision.tile = tile; - result.wallCollision.side = side; - - result.wallCollision.mapX = mapX; - result.wallCollision.mapY = mapY; - result.wallCollision.rayLength = rayLength; - result.wallCollision.sampleU = sampleU; - // return result; } } diff --git a/frontend/ascii_tile_map.js b/frontend/ascii_tile_map.js index a7d9541..355a537 100755 --- a/frontend/ascii_tile_map.js +++ b/frontend/ascii_tile_map.js @@ -32,6 +32,10 @@ export class Tile { } } } + + get isCollision() { + return this.wall || this.sprite; + } } export const defaultLegend = Object.freeze({