mirror of
https://git.leinelab.org/Mal/mr-crocs-adventures.git
synced 2025-09-11 02:57:36 +02:00
Tileset dialog for Tilorswift and fix for adding rows.
This commit is contained in:
@@ -3,6 +3,8 @@ import RetroArchitectureTile from "./RetroArchitectureTile.js";
|
||||
import GeometryRectCollection from "../geometry/GeometryRectCollection.js";
|
||||
import GeometryPoint from "../geometry/GeometryPoint.js";
|
||||
import GeometryRect from "../geometry/GeometryRect.js";
|
||||
import GraphicSet from "../GraphicSet.js";
|
||||
import Setting from "../Setting.js";
|
||||
|
||||
export default class RetroArchitecture
|
||||
{
|
||||
@@ -10,6 +12,8 @@ export default class RetroArchitecture
|
||||
{
|
||||
this.tileset = tilesetSprite;
|
||||
this.tiles = tiles;
|
||||
this.backgroundColor = null;
|
||||
this.backgroundImage = null;
|
||||
this.rows = rows;
|
||||
this.columns = columns;
|
||||
this.matrix = [];
|
||||
@@ -37,6 +41,16 @@ export default class RetroArchitecture
|
||||
}
|
||||
}
|
||||
|
||||
setBackgroundColor(color)
|
||||
{
|
||||
this.backgroundColor = color;
|
||||
}
|
||||
|
||||
setBackgroundImage(image)
|
||||
{
|
||||
this.backgroundImage = image;
|
||||
}
|
||||
|
||||
getCollisionRects(rect)
|
||||
{
|
||||
let posX = Math.floor(rect.position.x / this.tileWidth) - 2;
|
||||
@@ -200,33 +214,46 @@ export default class RetroArchitecture
|
||||
let field = this.matrix[y][x];
|
||||
|
||||
if (field !== null && field !== undefined) {
|
||||
context.drawImage(
|
||||
this.tileset.canvas,
|
||||
field.tile * this.tileWidth,
|
||||
0,
|
||||
this.tileWidth,
|
||||
this.tileHeight,
|
||||
x * this.tileWidth - camera.position.x,
|
||||
y * this.tileHeight - camera.position.y,
|
||||
this.tileWidth,
|
||||
this.tileHeight
|
||||
);
|
||||
this.drawField(context, x, y, camera, field);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
drawField(context, x, y, camera, field)
|
||||
{
|
||||
context.drawImage(
|
||||
this.tileset.canvas,
|
||||
field.tile * this.tileWidth,
|
||||
0,
|
||||
this.tileWidth,
|
||||
this.tileHeight,
|
||||
x * this.tileWidth - camera.position.x,
|
||||
y * this.tileHeight - camera.position.y,
|
||||
this.tileWidth + 1,
|
||||
this.tileHeight + 1
|
||||
);
|
||||
}
|
||||
|
||||
static createFromData(data)
|
||||
{
|
||||
let tileset = new RetroSprite(data.tileset, data.scale);
|
||||
let graphicSet = GraphicSet[data.tileset];
|
||||
console.log(data);
|
||||
let tileset = new RetroSprite(
|
||||
Setting.TILESET_LOCATION + graphicSet.tileset,
|
||||
graphicSet.scale
|
||||
);
|
||||
|
||||
let architecture = new RetroArchitecture(
|
||||
tileset,
|
||||
data.tiles,
|
||||
graphicSet.tiles,
|
||||
data.columns,
|
||||
data.rows
|
||||
);
|
||||
|
||||
architecture.setBackgroundColor(graphicSet.backgroundColor);
|
||||
architecture.setBackgroundImage(graphicSet.backgroundImage);
|
||||
|
||||
architecture.startX = data.startX;
|
||||
architecture.startY = data.startY;
|
||||
architecture.targetX = data.targetX;
|
||||
|
||||
Reference in New Issue
Block a user