import { GameMap } from './GameMap' ; export interface ViewTracker { x : number ; y : number ; } export class View { constructor ( public gameMap , public width , public height , public x = 0 , public y = 0 ) { } public trace ( obj ) { this . x = ( obj . x / this . gameMap . scale ) - this . width / 2 ; this . y = ( obj . y / this . gameMap . scale ) - this . height / 2 ; } public absoluteX ( x ) { return ( x + this . x ) * this . gameMap . scale ; } public absoluteY ( y ) { return ( y + this . y ) * this . gameMap . scale ; } public relativeX ( x ) { return ( x / this . gameMap . scale ) - this . x ; } public relativeY ( y ) { return ( y / this . gameMap . scale ) - this . y ; } public relativeW ( width ) { return width / this . gameMap . scale ; } public relativeH ( height ) { return height / this . gameMap . scale ; } }