mirror of
https://git.leinelab.org/Mal/mr-crocs-adventures.git
synced 2025-09-11 02:57:36 +02:00
Reset if Mr Croc left architecture.
This commit is contained in:
@@ -2,6 +2,7 @@ import RetroSprite from "./RetroSprite.js";
|
||||
import RetroArchitectureTile from "./RetroArchitectureTile.js";
|
||||
import GeometryRectCollection from "../geometry/GeometryRectCollection.js";
|
||||
import GeometryPoint from "../geometry/GeometryPoint.js";
|
||||
import GeometryRect from "../geometry/GeometryRect.js";
|
||||
|
||||
export default class RetroArchitecture
|
||||
{
|
||||
@@ -14,6 +15,8 @@ export default class RetroArchitecture
|
||||
this.matrix = [];
|
||||
this.tileWidth = this.tileset.getWidth() / this.tiles;
|
||||
this.tileHeight = this.tileset.getHeight();
|
||||
this.startX = 0;
|
||||
this.startY = 0;
|
||||
|
||||
this.init();
|
||||
}
|
||||
@@ -26,7 +29,7 @@ export default class RetroArchitecture
|
||||
for (let x = 0; x < this.columns; x++) {
|
||||
row.push(null);
|
||||
}
|
||||
console.log(row);
|
||||
|
||||
this.matrix.push(row);
|
||||
}
|
||||
}
|
||||
@@ -113,7 +116,7 @@ export default class RetroArchitecture
|
||||
tilePosition.y++;
|
||||
}
|
||||
|
||||
return this.tileHeight * this.rows;
|
||||
return 9999999999;
|
||||
}
|
||||
|
||||
getWallRight(position)
|
||||
@@ -146,6 +149,21 @@ export default class RetroArchitecture
|
||||
return 0;
|
||||
}
|
||||
|
||||
isInsideArchitecture(geometryPoint)
|
||||
{
|
||||
let architectureRect = new GeometryRect(
|
||||
0, 0, this.tileWidth * this.columns, this.tileHeight * this.rows
|
||||
);
|
||||
|
||||
return architectureRect.isContainingPoint(geometryPoint);
|
||||
}
|
||||
|
||||
resetMovableToStartPosition(movable)
|
||||
{
|
||||
movable.position.x = this.tileWidth * this.startX + this.tileWidth * 0.5;
|
||||
movable.position.y = this.tileHeight * this.startY + this.tileHeight * 0.5;
|
||||
}
|
||||
|
||||
draw(context, camera = null)
|
||||
{
|
||||
let viewX = parseInt(Math.floor(Math.max(0, camera.position.x) / this.tileWidth));
|
||||
@@ -185,6 +203,9 @@ export default class RetroArchitecture
|
||||
data.rows
|
||||
);
|
||||
|
||||
architecture.startX = data.startX;
|
||||
architecture.startY = data.startY;
|
||||
|
||||
for (let y = 0; y < data.rows; y++) {
|
||||
for (let x = 0; x < data.columns; x++) {
|
||||
if (data.matrix[y][x] > -1) {
|
||||
|
||||
Reference in New Issue
Block a user