mirror of
https://git.leinelab.org/Mal/mr-crocs-adventures.git
synced 2025-09-11 02:57:36 +02:00
Loading of levels is working now
This commit is contained in:
@@ -204,10 +204,10 @@ export default class RetroArchitecture
|
||||
|
||||
draw(context, camera = new Camera())
|
||||
{
|
||||
let viewX = parseInt(Math.floor(Math.max(0, camera.position.x) / this.tileWidth));
|
||||
let viewWidth = parseInt(Math.min(Math.ceil(camera.width), this.columns));
|
||||
let viewY = parseInt(Math.floor(Math.max(0, camera.position.y)) / this.tileHeight);
|
||||
let viewHeight = parseInt(Math.min(Math.ceil(camera.height), this.rows));
|
||||
const viewX = parseInt(Math.floor(Math.max(0, camera.position.x) / this.tileWidth));
|
||||
const viewWidth = parseInt(Math.min(Math.ceil(camera.width), this.columns));
|
||||
const viewY = parseInt(Math.floor(Math.max(0, camera.position.y)) / this.tileHeight);
|
||||
const viewHeight = parseInt(Math.min(Math.ceil(camera.height), this.rows));
|
||||
|
||||
for (let y = viewY; y < viewHeight; y++) {
|
||||
for (let x = viewX; x < viewWidth; x++) {
|
||||
@@ -235,6 +235,11 @@ export default class RetroArchitecture
|
||||
);
|
||||
}
|
||||
|
||||
getStartPosition()
|
||||
{
|
||||
return new GeometryPoint(this.startX * this.tileWidth, this.startY * this.tileHeight);
|
||||
}
|
||||
|
||||
static createFromData(level)
|
||||
{
|
||||
let graphicSet = GraphicSet[level.getTilesetId()];
|
||||
|
||||
@@ -82,7 +82,7 @@ export default class RetroSprite
|
||||
canvasTemp.width = this.image.width * this.scale;
|
||||
canvasTemp.height = this.image.height * this.scale;
|
||||
|
||||
let contextTemp = canvasTemp.getContext('2d');
|
||||
let contextTemp = canvasTemp.getContext('2d', {willReadFrequently: true});
|
||||
contextTemp.drawImage(this.image, 0, 0);
|
||||
|
||||
this.canvas.width = this.image.width * this.scale;
|
||||
@@ -99,4 +99,4 @@ export default class RetroSprite
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user