three v154

This commit is contained in:
2023-07-08 17:41:27 +02:00
parent 3f84ddd8df
commit 5a85c0cae2
3 changed files with 10 additions and 4 deletions

View File

@@ -55,6 +55,7 @@ export default class MazeMesh extends THREE.InstancedMesh {
isWall(position) {
if (0 <= position.x && position.x < this.width &&
0 <= position.y &&
0 <= position.z && position.z < this.length) {
return this.map[Math.floor(position.z)][Math.floor(position.x)]
} else {
@@ -62,6 +63,10 @@ export default class MazeMesh extends THREE.InstancedMesh {
}
}
collision(position) {
return this.isWall(this.worldToLocal(position))
}
toString() {
return this.map.map(row =>
row.map(isWall => isWall? "██":" ").join("")