wlall
This commit is contained in:
@@ -121,8 +121,6 @@ class DungeonCrawler {
|
|||||||
|
|
||||||
this.setupControls();
|
this.setupControls();
|
||||||
this.loadMap();
|
this.loadMap();
|
||||||
this.render(this.player.x, this.player.y, this.player.orientation * PI_OVER_TWO);
|
|
||||||
this.renderCompass();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Start the game loop
|
// Start the game loop
|
||||||
@@ -173,13 +171,12 @@ class DungeonCrawler {
|
|||||||
textureUrls.forEach((url, textureId) => {
|
textureUrls.forEach((url, textureId) => {
|
||||||
Texture.fromSource(url).then((texture) => {
|
Texture.fromSource(url).then((texture) => {
|
||||||
textures[textureId] = texture;
|
textures[textureId] = texture;
|
||||||
|
console.log("here", { textureId, texture, textures });
|
||||||
if (textureLoadCount > textureUrls.length) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
textureLoadCount++;
|
textureLoadCount++;
|
||||||
|
|
||||||
|
if (textureLoadCount < textureUrls.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.rendering.firstPersonRenderer = new FirstPersonRenderer(
|
this.rendering.firstPersonRenderer = new FirstPersonRenderer(
|
||||||
this.rendering.firstPersonWindow,
|
this.rendering.firstPersonWindow,
|
||||||
this.map,
|
this.map,
|
||||||
@@ -188,8 +185,9 @@ class DungeonCrawler {
|
|||||||
);
|
);
|
||||||
this.render();
|
this.render();
|
||||||
this.renderMinimap();
|
this.renderMinimap();
|
||||||
|
this.renderCompass();
|
||||||
|
|
||||||
console.debug("renderer ready", texture);
|
console.debug("renderer ready", textures);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -397,21 +397,13 @@ export class FirstPersonRenderer {
|
|||||||
// appear first in the array,
|
// appear first in the array,
|
||||||
// enabling us to simply draw from back to front
|
// enabling us to simply draw from back to front
|
||||||
const collision = new RayCollision();
|
const collision = new RayCollision();
|
||||||
result.collisions.unshift(collision);
|
|
||||||
|
|
||||||
collision.mapX = mapX;
|
collision.mapX = mapX;
|
||||||
collision.mapY = mapY;
|
collision.mapY = mapY;
|
||||||
collision.rayLength = rayLength;
|
collision.rayLength = rayLength;
|
||||||
collision.tile = tile;
|
collision.tile = tile;
|
||||||
collision.sampleU = sampleU;
|
collision.sampleU = sampleU;
|
||||||
collision.side = side;
|
collision.side = side;
|
||||||
if (result.sprite) {
|
result.collisions.unshift(collision);
|
||||||
collision.sprite = true;
|
|
||||||
}
|
|
||||||
if (result.wall) {
|
|
||||||
collision.wall = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -421,17 +413,6 @@ export class FirstPersonRenderer {
|
|||||||
// --------------------------
|
// --------------------------
|
||||||
if (tile.wall) {
|
if (tile.wall) {
|
||||||
result.hitWall = true;
|
result.hitWall = true;
|
||||||
|
|
||||||
// <todo>
|
|
||||||
// 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;
|
|
||||||
// </todo>
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ export class Tile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isCollision() {
|
||||||
|
return this.wall || this.sprite;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const defaultLegend = Object.freeze({
|
export const defaultLegend = Object.freeze({
|
||||||
|
|||||||
Reference in New Issue
Block a user