witcher-game-viewport
Version:
Creates a View Port for the game engine to display
24 lines (20 loc) • 723 B
JavaScript
export class Viewport {
constructor(player, canvas_width, canvas_height, world_width, world_height) {
this.player = player;
this.width = canvas_width;
this.height = canvas_height;
this.world_width = world_width;
this.world_height = world_height;
this.leftX = (this.player.worldX - 400) - canvas_width / 2;
this.rightX = (this.player.worldX + 400) + canvas_width / 2;
}
update() {
this.leftX = (this.player.worldX - 400) - this.width / 2;
this.rightX = (this.player.worldX + 400) + this.height / 2;
let result = {
"leftX" : this.leftX,
"rightX" : this.rightX
}
return result;
}
}