diff --git a/.travis.yml b/.travis.yml index 9eddaeef..46999a28 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,9 +12,9 @@ cache: before_install: - google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost & - gem install sass -v 3.4.24 -- npm i -g npm@6.5.0 +- npm i -g npm@6.8.0 script: -- node_modules/.bin/grunt travis +- npm run travis after_success: - node deploy-docs.js - if [[ "$TRAVIS_PULL_REQUEST" = "false" && ( "$TRAVIS_BRANCH" = "master" || "$TRAVIS_TAG" != "" ) ]]; then node_modules/.bin/grunt dists; fi diff --git a/GruntFile.js b/GruntFile.js index 6c753e3b..985d8579 100644 --- a/GruntFile.js +++ b/GruntFile.js @@ -295,6 +295,9 @@ module.exports = function(grunt) { // Default task - compile & test grunt.registerTask('default', ['tslint:src', 'core', 'karma', 'visual']); + // Lint only + grunt.registerTask('lint', ['tslint:src']); + // Core only grunt.registerTask('core', [ 'shell:gitBuild', diff --git a/package.json b/package.json index d4d3a88f..86343465 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,8 @@ "scripts": { "all": "grunt", "core": "grunt core", + "lint": "grunt lint", + "travis": "grunt travis", "visual": "grunt visual", "sandbox": "grunt sandbox", "start": "grunt watch", diff --git a/sandbox/tests/ui/index.ts b/sandbox/tests/ui/index.ts index a56337a8..54df5e3f 100644 --- a/sandbox/tests/ui/index.ts +++ b/sandbox/tests/ui/index.ts @@ -9,7 +9,7 @@ var loader = new ex.Loader(); for (var key in Resources) { if (Resources.hasOwnProperty(key)) { - loader.addResource(Resources[key]); + loader.addResource(Resources[key]); } } diff --git a/src/engine/Actions/Action.ts b/src/engine/Actions/Action.ts index 199fb6f4..75a2b372 100644 --- a/src/engine/Actions/Action.ts +++ b/src/engine/Actions/Action.ts @@ -8,14 +8,14 @@ import * as Util from '../Util/Util'; /** * Used for implementing actions for the [[ActionContext|Action API]]. */ -export interface IAction { +export interface Action { update(delta: number): void; isComplete(actor: Actor): boolean; reset(): void; stop(): void; } -export class EaseTo implements IAction { +export class EaseTo implements Action { private _currentLerpTime: number = 0; private _lerpDuration: number = 1 * 1000; // 1 second private _lerpStart: Vector = new Vector(0, 0); @@ -87,7 +87,7 @@ export class EaseTo implements IAction { } } -export class MoveTo implements IAction { +export class MoveTo implements Action { private _actor: Actor; public x: number; public y: number; @@ -138,7 +138,7 @@ export class MoveTo implements IAction { } } -export class MoveBy implements IAction { +export class MoveBy implements Action { private _actor: Actor; public x: number; public y: number; @@ -197,7 +197,7 @@ export class MoveBy implements IAction { } } -export class Follow implements IAction { +export class Follow implements Action { private _actor: Actor; private _actorToFollow: Actor; public x: number; @@ -272,7 +272,7 @@ export class Follow implements IAction { } } -export class Meet implements IAction { +export class Meet implements Action { private _actor: Actor; private _actorToMeet: Actor; public x: number; @@ -344,7 +344,7 @@ export class Meet implements IAction { } } -export class RotateTo implements IAction { +export class RotateTo implements Action { private _actor: Actor; public x: number; public y: number; @@ -442,7 +442,7 @@ export class RotateTo implements IAction { } } -export class RotateBy implements IAction { +export class RotateBy implements Action { private _actor: Actor; public x: number; public y: number; @@ -542,7 +542,7 @@ export class RotateBy implements IAction { } } -export class ScaleTo implements IAction { +export class ScaleTo implements Action { private _actor: Actor; public x: number; public y: number; @@ -613,7 +613,7 @@ export class ScaleTo implements IAction { } } -export class ScaleBy implements IAction { +export class ScaleBy implements Action { private _actor: Actor; public x: number; public y: number; @@ -674,7 +674,7 @@ export class ScaleBy implements IAction { } } -export class Delay implements IAction { +export class Delay implements Action { public x: number; public y: number; private _actor: Actor; @@ -712,7 +712,7 @@ export class Delay implements IAction { } } -export class Blink implements IAction { +export class Blink implements Action { private _timeVisible: number = 0; private _timeNotVisible: number = 0; private _elapsedTime: number = 0; @@ -766,7 +766,7 @@ export class Blink implements IAction { } } -export class Fade implements IAction { +export class Fade implements Action { public x: number; public y: number; @@ -821,7 +821,7 @@ export class Fade implements IAction { } } -export class Die implements IAction { +export class Die implements Action { public x: number; public y: number; @@ -851,7 +851,7 @@ export class Die implements IAction { } } -export class CallMethod implements IAction { +export class CallMethod implements Action { public x: number; public y: number; private _method: () => any = null; @@ -877,7 +877,7 @@ export class CallMethod implements IAction { } } -export class Repeat implements IAction { +export class Repeat implements Action { public x: number; public y: number; private _actor: Actor; @@ -885,7 +885,7 @@ export class Repeat implements IAction { private _repeat: number; private _originalRepeat: number; private _stopped: boolean = false; - constructor(actor: Actor, repeat: number, actions: IAction[]) { + constructor(actor: Actor, repeat: number, actions: Action[]) { this._actor = actor; this._actionQueue = new ActionQueue(actor); this._repeat = repeat; @@ -922,13 +922,13 @@ export class Repeat implements IAction { } } -export class RepeatForever implements IAction { +export class RepeatForever implements Action { public x: number; public y: number; private _actor: Actor; private _actionQueue: ActionQueue; private _stopped: boolean = false; - constructor(actor: Actor, actions: IAction[]) { + constructor(actor: Actor, actions: Action[]) { this._actor = actor; this._actionQueue = new ActionQueue(actor); @@ -980,18 +980,18 @@ export class RepeatForever implements IAction { */ export class ActionQueue { private _actor: Actor; - private _actions: IAction[] = []; - private _currentAction: IAction; - private _completedActions: IAction[] = []; + private _actions: Action[] = []; + private _currentAction: Action; + private _completedActions: Action[] = []; constructor(actor: Actor) { this._actor = actor; } - public add(action: IAction) { + public add(action: Action) { this._actions.push(action); } - public remove(action: IAction) { + public remove(action: Action) { var index = this._actions.indexOf(action); this._actions.splice(index, 1); } @@ -1004,7 +1004,7 @@ export class ActionQueue { } } - public getActions(): IAction[] { + public getActions(): Action[] { return this._actions.concat(this._completedActions); } diff --git a/src/engine/Actions/IActionable.ts b/src/engine/Actions/Actionable.ts similarity index 72% rename from src/engine/Actions/IActionable.ts rename to src/engine/Actions/Actionable.ts index 9337e697..d8535b5d 100644 --- a/src/engine/Actions/IActionable.ts +++ b/src/engine/Actions/Actionable.ts @@ -1,5 +1,5 @@ import { ActionContext } from './ActionContext'; -export interface IActionable { +export interface Actionable { actions: ActionContext; } diff --git a/src/engine/Actions/Index.ts b/src/engine/Actions/Index.ts index 31ac7ca1..787693c1 100644 --- a/src/engine/Actions/Index.ts +++ b/src/engine/Actions/Index.ts @@ -1,8 +1,9 @@ export * from './ActionContext'; -export * from './IActionable'; +export * from './Actionable'; export * from './RotationType'; import * as actions from './Action'; export { actions as Actions }; + // legacy Internal.Actions namespace support export var Internal = { Actions: actions }; diff --git a/src/engine/Actor.ts b/src/engine/Actor.ts index 99c6d7c0..ec476e94 100644 --- a/src/engine/Actor.ts +++ b/src/engine/Actor.ts @@ -27,25 +27,25 @@ import { PointerEvent, WheelEvent, PointerDragEvent } from './Input/Pointer'; import { Engine } from './Engine'; import { Color } from './Drawing/Color'; import { Sprite } from './Drawing/Sprite'; -import { IActorTrait } from './Interfaces/IActorTrait'; -import { IDrawable } from './Interfaces/IDrawable'; -import { ICanInitialize, ICanUpdate, ICanDraw, ICanBeKilled } from './Interfaces/LifecycleEvents'; +import { Trait } from './Interfaces/Trait'; +import { Drawable } from './Interfaces/Drawable'; +import { CanInitialize, CanUpdate, CanDraw, CanBeKilled } from './Interfaces/LifecycleEvents'; import { Scene } from './Scene'; import { Logger } from './Util/Log'; import { ActionContext } from './Actions/ActionContext'; import { ActionQueue } from './Actions/Action'; import { Vector } from './Algebra'; -import { ICollisionArea } from './Collision/ICollisionArea'; +import { CollisionArea } from './Collision/CollisionArea'; import { Body } from './Collision/Body'; import { Side } from './Collision/Side'; -import { IEvented } from './Interfaces/IEvented'; -import { IActionable } from './Actions/IActionable'; +import { Eventable } from './Interfaces/Evented'; +import { Actionable } from './Actions/Actionable'; import { Configurable } from './Configurable'; import * as Traits from './Traits/Index'; import * as Effects from './Drawing/SpriteEffects'; import * as Util from './Util/Util'; import * as Events from './Events'; -import { IPointerEvents } from './Interfaces/IPointerEvents'; +import { PointerEvents } from './Interfaces/PointerEvents'; export type PointerEventName = | 'pointerdragstart' @@ -62,7 +62,7 @@ export type PointerEventName = /** * [[include:Constructors.md]] */ -export interface IActorArgs extends Partial { +export interface ActorArgs extends Partial { width?: number; height?: number; pos?: Vector; @@ -77,7 +77,7 @@ export interface IActorArgs extends Partial { collisionType?: CollisionType; } -export interface IActorDefaults { +export interface ActorDefaults { anchor: Vector; } @@ -85,13 +85,13 @@ export interface IActorDefaults { * @hidden */ -export class ActorImpl extends Class implements IActionable, IEvented, IPointerEvents, ICanInitialize, ICanUpdate, ICanDraw, ICanBeKilled { +export class ActorImpl extends Class implements Actionable, Eventable, PointerEvents, CanInitialize, CanUpdate, CanDraw, CanBeKilled { // #region Properties /** * Indicates the next id to be set */ - public static defaults: IActorDefaults = { + public static defaults: ActorDefaults = { anchor: Vector.Half }; /** @@ -113,7 +113,7 @@ export class ActorImpl extends Class implements IActionable, IEvented, IPointerE * Gets the collision area shape to use for collision possible options are [CircleArea|circles], [PolygonArea|polygons], and * [EdgeArea|edges]. */ - public get collisionArea(): ICollisionArea { + public get collisionArea(): CollisionArea { return this.body.collisionArea; } @@ -121,7 +121,7 @@ export class ActorImpl extends Class implements IActionable, IEvented, IPointerE * Gets the collision area shape to use for collision possible options are [CircleArea|circles], [PolygonArea|polygons], and * [EdgeArea|edges]. */ - public set collisionArea(area: ICollisionArea) { + public set collisionArea(area: CollisionArea) { this.body.collisionArea = area; } @@ -423,7 +423,7 @@ export class ActorImpl extends Class implements IActionable, IEvented, IPointerE private _collisionHandlers: { [key: string]: { (actor: Actor): void }[] } = {}; private _isInitialized: boolean = false; - public frames: { [key: string]: IDrawable } = {}; + public frames: { [key: string]: Drawable } = {}; private _effectsDirty: boolean = false; /** @@ -431,12 +431,12 @@ export class ActorImpl extends Class implements IActionable, IEvented, IPointerE * an [[Animation]], [[Sprite]], or [[Polygon]]. * Set drawings with [[setDrawing]]. */ - public currentDrawing: IDrawable = null; + public currentDrawing: Drawable = null; /** * Modify the current actor update pipeline. */ - public traits: IActorTrait[] = []; + public traits: Trait[] = []; /** * Sets the color of the actor. A rectangle of this color will be @@ -461,7 +461,7 @@ export class ActorImpl extends Class implements IActionable, IEvented, IPointerE /** * Configuration for [[CapturePointer]] trait */ - public capturePointer: Traits.ICapturePointerConfig = { + public capturePointer: Traits.CapturePointerConfig = { captureMoveEvents: false, captureDragEvents: false }; @@ -480,7 +480,7 @@ export class ActorImpl extends Class implements IActionable, IEvented, IPointerE * @param color The starting color of the actor. Leave null to draw a transparent actor. The opacity of the color will be used as the * initial [[opacity]]. */ - constructor(xOrConfig?: number | IActorArgs, y?: number, width?: number, height?: number, color?: Color) { + constructor(xOrConfig?: number | ActorArgs, y?: number, width?: number, height?: number, color?: Color) { super(); if (xOrConfig && typeof xOrConfig === 'object') { @@ -933,7 +933,7 @@ export class ActorImpl extends Class implements IActionable, IEvented, IPointerE * @param key The key to associate with a drawing for this actor * @param drawing This can be an [[Animation]], [[Sprite]], or [[Polygon]]. */ - public addDrawing(key: any, drawing: IDrawable): void; + public addDrawing(key: any, drawing: Drawable): void; public addDrawing(): void { if (arguments.length === 2) { this.frames[arguments[0]] = arguments[1]; @@ -1289,7 +1289,7 @@ export class ActorImpl extends Class implements IActionable, IEvented, IPointerE return new Vector(this.getWidth() * this.anchor.x, this.getHeight() * this.anchor.y); } - protected _reapplyEffects(drawing: IDrawable) { + protected _reapplyEffects(drawing: Drawable) { drawing.removeEffect(this._opacityFx); drawing.addEffect(this._opacityFx); } @@ -1603,9 +1603,9 @@ export class ActorImpl extends Class implements IActionable, IEvented, IPointerE */ export class Actor extends Configurable(ActorImpl) { constructor(); - constructor(config?: IActorArgs); + constructor(config?: ActorArgs); constructor(x?: number, y?: number, width?: number, height?: number, color?: Color); - constructor(xOrConfig?: number | IActorArgs, y?: number, width?: number, height?: number, color?: Color) { + constructor(xOrConfig?: number | ActorArgs, y?: number, width?: number, height?: number, color?: Color) { super(xOrConfig, y, width, height, color); } } diff --git a/src/engine/Camera.ts b/src/engine/Camera.ts index 11708c99..56c7f80a 100644 --- a/src/engine/Camera.ts +++ b/src/engine/Camera.ts @@ -1,10 +1,10 @@ import { Engine } from './Engine'; import { EasingFunction, EasingFunctions } from './Util/EasingFunctions'; -import { IPromise, Promise, PromiseState } from './Promises'; +import { PromiseLike, Promise, PromiseState } from './Promises'; import { Vector } from './Algebra'; import { Actor } from './Actor'; import { removeItemFromArray } from './Util/Util'; -import { ICanUpdate, ICanInitialize } from './Interfaces/LifecycleEvents'; +import { CanUpdate, CanInitialize } from './Interfaces/LifecycleEvents'; import { PreUpdateEvent, PostUpdateEvent, GameEvent, InitializeEvent } from './Events'; import { Class } from './Class'; import { BoundingBox } from './Collision/BoundingBox'; @@ -13,7 +13,7 @@ import { obsolete } from './Util/Decorators'; /** * Interface that describes a custom camera strategy for tracking targets */ -export interface ICameraStrategy { +export interface CameraStrategy { /** * Target of the camera strategy that will be passed to the action */ @@ -88,7 +88,7 @@ export enum Axis { /** * Lock a camera to the exact x/y postition of an actor. */ -export class LockCameraToActorStrategy implements ICameraStrategy { +export class LockCameraToActorStrategy implements CameraStrategy { constructor(public target: Actor) {} public action = (target: Actor, _cam: Camera, _eng: Engine, _delta: number) => { let center = target.getCenter(); @@ -99,7 +99,7 @@ export class LockCameraToActorStrategy implements ICameraStrategy { /** * Lock a camera to a specific axis around an actor. */ -export class LockCameraToActorAxisStrategy implements ICameraStrategy { +export class LockCameraToActorAxisStrategy implements CameraStrategy { constructor(public target: Actor, public axis: Axis) {} public action = (target: Actor, cam: Camera, _eng: Engine, _delta: number) => { let center = target.getCenter(); @@ -115,7 +115,7 @@ export class LockCameraToActorAxisStrategy implements ICameraStrategy { /** * Using [Hook's law](https://en.wikipedia.org/wiki/Hooke's_law), elastically move the camera towards the target actor. */ -export class ElasticToActorStrategy implements ICameraStrategy { +export class ElasticToActorStrategy implements CameraStrategy { /** * If cameraElasticity < cameraFriction < 1.0, the behavior will be a dampened spring that will slowly end at the target without bouncing * If cameraFriction < cameraElasticity < 1.0, the behavior will be an oscillationg spring that will over @@ -150,7 +150,7 @@ export class ElasticToActorStrategy implements ICameraStrategy { }; } -export class RadiusAroundActorStrategy implements ICameraStrategy { +export class RadiusAroundActorStrategy implements CameraStrategy { /** * * @param target Target actor to follow when it is "radius" pixels away @@ -180,10 +180,10 @@ export class RadiusAroundActorStrategy implements ICameraStrategy { * * [[include:Cameras.md]] */ -export class Camera extends Class implements ICanUpdate, ICanInitialize { +export class Camera extends Class implements CanUpdate, CanInitialize { protected _follow: Actor; - private _cameraStrategies: ICameraStrategy[] = []; + private _cameraStrategies: CameraStrategy[] = []; public strategy: StrategyContainer = new StrategyContainer(this); @@ -208,7 +208,7 @@ export class Camera extends Class implements ICanUpdate, ICanInitialize { private _lerpDuration: number = 1000; // 1 second private _lerpStart: Vector = null; private _lerpEnd: Vector = null; - private _lerpPromise: IPromise; + private _lerpPromise: PromiseLike; //camera effects protected _isShaking: boolean = false; @@ -307,7 +307,7 @@ export class Camera extends Class implements ICanUpdate, ICanInitialize { * @returns A [[Promise]] that resolves when movement is finished, including if it's interrupted. * The [[Promise]] value is the [[Vector]] of the target position. It will be rejected if a move cannot be made. */ - public move(pos: Vector, duration: number, easingFn: EasingFunction = EasingFunctions.EaseInOutCubic): IPromise { + public move(pos: Vector, duration: number, easingFn: EasingFunction = EasingFunctions.EaseInOutCubic): PromiseLike { if (typeof easingFn !== 'function') { throw 'Please specify an EasingFunction'; } @@ -395,7 +395,7 @@ export class Camera extends Class implements ICanUpdate, ICanInitialize { * Adds a new camera strategy to this camera * @param cameraStrategy Instance of an [[ICameraStrategy]] */ - public addStrategy(cameraStrategy: ICameraStrategy) { + public addStrategy(cameraStrategy: CameraStrategy) { this._cameraStrategies.push(cameraStrategy); } @@ -403,7 +403,7 @@ export class Camera extends Class implements ICanUpdate, ICanInitialize { * Removes a camera strategy by reference * @param cameraStrategy Instance of an [[ICameraStrategy]] */ - public removeStrategy(cameraStrategy: ICameraStrategy) { + public removeStrategy(cameraStrategy: CameraStrategy) { removeItemFromArray(cameraStrategy, this._cameraStrategies); } diff --git a/src/engine/Class.ts b/src/engine/Class.ts index 2cc42875..34796be4 100644 --- a/src/engine/Class.ts +++ b/src/engine/Class.ts @@ -1,12 +1,12 @@ import { GameEvent } from './Events'; import { EventDispatcher } from './EventDispatcher'; -import { IEvented } from './Interfaces/IEvented'; +import { Eventable } from './Interfaces/Evented'; /** * Excalibur base class that provides basic functionality such as [[EventDispatcher]] * and extending abilities for vanilla Javascript projects */ -export class Class implements IEvented { +export class Class implements Eventable { /** * Direct access to the game object event dispatcher. */ diff --git a/src/engine/Collision/Body.ts b/src/engine/Collision/Body.ts index 8860284e..48a009d3 100644 --- a/src/engine/Collision/Body.ts +++ b/src/engine/Collision/Body.ts @@ -1,7 +1,7 @@ import { Physics, CollisionResolutionStrategy } from './../Physics'; import { EdgeArea } from './EdgeArea'; import { CircleArea } from './CircleArea'; -import { ICollisionArea } from './ICollisionArea'; +import { CollisionArea } from './CollisionArea'; import { PolygonArea } from './PolygonArea'; import { BoundingBox } from './BoundingBox'; import { Pair } from './Pair'; @@ -20,7 +20,7 @@ export class Body { /** * [[ICollisionArea|Collision area]] of this physics body, defines the shape for rigid body collision */ - public collisionArea: ICollisionArea = null; + public collisionArea: CollisionArea = null; /** * The (x, y) position of the actor this will be in the middle of the actor if the diff --git a/src/engine/Collision/BoundingBox.ts b/src/engine/Collision/BoundingBox.ts index 42e69e3f..a7989a8a 100644 --- a/src/engine/Collision/BoundingBox.ts +++ b/src/engine/Collision/BoundingBox.ts @@ -7,7 +7,7 @@ import { Color } from '../Drawing/Color'; /** * Interface all collidable objects must implement */ -export interface ICollidable { +export interface Collidable { /** * Test whether this bounding box collides with another one. * @@ -15,7 +15,7 @@ export interface ICollidable { * @returns Vector The intersection vector that can be used to resolve the collision. * If there is no collision, `null` is returned. */ - collides(collidable: ICollidable): Vector; + collides(collidable: Collidable): Vector; /** * Tests wether a point is contained within the collidable * @param point The point to test @@ -28,7 +28,7 @@ export interface ICollidable { /** * Axis Aligned collision primitive for Excalibur. */ -export class BoundingBox implements ICollidable { +export class BoundingBox implements Collidable { /** * @param left x coordinate of the left edge * @param top y coordinate of the top edge @@ -208,7 +208,7 @@ export class BoundingBox implements ICollidable { * @returns A Vector in the direction of the current BoundingBox * @param collidable Other collidable to test */ - public collides(collidable: ICollidable): Vector { + public collides(collidable: Collidable): Vector { if (collidable instanceof BoundingBox) { var other: BoundingBox = collidable; var totalBoundingBox = this.combine(other); diff --git a/src/engine/Collision/CircleArea.ts b/src/engine/Collision/CircleArea.ts index f3c12245..7ddba910 100644 --- a/src/engine/Collision/CircleArea.ts +++ b/src/engine/Collision/CircleArea.ts @@ -1,6 +1,6 @@ import { Body } from './Body'; import { BoundingBox } from './BoundingBox'; -import { ICollisionArea } from './ICollisionArea'; +import { CollisionArea } from './CollisionArea'; import { PolygonArea } from './PolygonArea'; import { EdgeArea } from './EdgeArea'; import { CollisionJumpTable } from './CollisionJumpTable'; @@ -10,7 +10,7 @@ import { Vector, Ray, Projection } from '../Algebra'; import { Physics } from '../Physics'; import { Color } from '../Drawing/Color'; -export interface ICircleAreaOptions { +export interface CircleAreaOptions { pos?: Vector; radius?: number; body?: Body; @@ -19,7 +19,7 @@ export interface ICircleAreaOptions { /** * This is a circle collision area for the excalibur rigid body physics simulation */ -export class CircleArea implements ICollisionArea { +export class CircleArea implements CollisionArea { /** * This is the center position of the circle, relative to the body position */ @@ -33,7 +33,7 @@ export class CircleArea implements ICollisionArea { */ public body: Body; - constructor(options: ICircleAreaOptions) { + constructor(options: CircleAreaOptions) { this.pos = options.pos || Vector.Zero; this.radius = options.radius || 0; this.body = options.body || null; @@ -99,7 +99,7 @@ export class CircleArea implements ICollisionArea { /** * @inheritdoc */ - public collide(area: ICollisionArea): CollisionContact { + public collide(area: CollisionArea): CollisionContact { if (area instanceof CircleArea) { return CollisionJumpTable.CollideCircleCircle(this, area); } else if (area instanceof PolygonArea) { diff --git a/src/engine/Collision/ICollisionArea.ts b/src/engine/Collision/CollisionArea.ts similarity index 93% rename from src/engine/Collision/ICollisionArea.ts rename to src/engine/Collision/CollisionArea.ts index c47dec86..a20c00ed 100644 --- a/src/engine/Collision/ICollisionArea.ts +++ b/src/engine/Collision/CollisionArea.ts @@ -1,4 +1,4 @@ -import { Color } from './../Drawing/Color'; +import { Color } from '../Drawing/Color'; import { CollisionContact } from './CollisionContact'; import { Body } from './Body'; import { BoundingBox } from './BoundingBox'; @@ -8,7 +8,7 @@ import { Vector, Projection, Ray } from '../Algebra'; * A collision area is a region of space that can detect when other collision areas intersect * for the purposes of colliding 2 objects in excalibur. */ -export interface ICollisionArea { +export interface CollisionArea { /** * Position of the collision area relative to the actor if it exists */ @@ -47,7 +47,7 @@ export interface ICollisionArea { // All new ICollisionAreas need to do the following // Create a new collision function in the CollisionJumpTable against all the primitives // Currently there are 3 primitive collision areas 3! = 6 jump functions - collide(area: ICollisionArea): CollisionContact; + collide(area: CollisionArea): CollisionContact; /** * Return wether the area contains a point inclusive to it's border diff --git a/src/engine/Collision/CollisionContact.ts b/src/engine/Collision/CollisionContact.ts index 6719fc82..8763500f 100644 --- a/src/engine/Collision/CollisionContact.ts +++ b/src/engine/Collision/CollisionContact.ts @@ -1,4 +1,4 @@ -import { ICollisionArea } from './ICollisionArea'; +import { CollisionArea } from './CollisionArea'; import { Body } from './Body'; import { Actor, CollisionType } from '../Actor'; @@ -19,11 +19,11 @@ export class CollisionContact { /** * The first rigid body in the collision */ - bodyA: ICollisionArea; + bodyA: CollisionArea; /** * The second rigid body in the collision */ - bodyB: ICollisionArea; + bodyB: CollisionArea; /** * The minimum translation vector to resolve penetration, pointing away from bodyA */ @@ -37,7 +37,7 @@ export class CollisionContact { */ normal: Vector; - constructor(bodyA: ICollisionArea, bodyB: ICollisionArea, mtv: Vector, point: Vector, normal: Vector) { + constructor(bodyA: CollisionArea, bodyB: CollisionArea, mtv: Vector, point: Vector, normal: Vector) { this.bodyA = bodyA; this.bodyB = bodyB; this.mtv = mtv; diff --git a/src/engine/Collision/ICollisionResolver.ts b/src/engine/Collision/CollisionResolver.ts similarity index 90% rename from src/engine/Collision/ICollisionResolver.ts rename to src/engine/Collision/CollisionResolver.ts index 58693074..21b8829f 100644 --- a/src/engine/Collision/ICollisionResolver.ts +++ b/src/engine/Collision/CollisionResolver.ts @@ -1,13 +1,13 @@ import { Body } from './Body'; -import { FrameStats } from './../Debug'; +import { FrameStats } from '../Debug'; import { Pair } from './Pair'; -import { Actor } from './../Actor'; +import { Actor } from '../Actor'; import { CollisionResolutionStrategy } from '../Physics'; /** * Definition for collision broadphase */ -export interface ICollisionBroadphase { +export interface CollisionBroadphase { /** * Track a physics body */ diff --git a/src/engine/Collision/DynamicTreeCollisionBroadphase.ts b/src/engine/Collision/DynamicTreeCollisionBroadphase.ts index c877e279..ea021bcd 100644 --- a/src/engine/Collision/DynamicTreeCollisionBroadphase.ts +++ b/src/engine/Collision/DynamicTreeCollisionBroadphase.ts @@ -1,5 +1,5 @@ import { Physics } from './../Physics'; -import { ICollisionBroadphase } from './ICollisionResolver'; +import { CollisionBroadphase } from './CollisionResolver'; import { DynamicTree } from './DynamicTree'; import { Pair } from './Pair'; import { Body } from './Body'; @@ -11,7 +11,7 @@ import { CollisionResolutionStrategy } from '../Physics'; import { Logger } from '../Util/Log'; import { CollisionStartEvent, CollisionEndEvent } from '../Events'; -export class DynamicTreeCollisionBroadphase implements ICollisionBroadphase { +export class DynamicTreeCollisionBroadphase implements CollisionBroadphase { private _dynamicCollisionTree = new DynamicTree(); private _collisionHash: { [key: string]: boolean } = {}; private _collisionPairCache: Pair[] = []; diff --git a/src/engine/Collision/EdgeArea.ts b/src/engine/Collision/EdgeArea.ts index 5bf10b99..e51a3c09 100644 --- a/src/engine/Collision/EdgeArea.ts +++ b/src/engine/Collision/EdgeArea.ts @@ -2,7 +2,7 @@ import { BoundingBox } from './BoundingBox'; import { CollisionContact } from './CollisionContact'; import { CollisionJumpTable } from './CollisionJumpTable'; -import { ICollisionArea } from './ICollisionArea'; +import { CollisionArea } from './CollisionArea'; import { CircleArea } from './CircleArea'; import { PolygonArea } from './PolygonArea'; @@ -10,19 +10,19 @@ import { Vector, Ray, Projection } from '../Algebra'; import { Physics } from '../Physics'; import { Color } from '../Drawing/Color'; -export interface IEdgeAreaOptions { +export interface EdgeAreaOptions { begin?: Vector; end?: Vector; body?: Body; } -export class EdgeArea implements ICollisionArea { +export class EdgeArea implements CollisionArea { body: Body; pos: Vector; begin: Vector; end: Vector; - constructor(options: IEdgeAreaOptions) { + constructor(options: EdgeAreaOptions) { this.begin = options.begin || Vector.Zero; this.end = options.end || Vector.Zero; this.body = options.body || null; @@ -115,7 +115,7 @@ export class EdgeArea implements ICollisionArea { /** * @inheritdoc */ - public collide(area: ICollisionArea): CollisionContact { + public collide(area: CollisionArea): CollisionContact { if (area instanceof CircleArea) { return CollisionJumpTable.CollideCircleEdge(area, this); } else if (area instanceof PolygonArea) { diff --git a/src/engine/Collision/Index.ts b/src/engine/Collision/Index.ts index d3272a8b..f51ff0fc 100644 --- a/src/engine/Collision/Index.ts +++ b/src/engine/Collision/Index.ts @@ -6,9 +6,9 @@ export * from './CollisionJumpTable'; export * from './DynamicTree'; export * from './DynamicTreeCollisionBroadphase'; export * from './EdgeArea'; -export * from './ICollisionArea'; -export * from './ICollisionResolver'; -export * from './IPhysics'; +export * from './CollisionArea'; +export * from './CollisionResolver'; +export * from './Physics'; export * from './NaiveCollisionBroadphase'; export * from './Pair'; export * from './PolygonArea'; diff --git a/src/engine/Collision/NaiveCollisionBroadphase.ts b/src/engine/Collision/NaiveCollisionBroadphase.ts index 51a76b76..71d2d412 100644 --- a/src/engine/Collision/NaiveCollisionBroadphase.ts +++ b/src/engine/Collision/NaiveCollisionBroadphase.ts @@ -2,10 +2,10 @@ import { CollisionContact } from './CollisionContact'; import { Pair } from './Pair'; import { Actor, CollisionType } from './../Actor'; -import { ICollisionBroadphase } from './ICollisionResolver'; +import { CollisionBroadphase } from './CollisionResolver'; import { CollisionStartEvent, CollisionEndEvent } from '../Events'; -export class NaiveCollisionBroadphase implements ICollisionBroadphase { +export class NaiveCollisionBroadphase implements CollisionBroadphase { private _lastFramePairs: Pair[] = []; private _lastFramePairsHash: { [pairId: string]: Pair } = {}; diff --git a/src/engine/Collision/IPhysics.ts b/src/engine/Collision/Physics.ts similarity index 93% rename from src/engine/Collision/IPhysics.ts rename to src/engine/Collision/Physics.ts index d788cc2f..2f8482d9 100644 --- a/src/engine/Collision/IPhysics.ts +++ b/src/engine/Collision/Physics.ts @@ -1,7 +1,7 @@ -import { Vector } from './../Algebra'; +import { Vector } from '../Algebra'; import { BroadphaseStrategy, CollisionResolutionStrategy } from '../Physics'; -export interface IEnginePhysics { +export interface EnginePhysics { /** * Global engine acceleration, useful for defining consistent gravity on all actors */ diff --git a/src/engine/Collision/PolygonArea.ts b/src/engine/Collision/PolygonArea.ts index cd2ae29e..2d9ea8fb 100644 --- a/src/engine/Collision/PolygonArea.ts +++ b/src/engine/Collision/PolygonArea.ts @@ -5,11 +5,11 @@ import { EdgeArea } from './EdgeArea'; import { CollisionJumpTable } from './CollisionJumpTable'; import { CircleArea } from './CircleArea'; import { CollisionContact } from './CollisionContact'; -import { ICollisionArea } from './ICollisionArea'; +import { CollisionArea } from './CollisionArea'; import { Body } from './Body'; import { Vector, Line, Ray, Projection } from './../Algebra'; -export interface IPolygonAreaOptions { +export interface PolygonAreaOptions { pos?: Vector; points?: Vector[]; clockwiseWinding?: boolean; @@ -19,7 +19,7 @@ export interface IPolygonAreaOptions { /** * Polygon collision area for detecting collisions for actors, or independently */ -export class PolygonArea implements ICollisionArea { +export class PolygonArea implements CollisionArea { public pos: Vector; public points: Vector[]; public body: Body; @@ -28,7 +28,7 @@ export class PolygonArea implements ICollisionArea { private _axes: Vector[] = []; private _sides: Line[] = []; - constructor(options: IPolygonAreaOptions) { + constructor(options: PolygonAreaOptions) { this.pos = options.pos || Vector.Zero; var winding = !!options.clockwiseWinding; this.points = (winding ? options.points.reverse() : options.points) || []; @@ -123,7 +123,7 @@ export class PolygonArea implements ICollisionArea { * return null. * @param area */ - public collide(area: ICollisionArea): CollisionContact { + public collide(area: CollisionArea): CollisionContact { if (area instanceof CircleArea) { return CollisionJumpTable.CollideCirclePolygon(area, this); } else if (area instanceof PolygonArea) { diff --git a/src/engine/Debug.ts b/src/engine/Debug.ts index 4d1c43fe..b3ebae69 100644 --- a/src/engine/Debug.ts +++ b/src/engine/Debug.ts @@ -1,10 +1,10 @@ -import { IDebugFlags } from './DebugFlags'; +import { DebugFlags } from './DebugFlags'; import { Pair } from './Collision/Pair'; /** * Debug stats containing current and previous frame statistics */ -export interface IDebugStats { +export interface DebugStats { currFrame: FrameStats; prevFrame: FrameStats; } @@ -12,14 +12,14 @@ export interface IDebugStats { /** * Hash containing the [[Pair.id]]s of pairs that collided in a frame */ -export interface ICollidersHash { +export interface CollidersHash { [pairId: string]: Pair; } /** * Represents a frame's individual statistics */ -export interface IFrameStats { +export interface FrameStatistics { /** * The number of the frame */ @@ -38,23 +38,23 @@ export interface IFrameStats { /** * Duration statistics (in ms) */ - duration: IFrameDurationStats; + duration: FrameDurationStats; /** * Actor statistics */ - actors: IFrameActorStats; + actors: FrameActorStats; /** * Physics statistics */ - physics: IPhysicsStats; + physics: PhysicsStatistics; } /** * Represents actor stats for a frame */ -export interface IFrameActorStats { +export interface FrameActorStats { /** * Gets the frame's number of actors (alive) */ @@ -84,7 +84,7 @@ export interface IFrameActorStats { /** * Represents duration stats for a frame */ -export interface IFrameDurationStats { +export interface FrameDurationStats { /** * Gets the frame's total time to run the update function (in ms) */ @@ -104,7 +104,7 @@ export interface IFrameDurationStats { /** * Represents physics stats for the current frame */ -export interface IPhysicsStats { +export interface PhysicsStatistics { /** * Gets the number of broadphase collision pairs which */ @@ -118,7 +118,7 @@ export interface IPhysicsStats { /** * A Hash storing the [[Pair.id]]s of [[Pair]]s that collided in the frame */ - collidersHash: ICollidersHash; + collidersHash: CollidersHash; /** * Gets the number of fast moving bodies using raycast continuous collisions in the scene @@ -146,11 +146,11 @@ export interface IPhysicsStats { * best to do so on the `postupdate` event for [[Engine]], after all values have been * updated during a frame. */ -export class Debug implements IDebugFlags { +export class Debug implements DebugFlags { /** * Performance statistics */ - public stats: IDebugStats = { + public stats: DebugStats = { /** * Current frame statistics. Engine reuses this instance, use [[FrameStats.clone]] to copy frame stats. * Best accessed on [[postframe]] event. See [[IFrameStats]] @@ -169,25 +169,25 @@ export class Debug implements IDebugFlags { * Implementation of a frame's stats. Meant to have values copied via [[FrameStats.reset]], avoid * creating instances of this every frame. */ -export class FrameStats implements IFrameStats { +export class FrameStats implements FrameStatistics { private _id: number = 0; private _delta: number = 0; private _fps: number = 0; - private _actorStats: IFrameActorStats = { + private _actorStats: FrameActorStats = { alive: 0, killed: 0, ui: 0, - get remaining(this: IFrameActorStats) { + get remaining(this: FrameActorStats) { return this.alive - this.killed; }, - get total(this: IFrameActorStats) { + get total(this: FrameActorStats) { return this.remaining + this.ui; } }; - private _durationStats: IFrameDurationStats = { + private _durationStats: FrameDurationStats = { update: 0, draw: 0, - get total(this: IFrameDurationStats) { + get total(this: FrameDurationStats) { return this.update + this.draw; } }; @@ -199,7 +199,7 @@ export class FrameStats implements IFrameStats { * * @param [otherStats] Optional stats to clone */ - public reset(otherStats?: IFrameStats) { + public reset(otherStats?: FrameStatistics) { if (otherStats) { this.id = otherStats.id; this.delta = otherStats.delta; @@ -295,10 +295,10 @@ export class FrameStats implements IFrameStats { } } -export class PhysicsStats implements IPhysicsStats { +export class PhysicsStats implements PhysicsStatistics { private _pairs: number = 0; private _collisions: number = 0; - private _collidersHash: ICollidersHash = {}; + private _collidersHash: CollidersHash = {}; private _fastBodies: number = 0; private _fastBodyCollisions: number = 0; private _broadphase: number = 0; @@ -309,7 +309,7 @@ export class PhysicsStats implements IPhysicsStats { * * @param [otherStats] Optional stats to clone */ - public reset(otherStats?: IPhysicsStats) { + public reset(otherStats?: PhysicsStatistics) { if (otherStats) { this.pairs = otherStats.pairs; this.collisions = otherStats.collisions; @@ -328,7 +328,7 @@ export class PhysicsStats implements IPhysicsStats { /** * Provides a clone of this instance. */ - public clone(): IPhysicsStats { + public clone(): PhysicsStatistics { var ps = new PhysicsStats(); ps.reset(this); @@ -352,11 +352,11 @@ export class PhysicsStats implements IPhysicsStats { this._collisions = value; } - public get collidersHash(): ICollidersHash { + public get collidersHash(): CollidersHash { return this._collidersHash; } - public set collidersHash(colliders: ICollidersHash) { + public set collidersHash(colliders: CollidersHash) { this._collidersHash = colliders; } diff --git a/src/engine/DebugFlags.ts b/src/engine/DebugFlags.ts index 15b2380a..137d979c 100644 --- a/src/engine/DebugFlags.ts +++ b/src/engine/DebugFlags.ts @@ -1 +1 @@ -export interface IDebugFlags {} +export interface DebugFlags {} diff --git a/src/engine/Deprecated.ts b/src/engine/Deprecated.ts new file mode 100644 index 00000000..246098df --- /dev/null +++ b/src/engine/Deprecated.ts @@ -0,0 +1,405 @@ +import { Actionable } from './Actions/Actionable'; +import { Trait } from './Interfaces/Trait'; +import { Drawable } from './Interfaces/Drawable'; +import { CanInitialize, CanActivate, CanDeactivate, CanUpdate, CanDraw, CanBeKilled } from './Interfaces/LifecycleEvents'; +import { CollisionArea } from './Collision/CollisionArea'; +import { Eventable } from './Interfaces/Evented'; +import { PointerEvents } from './Interfaces/PointerEvents'; +import { CameraStrategy } from './Camera'; +import { Loadable } from './Interfaces/Loadable'; +import { Action } from './Actions/Action'; +import { ActorArgs, ActorDefaults } from './Actor'; +import { CapturePointerConfig } from './Traits/CapturePointer'; +import { Collidable, CircleAreaOptions, CollisionBroadphase, EdgeAreaOptions, EnginePhysics, PolygonAreaOptions } from './Collision/Index'; +import { Physics } from './Physics'; +import { DebugFlags } from './DebugFlags'; +import { CollidersHash, FrameStatistics, FrameDurationStats, PhysicsStatistics, FrameActorStats } from './Debug'; +import { AnimationArgs } from './Drawing/Animation'; +import { SpriteEffect } from './Drawing/SpriteEffects'; +import { SpriteArgs } from './Drawing/Sprite'; +import { SpriteFontArgs, SpriteFontOptions } from './Drawing/SpriteSheet'; +import { CanLoad, Audio, ExResponseTypesLookup, AudioImplementation } from './Interfaces/Index'; +import { PostProcessor } from './PostProcessing/Index'; +import { AbsolutePosition, EngineOptions } from './Engine'; +import { EngineInput, NavigatorGamepad, NavigatorGamepads, GamepadConfiguration, ActorsUnderPointer } from './Input/Index'; +import { LabelArgs } from './Label'; +import { PerlinOptions } from './Math/PerlinNoise'; +import { ParticleArgs, ParticleEmitterArgs } from './Particles'; +import { TileMapArgs, CellArgs } from './TileMap'; +import { TriggerOptions } from './Trigger'; +import { ObsoleteOptions } from './Util/Decorators'; +import { DetectedFeatures } from './Util/Detector'; +import { BorderRadius } from './Util/DrawUtil'; +import { Appender } from './Util/Log'; + +/** + * @deprecated Use ActorsUnderPointer, IActorsUnderPointer will be deprecated in v0.23.0 + * @obsolete Use ActorsUnderPointer, IActorsUnderPointer will be deprecated in v0.23.0 + */ +export type IActorsUnderPointer = ActorsUnderPointer; + +/** + * @deprecated Use AbsolutePosition, IAbsolutePosition will be deprecated in v0.23.0 + * @obsolete Use AbsolutePosition, IAbsolutePosition will be deprecated in v0.23.0 + */ +export type IAbsolutePosition = AbsolutePosition; + +/** + * @deprecated Use Action, IAction will be deprecated in v0.23.0 + * @obsolete Use Action, IAction will be deprecated in v0.23.0 + */ +export type IAction = Action; + +/** + * @deprecated Use Actionable, IActionable will be deprecated in v0.23.0 + * @obsolete Use Actionable, IActionable will be deprecated in v0.23.0 + */ +export type IActionable = Actionable; + +/** + * @deprecated Use ActorArgs, IActorArgs will be deprecated in v0.23.0 + * @obsolete Use ActorArgs, IActorArgs will be deprecated in v0.23.0 + */ +export type IActorArgs = ActorArgs; + +/** + * @deprecated Use ActorDefaults, IActorDefaults will be deprecated in v0.23.0 + * @obsolete Use ActorDefaults, IActorDefaults will be deprecated in v0.23.0 + */ +export type IActorDefaults = ActorDefaults; + +/** + * @deprecated Use Trait, IActorTrait will be removed v0.23.0 + * @obsolete Use Trait, IActorTrait will be removed v0.23.0 + */ +export type IActorTrait = Trait; + +/** + * @deprecated Use AnimationArgs, IAnimationArgs will be removed v0.23.0 + * @obsolete Use AnimationArgs, IAnimationArgs will be removed v0.23.0 + */ +export type IAnimationArgs = AnimationArgs; + +/** + * @deprecated Use Appender, IAppender will be removed v0.23.0 + * @obsolete Use Appender, IAppender will be removed v0.23.0 + */ +export type IAppender = Appender; + +/** + * @deprecated Use Audio, IAudio will be removed v0.23.0 + * @obsolete Use Audio, IAudio will be removed v0.23.0 + */ +export type IAudio = Audio; + +/** + * @deprecated Use AudioImplementation, IAudioImplementation will be removed v0.23.0 + * @obsolete Use AudioImplementation, IAudioImplementation will be removed v0.23.0 + */ +export type IAudioImplementation = AudioImplementation; + +/** + * @deprecated Use BorderRadius, IBorderRadius will be removed v0.23.0 + * @obsolete Use BorderRadius, IBorderRadius will be removed v0.23.0 + */ +export type IBorderRadius = BorderRadius; + +/** + * @deprecated Use CanInitialize, ICanInitialize will be removed v0.23.0 + * @obsolete Use CanInitialize, ICanInitialize will be removed v0.23.0 + */ +export type ICanInitialize = CanInitialize; + +/** + * @deprecated Use CanActivate, ICanActivate will be removed v0.23.0 + * @obsolete Use CanActivate, ICanActivate will be removed v0.23.0 + */ +export type ICanActivate = CanActivate; + +/** + * @deprecated Use CanDeactivate, ICanDeactivate will be removed v0.23.0 + * @obsolete Use CanDeactivate, ICanDeactivate will be removed v0.23.0 + */ +export type ICanDeactivate = CanDeactivate; + +/** + * @deprecated Use CanUpdate, ICanUpdate will be removed in v0.23.0 + * @obsolete Use CanUpdate, ICanUpdate will be removed in v0.23.0 + */ +export type ICanUpdate = CanUpdate; + +/** + * @deprecated Use CanDraw, ICanDraw will be removed in v0.23.0 + * @obsolete Use CanDraw, ICanDraw will be removed in v0.23.0 + */ +export type ICanDraw = CanDraw; + +/** + * @deprecated Use CanBeKilled, ICanBeKilled will be removed in v0.23.0 + * @obsolete Use CanBeKilled, ICanBeKilled will be removed in v0.23.0 + */ +export type ICanBeKilled = CanBeKilled; + +/** + * @deprecated Use CameraStrategy, ICameraStrategy will be removed in v0.23.0 + * @obsolete Use CameraStrategy, ICameraStrategy will be removed in v0.23.0 + */ +export type ICameraStrategy = CameraStrategy; + +/** + * @deprecated Use CellArgs, ICellArgs will be removed in v0.23.0 + * @obsolete Use CellArgs, ICellArgs will be removed in v0.23.0 + */ +export type ICellArgs = CellArgs; + +/** + * @deprecated Use Collidable, ICollidable will be removed in v0.23.0 + * @obsolete Use Collidable, ICollidable will be removed in v0.23.0 + */ +export type ICollidable = Collidable; + +/** + * @deprecated Use CollisionArea, ICollisionArea will be removed in v0.23.0 + * @obsolete Use CollisionArea, ICollisionArea will be removed in v0.23.0 + */ +export type ICollisionArea = CollisionArea; + +/** + * @deprecated Use DetectedFeatures, IDetectedFeatures will be removed in v0.23.0 + * @obsolete Use DetectedFeatures, IDetectedFeatures will be removed in v0.23.0 + */ +export type IDetectedFeatures = DetectedFeatures; + +/** + * @deprecated Use ExResponseTypesLookup, IExResponseTypesLookup will be removed in v0.23.0 + * @obsolete Use ExResponseTypesLookup, IExResponseTypesLookup will be removed in v0.23.0 + */ +export type IExResponseTypesLookup = ExResponseTypesLookup; + +/** + * @deprecated Use Physics, IPhysics will be removed in v0.23.0 + * @obsolete Use Physics, IPhysics will be removed in v0.23.0 + */ +export type IPhysics = Physics; + +/** + * @deprecated Use DebugFlags, IDebugFlags will be removed in v0.23.0 + * @obsolete Use DebugFlags, IDebugFlags will be removed in v0.23.0 + */ +export type IDebugFlags = DebugFlags; + +/** + * @deprecated Use CollisionBroadphase, ICollisionBroadphase will be removed in v0.23.0 + * @obsolete Use CollisionBroadphase, ICollisionBroadphase will be removed in v0.23.0 + */ +export type ICollisionBroadphase = CollisionBroadphase; + +/** + * @deprecated Use CollidersHash, IColliderHash will be removed in v0.23.0 + * @obsolete Use CollidersHash, IColliderHash will be removed in v0.23.0 + */ +export type IColliderHash = CollidersHash; + +/** + * @deprecated Use CircleAreaOptions, ICircleAreaOptions will be removed in v0.23.0 + * @obsolete Use CircleAreaOptions, ICircleAreaOptions will be removed in v0.23.0 + */ +export type ICircleAreaOptions = CircleAreaOptions; + +/** + * @deprecated Use EdgeAreaOptions, IEdgeAreaOptions will be removed in v0.23.0 + * @obsolete Use EdgeAreaOptions, IEdgeAreaOptions will be removed in v0.23.0 + */ +export type IEdgeAreaOptions = EdgeAreaOptions; + +/** + * @deprecated Use PolygonAreaOptions, IPolygonAreaOptions will be removed in v0.23.0 + * @obsolete Use PolygonAreaOptions, IPolygonAreaOptions will be removed in v0.23.0 + */ +export type IPolygonAreaOptions = PolygonAreaOptions; + +/** + * @deprecated Use EngineOptions, IEngineOptions will be removed in v0.23.0 + * @obsolete Use EngineOptions, IEngineOptions will be removed in v0.23.0 + */ +export type IEngineOptions = EngineOptions; + +/** + * @deprecated Use EnginePhysics, IEnginePhysics will be removed in v0.23.0 + * @obsolete Use EnginePhysics, IEnginePhysics will be removed in v0.23.0 + */ +export type IEnginePhysics = EnginePhysics; + +/** + * @deprecated Use EngineInput, IEngineInput will be removed in v0.23.0 + * @obsolete Use EngineInput, IEngineInput will be removed in v0.23.0 + */ +export type IEngineInput = EngineInput; + +/** + * @deprecated Use FrameStatistics, IFrameStats will be removed in v0.23.0 + * @obsolete Use FrameStatistics, IFrameStats will be removed in v0.23.0 + */ +export type IFrameStats = FrameStatistics; + +/** + * @deprecated Use FrameDurationStats, IFrameDurationStats will be removed in v0.23.0 + * @obsolete Use FrameDurationStats, IFrameDurationStats will be removed in v0.23.0 + */ +export type IFrameDurationStats = FrameDurationStats; + +/** + * @deprecated Use FrameActorStats, IFrameActorStates will be removed in v0.23.0 + * @obsolete Use FrameActorStats, IFrameActorStates will be removed in v0.23.0 + */ +export type IFrameActorStates = FrameActorStats; + +/** + * @deprecated Use PhysicsStatistics, IPhysicsStats will be removed in v0.23.0 + * @obsolete Use PhysicsStatistics, IPhysicsStats will be removed in v0.23.0 + */ +export type IPhysicsStats = PhysicsStatistics; + +/** + * @deprecated Use Drawable, IDrawable will be removed v0.23.0 + * @obsolete Use Drawable, IDrawable will be removed v0.23.0 + */ +export type IDrawable = Drawable; + +/** + * @deprecated Use Eventable, IEvented will be removed in v0.23.0 + * @obsolete Use Eventable, IEvented will be removed in v0.23.0 + */ +export type IEvented = Eventable; + +/** + * @deprecated Use NavigatorGamepads, INavigatorGamepads will be removed in v0.23.0 + * @obsolete Use NavigatorGamepads, INavigatorGamepads will be removed in v0.23.0 + */ +export type INavigatorGamepads = NavigatorGamepads; + +/** + * @deprecated Use NavigatorGamepad, INavigatorGamepad will be removed in v0.23.0 + * @obsolete Use NavigatorGamepad, INavigatorGamepad will be removed in v0.23.0 + */ +export type INavigatorGamepad = NavigatorGamepad; + +/** + * @deprecated Use GamepadConfiguration, IGamepadConfiguration will be removed in v0.23.0 + * @obsolete Use GamepadConfiguration, IGamepadConfiguration will be removed in v0.23.0 + */ +export type IGamepadConfiguration = GamepadConfiguration; + +/** + * @deprecated Use ObsoleteOptions, IObsoleteOptions will be removed in v0.23.0 + * @obsolete Use ObsoleteOptions, IObsoleteOptions will be removed in v0.23.0 + */ +export type IObsoleteOptions = ObsoleteOptions; + +/** + * @deprecated Use PointerEvents, IPointerEvents will be removed in v0.23.0 + * @obsolete Use PointerEvents, IPointerEvents will be removed in v0.23.0 + */ +export type IPointerEvents = PointerEvents; + +/** + * @deprecated Use Loadable, ILoadable will be removed in v0.23.0 + * @obsolete Use Loadable, ILoadable will be removed in v0.23.0 + */ +export type ILoadable = Loadable; + +/** + * @deprecated Use CanLoad, ILoader will be removed in v0.23.0 + * @obsolete Use CanLoad, ILoader will be removed in v0.23.0 + */ +export type ILoader = CanLoad; + +/** + * @deprecated Use CapturePointerConfig, ICapturePointerConfig will be removed in v0.23.0 + * @obsolete Use CapturePointerConfig, ICapturePointerConfig will be removed in v0.23.0 + */ +export type ICapturePointerConfig = CapturePointerConfig; + +/** + * @deprecated Use PromiseLike, IPromise will be removed in v0.23.0 + * @obsolete Use PromiseLike, IPromise will be removed in v0.23.0 + */ +export type IPromise = PromiseLike; + +/** + * @deprecated Use SpriteEffect, ISpriteEffect will be removed in v0.23.0 + * @obsolete Use SpriteEffect, ISpriteEffect will be removed in v0.23.0 + */ +export type ISpriteEffect = SpriteEffect; + +/** + * @deprecated Use SpriteArgs, ISpriteArgs will be removed in v0.23.0 + * @obsolete Use SpriteArgs, ISpriteArgs will be removed in v0.23.0 + */ +export type ISpriteArgs = SpriteArgs; + +/** + * @deprecated Use SpriteFontArgs, ISpriteFontInitArgs will be removed in v0.23.0 + * @obsolete Use SpriteFontArgs, ISpriteFontInitArgs will be removed in v0.23.0 + */ +export type ISpriteFontInitArgs = SpriteFontArgs; + +/** + * @deprecated Use SpriteFontOptions, ISpriteFrontOptions will be removed in v0.23.0 + * @obsolete Use SpriteFontOptions, ISpriteFrontOptions will be removed in v0.23.0 + */ +export type ISpriteFrontOptions = SpriteFontOptions; + +/** + * @deprecated Use TileMapArgs, ITileMapArgs will be removed in v0.23.0 + * @obsolete Use TileMapArgs, ITileMapArgs will be removed in v0.23.0 + */ +export type ITileMapArgs = TileMapArgs; + +/** + * @deprecated Use TouchEvent, ITouchEvent will be removed in v0.23.0 + * @obsolete Use TouchEvent, ITouchEvent will be removed in v0.23.0 + */ +export type ITouchEvent = TouchEvent; + +/** + * @deprecated Use Touch, ITouch will be removed in v0.23.0 + * @obsolete Use Touch, ITouch will be removed in v0.23.0 + */ +export type ITouch = Touch; + +/** + * @deprecated Use TriggerOptions, ITriggerOptions will be removed in v0.23.0 + * @obsolete Use TriggerOptions, ITriggerOptions will be removed in v0.23.0 + */ +export type ITriggerOptions = TriggerOptions; + +/** + * @deprecated Use ParticleArgs, IParticleArgs will be removed in v0.23.0 + * @obsolete Use ParticleArgs, IParticleArgs will be removed in v0.23.0 + */ +export type IParticleArgs = ParticleArgs; + +/** + * @deprecated Use ParticleEmitterArgs, IParticleEmitterArgs will be removed in v0.23.0 + * @obsolete Use ParticleEmitterArgs, IParticleEmitterArgs will be removed in v0.23.0 + */ +export type IParticleEmitterArgs = ParticleEmitterArgs; + +/** + * @deprecated Use PerlinOptions, IPerlinGeneratorOptions will be removed in v0.23.0 + * @obsolete Use PerlinOptions, IPerlinGeneratorOptions will be removed in v0.23.0 + */ +export type IPerlinGeneratorOptions = PerlinOptions; + +/** + * @deprecated Use PostProcessor, IPostProcessor will be removed in v0.23.0 + * @obsolete Use PostProcessor, IPostProcessor will be removed in v0.23.0 + */ +export type IPostProcessor = PostProcessor; + +/** + * @deprecated Use LabelArgs, ILabelArgs will be removed in v0.23.0 + * @obsolete Use LabelArgs, ILabelArgs will be removed in v0.23.0 + */ +export type ILabelArgs = LabelArgs; diff --git a/src/engine/Drawing/Animation.ts b/src/engine/Drawing/Animation.ts index 2cb28fe9..e24ddb08 100644 --- a/src/engine/Drawing/Animation.ts +++ b/src/engine/Drawing/Animation.ts @@ -1,9 +1,9 @@ import { Sprite } from './Sprite'; -import { IAnimationArgs } from '../Drawing/Animation'; +import { AnimationArgs } from '../Drawing/Animation'; import * as Effects from './SpriteEffects'; import { Color } from './Color'; -import { IDrawable } from '../Interfaces/IDrawable'; +import { Drawable } from '../Interfaces/Drawable'; import { Vector } from '../Algebra'; import { Engine } from '../Engine'; import * as Util from '../Util/Util'; @@ -12,7 +12,7 @@ import { Configurable } from '../Configurable'; /** * @hidden */ -export class AnimationImpl implements IDrawable { +export class AnimationImpl implements Drawable { /** * The sprite frames to play, in order. See [[SpriteSheet.getAnimationForAll]] to quickly * generate an [[Animation]]. @@ -71,7 +71,7 @@ export class AnimationImpl implements IDrawable { * @param speed The number in milliseconds to display each frame in the animation * @param loop Indicates whether the animation should loop after it is completed */ - constructor(engineOrConfig: Engine | IAnimationArgs, sprites: Sprite[], speed: number, loop?: boolean) { + constructor(engineOrConfig: Engine | AnimationArgs, sprites: Sprite[], speed: number, loop?: boolean) { var engine = engineOrConfig; if (engineOrConfig && !(engineOrConfig instanceof Engine)) { var config = engineOrConfig; @@ -167,7 +167,7 @@ export class AnimationImpl implements IDrawable { /** * Add a [[ISpriteEffect]] manually */ - public addEffect(effect: Effects.ISpriteEffect) { + public addEffect(effect: Effects.SpriteEffect) { for (var i in this.sprites) { this.sprites[i].addEffect(effect); } @@ -177,7 +177,7 @@ export class AnimationImpl implements IDrawable { * Removes an [[ISpriteEffect]] from this animation. * @param effect Effect to remove from this animation */ - public removeEffect(effect: Effects.ISpriteEffect): void; + public removeEffect(effect: Effects.SpriteEffect): void; /** * Removes an effect given the index from this animation. @@ -305,7 +305,7 @@ export class AnimationImpl implements IDrawable { /** * [[include:Constructors.md]] */ -export interface IAnimationArgs extends Partial { +export interface AnimationArgs extends Partial { engine: Engine; sprites: Sprite[]; speed: number; @@ -326,9 +326,9 @@ export interface IAnimationArgs extends Partial { * [[include:Animations.md]] */ export class Animation extends Configurable(AnimationImpl) { - constructor(config: IAnimationArgs); + constructor(config: AnimationArgs); constructor(engine: Engine, images: Sprite[], speed: number, loop?: boolean); - constructor(engineOrConfig: Engine | IAnimationArgs, images?: Sprite[], speed?: number, loop?: boolean) { + constructor(engineOrConfig: Engine | AnimationArgs, images?: Sprite[], speed?: number, loop?: boolean) { super(engineOrConfig, images, speed, loop); } } diff --git a/src/engine/Drawing/Index.ts b/src/engine/Drawing/Index.ts index a1809530..095d9889 100644 --- a/src/engine/Drawing/Index.ts +++ b/src/engine/Drawing/Index.ts @@ -1,8 +1,8 @@ -export { Animation, IAnimationArgs } from './Animation'; +export { Animation, AnimationArgs } from './Animation'; export * from './Color'; export * from './Polygon'; -export { Sprite, ISpriteArgs } from './Sprite'; -export { SpriteSheet, SpriteFont, ISpriteSheetArgs, ISpriteFontInitArgs, ISpriteFontOptions } from './SpriteSheet'; +export { Sprite, SpriteArgs } from './Sprite'; +export { SpriteSheet, SpriteFont, SpriteSheetArgs, SpriteFontArgs as SpriteFontInitArgs, SpriteFontOptions } from './SpriteSheet'; import * as effects from './SpriteEffects'; export { effects as Effects }; diff --git a/src/engine/Drawing/Polygon.ts b/src/engine/Drawing/Polygon.ts index edb79650..79a1cf17 100644 --- a/src/engine/Drawing/Polygon.ts +++ b/src/engine/Drawing/Polygon.ts @@ -1,7 +1,7 @@ import { Color } from './Color'; import * as Effects from './SpriteEffects'; -import { IDrawable } from '../Interfaces/IDrawable'; +import { Drawable } from '../Interfaces/Drawable'; import { Vector } from '../Algebra'; /** @@ -9,7 +9,7 @@ import { Vector } from '../Algebra'; * * @warning Use sparingly as Polygons are performance intensive */ -export class Polygon implements IDrawable { +export class Polygon implements Drawable { public flipVertical: boolean; public flipHorizontal: boolean; public drawWidth: number; @@ -81,7 +81,7 @@ export class Polygon implements IDrawable { /** * @notimplemented Effects are not supported on `Polygon` */ - public removeEffect(effect: Effects.ISpriteEffect): void; + public removeEffect(effect: Effects.SpriteEffect): void; /** * @notimplemented Effects are not supported on `Polygon` */ diff --git a/src/engine/Drawing/Sprite.ts b/src/engine/Drawing/Sprite.ts index 5b57cffb..5691dff3 100644 --- a/src/engine/Drawing/Sprite.ts +++ b/src/engine/Drawing/Sprite.ts @@ -1,7 +1,7 @@ import * as Effects from './SpriteEffects'; import { Color } from './Color'; -import { IDrawable } from '../Interfaces/IDrawable'; +import { Drawable } from '../Interfaces/Drawable'; import { Texture } from '../Resources/Texture'; import { Vector } from '../Algebra'; import { Logger } from '../Util/Log'; @@ -11,7 +11,7 @@ import { Configurable } from '../Configurable'; /** * @hidden */ -export class SpriteImpl implements IDrawable { +export class SpriteImpl implements Drawable { private _texture: Texture; public x: number = 0; @@ -41,7 +41,7 @@ export class SpriteImpl implements IDrawable { */ public flipHorizontal: boolean = false; - public effects: Effects.ISpriteEffect[] = []; + public effects: Effects.SpriteEffect[] = []; public width: number = 0; public height: number = 0; @@ -59,7 +59,7 @@ export class SpriteImpl implements IDrawable { * @param width The width of the sprite in pixels * @param height The height of the sprite in pixels */ - constructor(imageOrConfig: Texture | ISpriteArgs, x: number, y: number, width: number, height: number) { + constructor(imageOrConfig: Texture | SpriteArgs, x: number, y: number, width: number, height: number) { var image = imageOrConfig; if (imageOrConfig && !(imageOrConfig instanceof Texture)) { x = imageOrConfig.x | 0; @@ -205,7 +205,7 @@ export class SpriteImpl implements IDrawable { * Adds a new [[ISpriteEffect]] to this drawing. * @param effect Effect to add to the this drawing */ - public addEffect(effect: Effects.ISpriteEffect) { + public addEffect(effect: Effects.SpriteEffect) { this.effects.push(effect); // We must check if the texture and the backing sprite pixels are loaded as well before // an effect can be applied @@ -220,7 +220,7 @@ export class SpriteImpl implements IDrawable { * Removes a [[ISpriteEffect]] from this sprite. * @param effect Effect to remove from this sprite */ - public removeEffect(effect: Effects.ISpriteEffect): void; + public removeEffect(effect: Effects.SpriteEffect): void; /** * Removes an effect given the index from this sprite. @@ -371,7 +371,7 @@ export class SpriteImpl implements IDrawable { /** * [[include:Constructors.md]] */ -export interface ISpriteArgs extends Partial { +export interface SpriteArgs extends Partial { image?: Texture; x?: number; width?: number; @@ -390,9 +390,9 @@ export interface ISpriteArgs extends Partial { * [[include:Sprites.md]] */ export class Sprite extends Configurable(SpriteImpl) { - constructor(config: ISpriteArgs); + constructor(config: SpriteArgs); constructor(image: Texture, x: number, y: number, width: number, height: number); - constructor(imageOrConfig: Texture | ISpriteArgs, x?: number, y?: number, width?: number, height?: number) { + constructor(imageOrConfig: Texture | SpriteArgs, x?: number, y?: number, width?: number, height?: number) { super(imageOrConfig, x, y, width, height); } } diff --git a/src/engine/Drawing/SpriteEffects.ts b/src/engine/Drawing/SpriteEffects.ts index 6d0e9afd..7598d518 100644 --- a/src/engine/Drawing/SpriteEffects.ts +++ b/src/engine/Drawing/SpriteEffects.ts @@ -14,7 +14,7 @@ import { Color } from './Color'; /** * The interface that all sprite effects must implement */ -export interface ISpriteEffect { +export interface SpriteEffect { /** * Should update individual pixels values * @param x The pixel's x coordinate @@ -27,7 +27,7 @@ export interface ISpriteEffect { /** * Applies the "Grayscale" effect to a sprite, removing color information. */ -export class Grayscale implements ISpriteEffect { +export class Grayscale implements SpriteEffect { updatePixel(x: number, y: number, imageData: ImageData): void { var firstPixel = (x + y * imageData.width) * 4; var pixel = imageData.data; @@ -41,7 +41,7 @@ export class Grayscale implements ISpriteEffect { /** * Applies the "Invert" effect to a sprite, inverting the pixel colors. */ -export class Invert implements ISpriteEffect { +export class Invert implements SpriteEffect { updatePixel(x: number, y: number, imageData: ImageData): void { var firstPixel = (x + y * imageData.width) * 4; var pixel = imageData.data; @@ -54,7 +54,7 @@ export class Invert implements ISpriteEffect { /** * Applies the "Opacity" effect to a sprite, setting the alpha of all pixels to a given value. */ -export class Opacity implements ISpriteEffect { +export class Opacity implements SpriteEffect { /** * @param opacity The new opacity of the sprite from 0-1.0 */ @@ -72,7 +72,7 @@ export class Opacity implements ISpriteEffect { * Applies the "Colorize" effect to a sprite, changing the color channels of all the pixels to an * average of the original color and the provided color */ -export class Colorize implements ISpriteEffect { +export class Colorize implements SpriteEffect { /** * @param color The color to apply to the sprite */ @@ -91,7 +91,7 @@ export class Colorize implements ISpriteEffect { /** * Applies the "Lighten" effect to a sprite, changes the lightness of the color according to HSL */ -export class Lighten implements ISpriteEffect { +export class Lighten implements SpriteEffect { /** * @param factor The factor of the effect between 0-1 */ @@ -112,7 +112,7 @@ export class Lighten implements ISpriteEffect { /** * Applies the "Darken" effect to a sprite, changes the darkness of the color according to HSL */ -export class Darken implements ISpriteEffect { +export class Darken implements SpriteEffect { /** * @param factor The factor of the effect between 0-1 */ @@ -133,7 +133,7 @@ export class Darken implements ISpriteEffect { /** * Applies the "Saturate" effect to a sprite, saturates the color according to HSL */ -export class Saturate implements ISpriteEffect { +export class Saturate implements SpriteEffect { /** * @param factor The factor of the effect between 0-1 */ @@ -154,7 +154,7 @@ export class Saturate implements ISpriteEffect { /** * Applies the "Desaturate" effect to a sprite, desaturates the color according to HSL */ -export class Desaturate implements ISpriteEffect { +export class Desaturate implements SpriteEffect { /** * @param factor The factor of the effect between 0-1 */ @@ -176,7 +176,7 @@ export class Desaturate implements ISpriteEffect { * Applies the "Fill" effect to a sprite, changing the color channels of all non-transparent pixels to match * a given color */ -export class Fill implements ISpriteEffect { +export class Fill implements SpriteEffect { /** * @param color The color to apply to the sprite */ diff --git a/src/engine/Drawing/SpriteSheet.ts b/src/engine/Drawing/SpriteSheet.ts index e77dbf78..33e791e2 100644 --- a/src/engine/Drawing/SpriteSheet.ts +++ b/src/engine/Drawing/SpriteSheet.ts @@ -1,4 +1,4 @@ -import { Sprite, ISpriteArgs } from './Sprite'; +import { Sprite, SpriteArgs } from './Sprite'; import { Animation } from './Animation'; import { Color } from './Color'; import * as Effects from './SpriteEffects'; @@ -29,7 +29,7 @@ export class SpriteSheetImpl { * @param spacing The spacing between every sprite in a spritesheet */ constructor( - imageOrConfigOrSprites: Texture | ISpriteSheetArgs | Sprite[], + imageOrConfigOrSprites: Texture | SpriteSheetArgs | Sprite[], columns?: number, rows?: number, spWidth?: number, @@ -169,7 +169,7 @@ export class SpriteSheetImpl { * @param spriteCoordinates * @param speed */ - public getAnimationByCoords(engine: Engine, spriteCoordinates: ISpriteArgs[], speed: number): Animation { + public getAnimationByCoords(engine: Engine, spriteCoordinates: SpriteArgs[], speed: number): Animation { let maxWidth: number = 0; let maxHeight: number = 0; let sprites: Sprite[] = new Array(spriteCoordinates.length); @@ -193,7 +193,7 @@ export class SpriteSheetImpl { /** * [[include:Constructors.md]] */ -export interface ISpriteSheetArgs extends Partial { +export interface SpriteSheetArgs extends Partial { image: Texture; sprites?: Sprite[]; spWidth: number; @@ -211,11 +211,11 @@ export interface ISpriteSheetArgs extends Partial { * [[include:SpriteSheets.md]] */ export class SpriteSheet extends Configurable(SpriteSheetImpl) { - constructor(config: ISpriteSheetArgs); + constructor(config: SpriteSheetArgs); constructor(sprites: Sprite[]); constructor(image: Texture, columns: number, rows: number, spWidth: number, spHeight: number); constructor( - imageOrConfigOrSprites: Texture | ISpriteSheetArgs | Sprite[], + imageOrConfigOrSprites: Texture | SpriteSheetArgs | Sprite[], columns?: number, rows?: number, spWidth?: number, @@ -251,7 +251,7 @@ export class SpriteFontImpl extends SpriteSheet { * @param spHeight The height of each character in pixels */ constructor( - imageOrConfig: Texture | ISpriteFontInitArgs, + imageOrConfig: Texture | SpriteFontArgs, alphabet: string, caseInsensitive: boolean, columns: number, @@ -328,7 +328,7 @@ export class SpriteFontImpl extends SpriteSheet { /** * Draws the current sprite font */ - public draw(ctx: CanvasRenderingContext2D, text: string, x: number, y: number, options: ISpriteFontOptions) { + public draw(ctx: CanvasRenderingContext2D, text: string, x: number, y: number, options: SpriteFontOptions) { options = this._parseOptions(options); if (this._currentColor.toString() !== options.color.toString() || this._currentOpacity !== options.opacity) { @@ -406,7 +406,7 @@ export class SpriteFontImpl extends SpriteSheet { } } - private _parseOptions(options: ISpriteFontOptions): ISpriteFontOptions { + private _parseOptions(options: SpriteFontOptions): SpriteFontOptions { return { fontSize: options.fontSize || 10, letterSpacing: options.letterSpacing || 0, @@ -422,7 +422,7 @@ export class SpriteFontImpl extends SpriteSheet { /** * Specify various font attributes for sprite fonts */ -export interface ISpriteFontOptions { +export interface SpriteFontOptions { color?: Color; opacity?: number; fontSize?: number; @@ -435,7 +435,7 @@ export interface ISpriteFontOptions { /** * [[include:Constructors.md]] */ -export interface ISpriteFontInitArgs extends ISpriteSheetArgs { +export interface SpriteFontArgs extends SpriteSheetArgs { image: Texture; columns: number; rows: number; @@ -453,10 +453,10 @@ export interface ISpriteFontInitArgs extends ISpriteSheetArgs { * [[include:SpriteFonts.md]] */ export class SpriteFont extends Configurable(SpriteFontImpl) { - constructor(config: ISpriteFontInitArgs); + constructor(config: SpriteFontArgs); constructor(image: Texture, alphabet: string, caseInsensitive: boolean, columns: number, rows: number, spWidth: number, spHeight: number); constructor( - imageOrConfig: Texture | ISpriteFontInitArgs, + imageOrConfig: Texture | SpriteFontArgs, alphabet?: string, caseInsensitive?: boolean, columns?: number, diff --git a/src/engine/Engine.ts b/src/engine/Engine.ts index 548a5c4c..951d853b 100644 --- a/src/engine/Engine.ts +++ b/src/engine/Engine.ts @@ -1,7 +1,7 @@ import { EX_VERSION } from './'; import './Polyfill'; -import { ICanUpdate, ICanDraw, ICanInitialize } from './Interfaces/LifecycleEvents'; -import { ILoadable } from './Interfaces/ILoadable'; +import { CanUpdate, CanDraw, CanInitialize } from './Interfaces/LifecycleEvents'; +import { Loadable } from './Interfaces/Loadable'; import { Promise } from './Promises'; import { Vector } from './Algebra'; import { UIActor } from './UIActor'; @@ -27,12 +27,12 @@ import { PostDrawEvent, InitializeEvent } from './Events'; -import { ILoader } from './Interfaces/ILoader'; +import { CanLoad } from './Interfaces/Loader'; import { Logger, LogLevel } from './Util/Log'; import { Color } from './Drawing/Color'; import { Scene } from './Scene'; -import { IPostProcessor } from './PostProcessing/IPostProcessor'; -import { Debug, IDebugStats } from './Debug'; +import { PostProcessor } from './PostProcessing/PostProcessor'; +import { Debug, DebugStats } from './Debug'; import { Class } from './Class'; import * as Input from './Input/Index'; import * as Util from './Util/Util'; @@ -85,7 +85,7 @@ export enum ScrollPreventionMode { * is specified and when the user wants to define exact pixel spacing of the window. * When a number is given, the value is interpreted as pixels */ -export interface IAbsolutePosition { +export interface AbsolutePosition { top?: number | string; left?: number | string; right?: number | string; @@ -95,7 +95,7 @@ export interface IAbsolutePosition { /** * Defines the available options to configure the Excalibur engine at constructor time. */ -export interface IEngineOptions { +export interface EngineOptions { /** * Optionally configure the native canvas width of the game */ @@ -159,7 +159,7 @@ export interface IEngineOptions { * Valid String examples: "top left", "top", "bottom", "middle", "middle center", "bottom right" * Valid [[IAbsolutePosition]] examples: `{top: 5, right: 10%}`, `{bottom: 49em, left: 10px}`, `{left: 10, bottom: 40}` */ - position?: string | IAbsolutePosition; + position?: string | AbsolutePosition; /** * Scroll prevention method. @@ -181,7 +181,7 @@ export interface IEngineOptions { * * [[include:Engine.md]] */ -export class Engine extends Class implements ICanInitialize, ICanUpdate, ICanDraw { +export class Engine extends Class implements CanInitialize, CanUpdate, CanDraw { /** * Direct access to the engine's canvas element */ @@ -271,7 +271,7 @@ export class Engine extends Class implements ICanInitialize, ICanUpdate, ICanDra /** * Access engine input like pointer, keyboard, or gamepad */ - public input: Input.IEngineInput; + public input: Input.EngineInput; private _hasStarted: boolean = false; @@ -283,14 +283,14 @@ export class Engine extends Class implements ICanInitialize, ICanUpdate, ICanDra /** * Access [[stats]] that holds frame statistics. */ - public get stats(): IDebugStats { + public get stats(): DebugStats { return this.debug.stats; } /** * Gets or sets the list of post processors to apply at the end of drawing a frame (such as [[ColorBlindCorrector]]) */ - public postProcessors: IPostProcessor[] = []; + public postProcessors: PostProcessor[] = []; /** * The current [[Scene]] being drawn and updated on screen @@ -343,7 +343,7 @@ export class Engine extends Class implements ICanInitialize, ICanUpdate, ICanDra /** * Indicates the current position of the engine. Valid only when DisplayMode is DisplayMode.Position */ - public position: string | IAbsolutePosition; + public position: string | AbsolutePosition; /** * Indicates whether audio should be paused when the game is no longer visible. */ @@ -388,7 +388,7 @@ export class Engine extends Class implements ICanInitialize, ICanUpdate, ICanDra private _timescale: number = 1.0; // loading - private _loader: ILoader; + private _loader: CanLoad; private _isLoading: boolean = false; private _isInitialized: boolean = false; @@ -444,7 +444,7 @@ export class Engine extends Class implements ICanInitialize, ICanUpdate, ICanDra /** * Default [[IEngineOptions]] */ - private static _DefaultEngineOptions: IEngineOptions = { + private static _DefaultEngineOptions: EngineOptions = { width: 0, height: 0, enableCanvasTransparency: true, @@ -482,7 +482,7 @@ export class Engine extends Class implements ICanInitialize, ICanUpdate, ICanDra * }); * ``` */ - constructor(options?: IEngineOptions) { + constructor(options?: EngineOptions) { super(); options = Util.extend({}, Engine._DefaultEngineOptions, options); @@ -941,7 +941,7 @@ O|===|* >________________>\n\ /** * Initializes the internal canvas, rendering context, displaymode, and native event listeners */ - private _initialize(options?: IEngineOptions) { + private _initialize(options?: EngineOptions) { if (options.displayMode) { this.displayMode = options.displayMode; } @@ -1015,7 +1015,7 @@ O|===|* >________________>\n\ // Override me } - private _intializeDisplayModePosition(options: IEngineOptions) { + private _intializeDisplayModePosition(options: EngineOptions) { if (!options.position) { throw new Error('DisplayMode of Position was selected but no position option was given'); } else { @@ -1285,7 +1285,7 @@ O|===|* >________________>\n\ * @param loader Optional [[ILoader]] to use to load resources. The default loader is [[Loader]], override to provide your own * custom loader. */ - public start(loader?: ILoader): Promise { + public start(loader?: CanLoad): Promise { if (!this._compatible) { var promise = new Promise(); return promise.reject('Excalibur is incompatible with your browser'); @@ -1404,7 +1404,7 @@ O|===|* >________________>\n\ * will appear. * @param loader Some [[ILoadable]] such as a [[Loader]] collection, [[Sound]], or [[Texture]]. */ - public load(loader: ILoadable): Promise { + public load(loader: Loadable): Promise { var complete = new Promise(); this._isLoading = true; diff --git a/src/engine/EventDispatcher.ts b/src/engine/EventDispatcher.ts index 60d7cfe8..f0bddc34 100644 --- a/src/engine/EventDispatcher.ts +++ b/src/engine/EventDispatcher.ts @@ -1,5 +1,5 @@ import { GameEvent, SubscribeEvent, UnsubscribeEvent } from './Events'; -import { IEvented } from './Interfaces/IEvented'; +import { Eventable } from './Interfaces/Evented'; /** * Excalibur's internal event dispatcher implementation. @@ -10,7 +10,7 @@ import { IEvented } from './Interfaces/IEvented'; * * [[include:Events.md]] */ -export class EventDispatcher implements IEvented { +export class EventDispatcher implements Eventable { private _handlers: { [key: string]: { (event?: GameEvent): void }[] } = {}; private _wiredEventDispatchers: EventDispatcher[] = []; diff --git a/src/engine/Group.ts b/src/engine/Group.ts index eb16c958..a3488ce3 100644 --- a/src/engine/Group.ts +++ b/src/engine/Group.ts @@ -5,8 +5,8 @@ import { Scene } from './Scene'; import { ActionContext } from './Actions/ActionContext'; import { Actor } from './Actor'; import { Logger } from './Util/Log'; -import { IEvented } from './Interfaces/IEvented'; -import { IActionable } from './Actions/IActionable'; +import { Eventable } from './Interfaces/Evented'; +import { Actionable } from './Actions/Actionable'; import { Class } from './Class'; /** @@ -15,7 +15,7 @@ import { Class } from './Class'; * * [[include:Groups.md]] */ -export class Group extends Class implements IActionable, IEvented { +export class Group extends Class implements Actionable, Eventable { private _logger: Logger = Logger.getInstance(); private _members: Actor[] = []; diff --git a/src/engine/Input/IEngineInput.ts b/src/engine/Input/EngineInput.ts similarity index 85% rename from src/engine/Input/IEngineInput.ts rename to src/engine/Input/EngineInput.ts index 93e8253c..c58dee65 100644 --- a/src/engine/Input/IEngineInput.ts +++ b/src/engine/Input/EngineInput.ts @@ -2,7 +2,7 @@ import { Gamepads } from './Gamepad'; import { Pointers } from './Pointer'; -export interface IEngineInput { +export interface EngineInput { keyboard: Keyboard; pointers: Pointers; gamepads: Gamepads; diff --git a/src/engine/Input/Gamepad.ts b/src/engine/Input/Gamepad.ts index d39fb787..2e7184bc 100644 --- a/src/engine/Input/Gamepad.ts +++ b/src/engine/Input/Gamepad.ts @@ -28,8 +28,8 @@ export class Gamepads extends Class { private _oldPads: Gamepad[] = []; private _pads: Gamepad[] = []; private _initSuccess: boolean = false; - private _navigator: INavigatorGamepads = navigator; - private _minimumConfiguration: IGamepadConfiguration = null; + private _navigator: NavigatorGamepads = navigator; + private _minimumConfiguration: GamepadConfiguration = null; constructor() { super(); @@ -57,7 +57,7 @@ export class Gamepads extends Class { * all other controllers with more axis or buttons are valid as well. If no minimum * configuration is set all pads are valid. */ - public setMinimumGamepadConfiguration(config: IGamepadConfiguration): void { + public setMinimumGamepadConfiguration(config: GamepadConfiguration): void { this._enableAndUpdate(); // if config is used, implicitly enable this._minimumConfiguration = config; } @@ -75,7 +75,7 @@ export class Gamepads extends Class { /** * Checks a navigator gamepad against the minimum configuration if present. */ - private _isGamepadValid(pad: INavigatorGamepad): boolean { + private _isGamepadValid(pad: NavigatorGamepad): boolean { if (!this._minimumConfiguration) { return true; } @@ -219,7 +219,7 @@ export class Gamepads extends Class { return this._pads.filter((p) => p.connected).length; } - private _clonePads(pads: INavigatorGamepad[]): Gamepad[] { + private _clonePads(pads: NavigatorGamepad[]): Gamepad[] { var arr = []; for (var i = 0, len = pads.length; i < len; i++) { arr.push(this._clonePad(pads[i])); @@ -230,7 +230,7 @@ export class Gamepads extends Class { /** * Fastest way to clone a known object is to do it yourself */ - private _clonePad(pad: INavigatorGamepad): Gamepad { + private _clonePad(pad: NavigatorGamepad): Gamepad { var i, len; var clonedPad = new Gamepad(); @@ -257,7 +257,7 @@ export class Gamepads extends Class { */ export class Gamepad extends Class { public connected = false; - public navigatorGamepad: INavigatorGamepad; + public navigatorGamepad: NavigatorGamepad; private _buttons: number[] = new Array(16); private _axes: number[] = new Array(4); @@ -407,16 +407,16 @@ export enum Axes { /** * @internal */ -interface INavigatorGamepads { - getGamepads(): INavigatorGamepad[]; +export interface NavigatorGamepads { + getGamepads(): NavigatorGamepad[]; } /** * @internal */ -export interface INavigatorGamepad { +export interface NavigatorGamepad { axes: number[]; - buttons: INavigatorGamepadButton[]; + buttons: NavigatorGamepadButton[]; connected: boolean; id: string; index: number; @@ -427,7 +427,7 @@ export interface INavigatorGamepad { /** * @internal */ -export interface INavigatorGamepadButton { +export interface NavigatorGamepadButton { pressed: boolean; value: number; } @@ -435,14 +435,14 @@ export interface INavigatorGamepadButton { /** * @internal */ -export interface INavigatorGamepadEvent { - gamepad: INavigatorGamepad; +export interface NavigatorGamepadEvent { + gamepad: NavigatorGamepad; } /** * @internal */ -export interface IGamepadConfiguration { +export interface GamepadConfiguration { axis: number; buttons: number; } diff --git a/src/engine/Input/Index.ts b/src/engine/Input/Index.ts index 3418db16..25d5c140 100644 --- a/src/engine/Input/Index.ts +++ b/src/engine/Input/Index.ts @@ -10,4 +10,4 @@ export * from './Gamepad'; export * from './Pointer'; export * from './Keyboard'; -export * from './IEngineInput'; +export * from './EngineInput'; diff --git a/src/engine/Input/Pointer.ts b/src/engine/Input/Pointer.ts index bd809dda..9d4aea01 100644 --- a/src/engine/Input/Pointer.ts +++ b/src/engine/Input/Pointer.ts @@ -7,7 +7,7 @@ import * as Actors from '../Util/Actors'; import * as Util from '../Util/Util'; import * as Events from '../Events'; -export interface IActorsUnderPointer { +export interface ActorsUnderPointer { [ActorId: number]: Actor; length: number; } @@ -589,7 +589,7 @@ export class Pointers extends Class { } private _handleTouchEvent(eventName: string, eventArr: PointerEvent[]) { - return (e: ITouchEvent) => { + return (e: TouchEvent) => { e.preventDefault(); for (var i = 0, len = e.changedTouches.length; i < len; i++) { const index = this._pointers.length > 1 ? this._getPointerIndex(e.changedTouches[i].identifier) : 0; @@ -726,7 +726,7 @@ export class Pointers extends Class { export class Pointer extends Class { private _isDown: boolean = false; private _wasDown: boolean = false; - private _actorsUnderPointer: IActorsUnderPointer = { length: 0 }; + private _actorsUnderPointer: ActorsUnderPointer = { length: 0 }; /** * Whether the Pointer is currently dragging. @@ -870,19 +870,19 @@ export class Pointer extends Class { } } -interface ITouchEvent extends Event { +interface TouchEvent extends Event { altKey: boolean; - changedTouches: ITouch[]; + changedTouches: Touch[]; ctrlKey: boolean; metaKey: boolean; shiftKey: boolean; - targetTouches: ITouch[]; - touches: ITouch[]; + targetTouches: Touch[]; + touches: Touch[]; type: string; target: Element; } -interface ITouch { +interface Touch { identifier: number; screenX: number; screenY: number; diff --git a/src/engine/Interfaces/IAudio.ts b/src/engine/Interfaces/Audio.ts similarity index 87% rename from src/engine/Interfaces/IAudio.ts rename to src/engine/Interfaces/Audio.ts index b2abecd9..e2311783 100644 --- a/src/engine/Interfaces/IAudio.ts +++ b/src/engine/Interfaces/Audio.ts @@ -1,9 +1,9 @@ -import { Promise } from './../Promises'; +import { Promise } from '../Promises'; /** * Represents an audio control implementation */ -export interface IAudio { +export interface Audio { /** * Whether the audio should loop (repeat forever) */ diff --git a/src/engine/Interfaces/IAudioImplementation.ts b/src/engine/Interfaces/AudioImplementation.ts similarity index 72% rename from src/engine/Interfaces/IAudioImplementation.ts rename to src/engine/Interfaces/AudioImplementation.ts index 32670878..93e2ec2c 100644 --- a/src/engine/Interfaces/IAudioImplementation.ts +++ b/src/engine/Interfaces/AudioImplementation.ts @@ -1,14 +1,14 @@ -import { Promise } from './../Promises'; -import { IAudio } from './IAudio'; +import { Promise } from '../Promises'; +import { Audio } from './Audio'; export type ExResponseType = '' | 'arraybuffer' | 'blob' | 'document' | 'json' | 'text'; -export interface IExResponseTypesLookup { +export interface ExResponseTypesLookup { [name: string]: ExResponseType; } export class ExResponse { - public static type: IExResponseTypesLookup = { + public static type: ExResponseTypesLookup = { any: '', blob: 'blob', json: 'json', @@ -21,7 +21,7 @@ export class ExResponse { /** * Represents an audio implementation like [[AudioTagInstance]] or [[WebAudioInstance]] */ -export interface IAudioImplementation { +export interface AudioImplementation { /** * XHR response type */ @@ -35,5 +35,5 @@ export interface IAudioImplementation { /** * Factory method that returns an instance of a played audio track */ - createInstance(data: string | AudioBuffer): IAudio; + createInstance(data: string | AudioBuffer): Audio; } diff --git a/src/engine/Interfaces/IDrawable.ts b/src/engine/Interfaces/Drawable.ts similarity index 90% rename from src/engine/Interfaces/IDrawable.ts rename to src/engine/Interfaces/Drawable.ts index 29290158..2f6b0285 100644 --- a/src/engine/Interfaces/IDrawable.ts +++ b/src/engine/Interfaces/Drawable.ts @@ -1,10 +1,10 @@ -import { Vector } from './../Algebra'; -import { ISpriteEffect } from '../Drawing/SpriteEffects'; +import { Vector } from '../Algebra'; +import { SpriteEffect } from '../Drawing/SpriteEffects'; /** * Interface for implementing anything in Excalibur that can be drawn to the screen. */ -export interface IDrawable { +export interface Drawable { /** * Indicates whether the drawing is to be flipped vertically */ @@ -35,13 +35,13 @@ export interface IDrawable { * Adds a new [[ISpriteEffect]] to this drawing. * @param effect Effect to add to the this drawing */ - addEffect(effect: ISpriteEffect): void; + addEffect(effect: SpriteEffect): void; /** * Removes an effect [[ISpriteEffect]] from this drawing. * @param effect Effect to remove from this drawing */ - removeEffect(effect: ISpriteEffect): void; + removeEffect(effect: SpriteEffect): void; /** * Removes an effect by index from this drawing. diff --git a/src/engine/Interfaces/IEvented.ts b/src/engine/Interfaces/Evented.ts similarity index 97% rename from src/engine/Interfaces/IEvented.ts rename to src/engine/Interfaces/Evented.ts index 492c662d..373a23d5 100644 --- a/src/engine/Interfaces/IEvented.ts +++ b/src/engine/Interfaces/Evented.ts @@ -1,6 +1,6 @@ import { GameEvent } from '../Events'; -export interface IEvented { +export interface Eventable { /** * Emits an event for target * @param eventName The name of the event to publish diff --git a/src/engine/Interfaces/Index.ts b/src/engine/Interfaces/Index.ts index 54635da5..362901f8 100644 --- a/src/engine/Interfaces/Index.ts +++ b/src/engine/Interfaces/Index.ts @@ -1,9 +1,9 @@ -export * from './IActorTrait'; -export * from './IAudio'; -export * from './IAudioImplementation'; -export * from './IDrawable'; -export * from './IEvented'; -export * from './ILoadable'; -export * from './ILoader'; +export * from './Trait'; +export * from './Audio'; +export * from './AudioImplementation'; +export * from './Drawable'; +export * from './Evented'; +export * from './Loadable'; +export * from './Loader'; export * from './LifecycleEvents'; -export * from './IPointerEvents'; +export * from './PointerEvents'; diff --git a/src/engine/Interfaces/LifecycleEvents.ts b/src/engine/Interfaces/LifecycleEvents.ts index 7dcdbaf6..8e11d640 100644 --- a/src/engine/Interfaces/LifecycleEvents.ts +++ b/src/engine/Interfaces/LifecycleEvents.ts @@ -2,7 +2,7 @@ import { Engine } from './../Engine'; import * as Events from './../Events'; import { Scene } from '../Scene'; -export interface ICanInitialize { +export interface CanInitialize { /** * Overridable implementation */ @@ -16,7 +16,7 @@ export interface ICanInitialize { off(eventName: Events.initialize, handler?: (event?: Events.InitializeEvent) => void): void; } -export interface ICanActivate { +export interface CanActivate { /** * Overridable implementation */ @@ -30,7 +30,7 @@ export interface ICanActivate { off(eventName: Events.activate, handler?: (event?: Events.ActivateEvent) => void): void; } -export interface ICanDeactivate { +export interface CanDeactivate { /** * Overridable implementation */ @@ -44,7 +44,7 @@ export interface ICanDeactivate { off(eventName: Events.deactivate, handler?: (event?: Events.DeactivateEvent) => void): void; } -export interface ICanUpdate { +export interface CanUpdate { /** * Overridable implementation */ @@ -70,7 +70,7 @@ export interface ICanUpdate { off(eventName: Events.postupdate, handler?: (event?: Events.PostUpdateEvent) => void): void; } -export interface ICanDraw { +export interface CanDraw { /** * Overridable implementation */ @@ -96,7 +96,7 @@ export interface ICanDraw { off(eventName: Events.postdraw, handler?: (event?: Events.PostDrawEvent) => void): void; } -export interface ICanBeKilled { +export interface CanBeKilled { /** * Overridable implementation */ diff --git a/src/engine/Interfaces/ILoadable.ts b/src/engine/Interfaces/Loadable.ts similarity index 97% rename from src/engine/Interfaces/ILoadable.ts rename to src/engine/Interfaces/Loadable.ts index adcf40f8..f0b0cc06 100644 --- a/src/engine/Interfaces/ILoadable.ts +++ b/src/engine/Interfaces/Loadable.ts @@ -7,7 +7,7 @@ import { Engine } from '../Engine'; * * [[include:Loadables.md]] */ -export interface ILoadable { +export interface Loadable { /** * Begins loading the resource and returns a promise to be resolved on completion */ diff --git a/src/engine/Interfaces/ILoader.ts b/src/engine/Interfaces/Loader.ts similarity index 67% rename from src/engine/Interfaces/ILoader.ts rename to src/engine/Interfaces/Loader.ts index e930d525..c6c9f04c 100644 --- a/src/engine/Interfaces/ILoader.ts +++ b/src/engine/Interfaces/Loader.ts @@ -1,7 +1,7 @@ -import { ILoadable } from './ILoadable'; +import { Loadable } from './Loadable'; import { Engine } from '../Engine'; -export interface ILoader extends ILoadable { +export interface CanLoad extends Loadable { suppressPlayButton: boolean; draw(ctx: CanvasRenderingContext2D, delta: number): void; update(engine: Engine, delta: number): void; diff --git a/src/engine/Interfaces/IPointerEvents.ts b/src/engine/Interfaces/PointerEvents.ts similarity index 98% rename from src/engine/Interfaces/IPointerEvents.ts rename to src/engine/Interfaces/PointerEvents.ts index e5be84ac..70c064b7 100644 --- a/src/engine/Interfaces/IPointerEvents.ts +++ b/src/engine/Interfaces/PointerEvents.ts @@ -1,7 +1,7 @@ import * as Events from '../Events'; import { PointerEvent, WheelEvent, PointerDragEvent } from '../Input/Pointer'; -export interface IPointerEvents { +export interface PointerEvents { on(eventName: Events.pointerup, handler: (event?: PointerEvent) => void): void; on(eventName: Events.pointerdown, handler: (event?: PointerEvent) => void): void; on(eventName: Events.pointerenter, handler: (event?: PointerEvent) => void): void; diff --git a/src/engine/Interfaces/IActorTrait.ts b/src/engine/Interfaces/Trait.ts similarity index 86% rename from src/engine/Interfaces/IActorTrait.ts rename to src/engine/Interfaces/Trait.ts index b5258177..781ab9cd 100644 --- a/src/engine/Interfaces/IActorTrait.ts +++ b/src/engine/Interfaces/Trait.ts @@ -4,6 +4,6 @@ import { Engine } from '../Engine'; /** * An interface describing actor update pipeline traits */ -export interface IActorTrait { +export interface Trait { update(actor: Actor, engine: Engine, delta: number): void; } diff --git a/src/engine/Label.ts b/src/engine/Label.ts index 5defc002..11779c68 100644 --- a/src/engine/Label.ts +++ b/src/engine/Label.ts @@ -107,7 +107,7 @@ export enum FontStyle { /** * [[include:Constructors.md]] */ -export interface ILabelArgs extends Partial { +export interface LabelArgs extends Partial { text?: string; bold?: boolean; pos?: Vector; @@ -407,9 +407,9 @@ export class LabelImpl extends Actor { */ export class Label extends Configurable(LabelImpl) { constructor(); - constructor(config?: ILabelArgs); + constructor(config?: LabelArgs); constructor(text?: string, x?: number, y?: number, fontFamily?: string, spriteFont?: SpriteFont); - constructor(textOrConfig?: string | ILabelArgs, x?: number, y?: number, fontFamily?: string, spriteFont?: SpriteFont) { + constructor(textOrConfig?: string | LabelArgs, x?: number, y?: number, fontFamily?: string, spriteFont?: SpriteFont) { super(textOrConfig, x, y, fontFamily, spriteFont); } } diff --git a/src/engine/Loader.ts b/src/engine/Loader.ts index 55ef17ad..cb1932f3 100644 --- a/src/engine/Loader.ts +++ b/src/engine/Loader.ts @@ -3,8 +3,8 @@ import { WebAudio } from './Util/WebAudio'; import { Logger } from './Util/Log'; import { Promise, PromiseState } from './Promises'; import { Engine } from './Engine'; -import { ILoadable } from './Interfaces/ILoadable'; -import { ILoader } from './Interfaces/ILoader'; +import { Loadable } from './Interfaces/Loadable'; +import { CanLoad } from './Interfaces/Loader'; import { Class } from './Class'; import * as DrawUtil from './Util/DrawUtil'; @@ -76,8 +76,8 @@ import loaderCss from './Loader.css'; * engine.start(loader).then(() => {}); * ``` */ -export class Loader extends Class implements ILoader { - private _resourceList: ILoadable[] = []; +export class Loader extends Class implements CanLoad { + private _resourceList: Loadable[] = []; private _index = 0; private _playButtonShown: boolean = false; @@ -148,7 +148,7 @@ export class Loader extends Class implements ILoader { /** * @param loadables Optionally provide the list of resources you want to load at constructor time */ - constructor(loadables?: ILoadable[]) { + constructor(loadables?: Loadable[]) { super(); if (loadables) { @@ -164,7 +164,7 @@ export class Loader extends Class implements ILoader { * Add a resource to the loader to load * @param loadable Resource to add */ - public addResource(loadable: ILoadable) { + public addResource(loadable: Loadable) { var key = this._index++; this._resourceList.push(loadable); this._progressCounts[key] = 0; @@ -176,7 +176,7 @@ export class Loader extends Class implements ILoader { * Add a list of resources to the loader to load * @param loadables The list of resources to load */ - public addResources(loadables: ILoadable[]) { + public addResources(loadables: Loadable[]) { var i = 0, len = loadables.length; @@ -277,7 +277,7 @@ export class Loader extends Class implements ILoader { }; }); - function loadNext(list: ILoadable[], index: number) { + function loadNext(list: Loadable[], index: number) { if (!list[index]) { return; } diff --git a/src/engine/Math/PerlinNoise.ts b/src/engine/Math/PerlinNoise.ts index ea78f673..97022faa 100644 --- a/src/engine/Math/PerlinNoise.ts +++ b/src/engine/Math/PerlinNoise.ts @@ -13,7 +13,7 @@ function _fade(t: number): number { /** * Options for the perlin noise generator */ -export interface IPerlinGeneratorOptions { +export interface PerlinOptions { /** * Random number seed for the Perlin noise generator */ @@ -306,7 +306,7 @@ export class PerlinGenerator { private _p: Uint8Array = new Uint8Array(512); private _random: Random; - private _defaultPerlinOptions: IPerlinGeneratorOptions = { + private _defaultPerlinOptions: PerlinOptions = { octaves: 1, frequency: 1, amplitude: 1, @@ -337,7 +337,7 @@ export class PerlinGenerator { */ public octaves: number; - constructor(options?: IPerlinGeneratorOptions) { + constructor(options?: PerlinOptions) { options = Util.extend({}, this._defaultPerlinOptions, options); this.persistance = options.persistance; diff --git a/src/engine/Particles.ts b/src/engine/Particles.ts index f4025ac2..c164d574 100644 --- a/src/engine/Particles.ts +++ b/src/engine/Particles.ts @@ -60,7 +60,7 @@ export class ParticleImpl { public elapsedMultiplier: number = 0; constructor( - emitterOrConfig: ParticleEmitter | IParticleArgs, + emitterOrConfig: ParticleEmitter | ParticleArgs, life?: number, opacity?: number, beginColor?: Color, @@ -174,7 +174,7 @@ export class ParticleImpl { /** * [[include:Constructors.md]] */ -export interface IParticleArgs extends Partial { +export interface ParticleArgs extends Partial { emitter: ParticleEmitter; position?: Vector; velocity?: Vector; @@ -189,7 +189,7 @@ export interface IParticleArgs extends Partial { * Particle is used in a [[ParticleEmitter]] */ export class Particle extends Configurable(ParticleImpl) { - constructor(config: IParticleArgs); + constructor(config: ParticleArgs); constructor( emitter: ParticleEmitter, life?: number, @@ -203,7 +203,7 @@ export class Particle extends Configurable(ParticleImpl) { endSize?: number ); constructor( - emitterOrConfig: ParticleEmitter | IParticleArgs, + emitterOrConfig: ParticleEmitter | ParticleArgs, life?: number, opacity?: number, beginColor?: Color, @@ -352,7 +352,7 @@ export class ParticleEmitterImpl extends Actor { * @param width The width of the emitter * @param height The height of the emitter */ - constructor(xOrConfig?: number | IParticleEmitterArgs, y?: number, width?: number, height?: number) { + constructor(xOrConfig?: number | ParticleEmitterArgs, y?: number, width?: number, height?: number) { super(typeof xOrConfig === 'number' ? { x: xOrConfig, y: y, width: width, height: height } : xOrConfig); this._particlesToEmit = 0; this.collisionType = CollisionType.PreventCollision; @@ -474,7 +474,7 @@ export class ParticleEmitterImpl extends Actor { /** * [[include:Constructors.md]] */ -export interface IParticleEmitterArgs extends Partial { +export interface ParticleEmitterArgs extends Partial { width?: number; height?: number; isEmitting?: boolean; @@ -511,9 +511,9 @@ export interface IParticleEmitterArgs extends Partial { * [[include:Particles.md]] */ export class ParticleEmitter extends Configurable(ParticleEmitterImpl) { - constructor(config?: IParticleEmitterArgs); - constructor(x?: number | IParticleEmitterArgs, y?: number, width?: number, height?: number); - constructor(xOrConfig?: number | IParticleEmitterArgs, y?: number, width?: number, height?: number) { + constructor(config?: ParticleEmitterArgs); + constructor(x?: number | ParticleEmitterArgs, y?: number, width?: number, height?: number); + constructor(xOrConfig?: number | ParticleEmitterArgs, y?: number, width?: number, height?: number) { super(xOrConfig, y, width, height); } } diff --git a/src/engine/PostProcessing/ColorBlindCorrector.ts b/src/engine/PostProcessing/ColorBlindCorrector.ts index ba124adf..6b75f75a 100644 --- a/src/engine/PostProcessing/ColorBlindCorrector.ts +++ b/src/engine/PostProcessing/ColorBlindCorrector.ts @@ -1,5 +1,5 @@ import { Logger } from './../Util/Log'; -import { IPostProcessor } from './IPostProcessor'; +import { PostProcessor } from './PostProcessor'; import { Engine } from '../Engine'; export enum ColorBlindness { @@ -16,7 +16,7 @@ export enum ColorBlindness { * * [[include:ColorBlind.md]] */ -export class ColorBlindCorrector implements IPostProcessor { +export class ColorBlindCorrector implements PostProcessor { private _vertexShader = 'attribute vec2 a_position;' + 'attribute vec2 a_texCoord;' + diff --git a/src/engine/PostProcessing/Index.ts b/src/engine/PostProcessing/Index.ts index 1b0894ef..a79efd8c 100644 --- a/src/engine/PostProcessing/Index.ts +++ b/src/engine/PostProcessing/Index.ts @@ -1,2 +1,2 @@ export * from './ColorBlindCorrector'; -export * from './IPostProcessor'; +export * from './PostProcessor'; diff --git a/src/engine/PostProcessing/IPostProcessor.ts b/src/engine/PostProcessing/PostProcessor.ts similarity index 86% rename from src/engine/PostProcessing/IPostProcessor.ts rename to src/engine/PostProcessing/PostProcessor.ts index 6d91039f..71e6ad8d 100644 --- a/src/engine/PostProcessing/IPostProcessor.ts +++ b/src/engine/PostProcessing/PostProcessor.ts @@ -3,6 +3,6 @@ * * [[include:PostProcessors.md]] */ -export interface IPostProcessor { +export interface PostProcessor { process(image: ImageData, out: CanvasRenderingContext2D): void; } diff --git a/src/engine/Promises.ts b/src/engine/Promises.ts index c2a4c4f8..b39883fc 100644 --- a/src/engine/Promises.ts +++ b/src/engine/Promises.ts @@ -9,15 +9,15 @@ export enum PromiseState { Pending } -export interface IPromise { - then(successCallback?: (value?: T) => any, rejectCallback?: (value?: T) => any): IPromise; - error(rejectCallback?: (value?: any) => any): IPromise; +export interface PromiseLike { + then(successCallback?: (value?: T) => any, rejectCallback?: (value?: T) => any): PromiseLike; + error(rejectCallback?: (value?: any) => any): PromiseLike; //Cannot define static methods on interfaces //wrap(value?: T): IPromise; - resolve(value?: T): IPromise; - reject(value?: any): IPromise; + resolve(value?: T): PromiseLike; + reject(value?: any): PromiseLike; state(): PromiseState; } @@ -29,7 +29,7 @@ export interface IPromise { * * [[include:Promises.md]] */ -export class Promise implements IPromise { +export class Promise implements PromiseLike { private _state: PromiseState = PromiseState.Pending; private _value: T; private _successCallbacks: { (value?: T): any }[] = []; diff --git a/src/engine/Resources/Resource.ts b/src/engine/Resources/Resource.ts index 68f5248c..8fd4dd46 100644 --- a/src/engine/Resources/Resource.ts +++ b/src/engine/Resources/Resource.ts @@ -1,4 +1,4 @@ -import { ILoadable } from '../Interfaces/ILoadable'; +import { Loadable } from '../Interfaces/Loadable'; import { Class } from '../Class'; import { Engine } from '../Engine'; import { Promise } from '../Promises'; @@ -10,7 +10,7 @@ import { Logger } from '../Util/Log'; * * [[include:Resources.md]] */ -export class Resource extends Class implements ILoadable { +export class Resource extends Class implements Loadable { public data: T = null; public logger: Logger = Logger.getInstance(); public arrayBuffer: ArrayBuffer = null; diff --git a/src/engine/Resources/Sound/AudioInstance.ts b/src/engine/Resources/Sound/AudioInstance.ts index 1044ab9c..52075665 100644 --- a/src/engine/Resources/Sound/AudioInstance.ts +++ b/src/engine/Resources/Sound/AudioInstance.ts @@ -1,4 +1,4 @@ -import { IAudio } from '../../Interfaces/IAudio'; +import { Audio } from '../../Interfaces/Audio'; import { Promise } from '../../Promises'; import * as Util from '../../Util/Util'; import { AudioContextFactory } from './AudioContext'; @@ -25,7 +25,7 @@ export class AudioInstanceFactory { * Internal class representing base AudioInstance implementation */ /* istanbul ignore next */ -export class AudioInstance implements IAudio { +export class AudioInstance implements Audio { public set loop(value: boolean) { this._loop = value; diff --git a/src/engine/Resources/Sound/Sound.ts b/src/engine/Resources/Sound/Sound.ts index 540e7df5..498db315 100644 --- a/src/engine/Resources/Sound/Sound.ts +++ b/src/engine/Resources/Sound/Sound.ts @@ -1,5 +1,5 @@ -import { ExResponse } from '../../Interfaces/IAudioImplementation'; -import { IAudio } from '../../Interfaces/IAudio'; +import { ExResponse } from '../../Interfaces/AudioImplementation'; +import { Audio } from '../../Interfaces/Audio'; import { Engine } from '../../Engine'; import { Resource } from '../Resource'; import { AudioInstance, AudioInstanceFactory } from './AudioInstance'; @@ -15,7 +15,7 @@ import { canPlayFile } from '../../Util/Sound'; * * [[include:Sounds.md]] */ -export class Sound extends Resource implements IAudio { +export class Sound extends Resource implements Audio { /** * Indicates whether the clip should loop when complete * @param value Set the looping flag diff --git a/src/engine/Scene.ts b/src/engine/Scene.ts index 4236a6fd..112882be 100644 --- a/src/engine/Scene.ts +++ b/src/engine/Scene.ts @@ -15,7 +15,7 @@ import { import { Logger } from './Util/Log'; import { Timer } from './Timer'; import { DynamicTreeCollisionBroadphase } from './Collision/DynamicTreeCollisionBroadphase'; -import { ICollisionBroadphase } from './Collision/ICollisionResolver'; +import { CollisionBroadphase } from './Collision/CollisionResolver'; import { SortedList } from './Util/SortedList'; import { Engine } from './Engine'; import { Group } from './Group'; @@ -23,7 +23,7 @@ import { TileMap } from './TileMap'; import { Camera } from './Camera'; import { Actor } from './Actor'; import { Class } from './Class'; -import { ICanInitialize, ICanActivate, ICanDeactivate, ICanUpdate, ICanDraw } from './Interfaces/LifecycleEvents'; +import { CanInitialize, CanActivate, CanDeactivate, CanUpdate, CanDraw } from './Interfaces/LifecycleEvents'; import * as Util from './Util/Util'; import * as Events from './Events'; import * as ActorUtils from './Util/Actors'; @@ -37,7 +37,7 @@ import { Trigger } from './Trigger'; * * [[include:Scenes.md]] */ -export class Scene extends Class implements ICanInitialize, ICanActivate, ICanDeactivate, ICanUpdate, ICanDraw { +export class Scene extends Class implements CanInitialize, CanActivate, CanDeactivate, CanUpdate, CanDraw { /** * Gets or sets the current camera for the scene */ @@ -77,7 +77,7 @@ export class Scene extends Class implements ICanInitialize, ICanActivate, ICanDe private _sortedDrawingTree: SortedList = new SortedList(Actor.prototype.getZIndex); - private _broadphase: ICollisionBroadphase = new DynamicTreeCollisionBroadphase(); + private _broadphase: CollisionBroadphase = new DynamicTreeCollisionBroadphase(); private _killQueue: Actor[] = []; private _triggerKillQueue: Trigger[] = []; diff --git a/src/engine/TileMap.ts b/src/engine/TileMap.ts index b04ebb6d..baeb8cc1 100644 --- a/src/engine/TileMap.ts +++ b/src/engine/TileMap.ts @@ -46,7 +46,7 @@ export class TileMapImpl extends Class { * @param rows The number of rows in the TileMap (should not be changed once set) * @param cols The number of cols in the TileMap (should not be changed once set) */ - constructor(xOrConfig: number | ITileMapArgs, y: number, cellWidth: number, cellHeight: number, rows: number, cols: number) { + constructor(xOrConfig: number | TileMapArgs, y: number, cellWidth: number, cellHeight: number, rows: number, cols: number) { super(); if (xOrConfig && typeof xOrConfig === 'object') { var config = xOrConfig; @@ -255,7 +255,7 @@ export class TileMapImpl extends Class { /** * [[include:Constructors.md]] */ -export interface ITileMapArgs extends Partial { +export interface TileMapArgs extends Partial { x: number; y: number; cellWidth: number; @@ -271,9 +271,9 @@ export interface ITileMapArgs extends Partial { * [[include:TileMaps.md]] */ export class TileMap extends Configurable(TileMapImpl) { - constructor(config: ITileMapArgs); + constructor(config: TileMapArgs); constructor(x: number, y: number, cellWidth: number, cellHeight: number, rows: number, cols: number); - constructor(xOrConfig: number | ITileMapArgs, y?: number, cellWidth?: number, cellHeight?: number, rows?: number, cols?: number) { + constructor(xOrConfig: number | TileMapArgs, y?: number, cellWidth?: number, cellHeight?: number, rows?: number, cols?: number) { super(xOrConfig, y, cellWidth, cellHeight, rows, cols); } } @@ -312,7 +312,7 @@ export class CellImpl { * @param sprites The list of tile sprites to use to draw in this cell (in order) */ constructor( - xOrConfig: number | ICellArgs, + xOrConfig: number | CellArgs, y: number, width: number, height: number, @@ -378,7 +378,7 @@ export class CellImpl { /** * [[include:Constructors.md]] */ -export interface ICellArgs extends Partial { +export interface CellArgs extends Partial { x: number; y: number; width: number; @@ -399,10 +399,10 @@ export interface ICellArgs extends Partial { * use transparency to create layers this way. */ export class Cell extends Configurable(CellImpl) { - constructor(config: ICellArgs); + constructor(config: CellArgs); constructor(x: number, y: number, width: number, height: number, index: number, solid?: boolean, sprites?: TileSprite[]); constructor( - xOrConfig: number | ICellArgs, + xOrConfig: number | CellArgs, y?: number, width?: number, height?: number, diff --git a/src/engine/Traits/CapturePointer.ts b/src/engine/Traits/CapturePointer.ts index 6090efbb..9c98f53b 100644 --- a/src/engine/Traits/CapturePointer.ts +++ b/src/engine/Traits/CapturePointer.ts @@ -1,8 +1,8 @@ -import { IActorTrait } from '../Interfaces/IActorTrait'; +import { Trait } from '../Interfaces/Trait'; import { Actor } from '../Actor'; import { Engine } from '../Engine'; -export interface ICapturePointerConfig { +export interface CapturePointerConfig { /** * Capture PointerMove events (may be expensive!) */ @@ -17,7 +17,7 @@ export interface ICapturePointerConfig { /** * Revises pointer events path accordingly to the actor */ -export class CapturePointer implements IActorTrait { +export class CapturePointer implements Trait { public update(actor: Actor, engine: Engine) { if (!actor.enableCapturePointer) { return; diff --git a/src/engine/Traits/EulerMovement.ts b/src/engine/Traits/EulerMovement.ts index 5db2ba26..1818e467 100644 --- a/src/engine/Traits/EulerMovement.ts +++ b/src/engine/Traits/EulerMovement.ts @@ -1,9 +1,9 @@ import { Physics } from './../Physics'; -import { IActorTrait } from '../Interfaces/IActorTrait'; +import { Trait } from '../Interfaces/Trait'; import { Actor, CollisionType } from '../Actor'; import { Engine } from '../Engine'; -export class EulerMovement implements IActorTrait { +export class EulerMovement implements Trait { public update(actor: Actor, _engine: Engine, delta: number) { // Update placements based on linear algebra var seconds = delta / 1000; diff --git a/src/engine/Traits/OffscreenCulling.ts b/src/engine/Traits/OffscreenCulling.ts index 390cdaee..3948955b 100644 --- a/src/engine/Traits/OffscreenCulling.ts +++ b/src/engine/Traits/OffscreenCulling.ts @@ -1,10 +1,10 @@ import { CullingBox } from './../Util/CullingBox'; -import { IActorTrait } from '../Interfaces/IActorTrait'; +import { Trait } from '../Interfaces/Trait'; import { Actor } from '../Actor'; import { Engine } from '../Engine'; import { ExitViewPortEvent, EnterViewPortEvent } from '../Events'; -export class OffscreenCulling implements IActorTrait { +export class OffscreenCulling implements Trait { public cullingBox: CullingBox = new CullingBox(); public update(actor: Actor, engine: Engine) { diff --git a/src/engine/Traits/TileMapCollisionDetection.ts b/src/engine/Traits/TileMapCollisionDetection.ts index 3daad273..f0666df0 100644 --- a/src/engine/Traits/TileMapCollisionDetection.ts +++ b/src/engine/Traits/TileMapCollisionDetection.ts @@ -1,11 +1,11 @@ -import { IActorTrait } from '../Interfaces/IActorTrait'; +import { Trait } from '../Interfaces/Trait'; import { Actor, CollisionType } from '../Actor'; import { Engine } from '../Engine'; import { Vector } from '../Algebra'; import { Side } from '../Collision/Side'; import { PreCollisionEvent, PostCollisionEvent } from '../Events'; -export class TileMapCollisionDetection implements IActorTrait { +export class TileMapCollisionDetection implements Trait { public update(actor: Actor, engine: Engine) { var eventDispatcher = actor.eventDispatcher; if (actor.collisionType !== CollisionType.PreventCollision && engine.currentScene && engine.currentScene.tileMaps) { diff --git a/src/engine/Trigger.ts b/src/engine/Trigger.ts index 24d53aed..9ef43a92 100644 --- a/src/engine/Trigger.ts +++ b/src/engine/Trigger.ts @@ -10,7 +10,7 @@ import * as Util from './Util/Util'; /** * ITriggerOptions */ -export interface ITriggerOptions { +export interface TriggerOptions { // position of the trigger pos: Vector; // width of the trigger @@ -29,7 +29,7 @@ export interface ITriggerOptions { repeat: number; } -let triggerDefaults: Partial = { +let triggerDefaults: Partial = { pos: Vector.Zero, width: 10, height: 10, @@ -70,7 +70,7 @@ export class Trigger extends Actor { * * @param opts Trigger options */ - constructor(opts: Partial) { + constructor(opts: Partial) { super(opts.pos.x, opts.pos.y, opts.width, opts.height); opts = Util.extend({}, triggerDefaults, opts); diff --git a/src/engine/UIActor.ts b/src/engine/UIActor.ts index cc63a4cc..28e309c9 100644 --- a/src/engine/UIActor.ts +++ b/src/engine/UIActor.ts @@ -1,6 +1,6 @@ import { Vector } from './Algebra'; import { Engine } from './Engine'; -import { Actor, IActorArgs, CollisionType } from './Actor'; +import { Actor, ActorArgs, CollisionType } from './Actor'; import * as Traits from './Traits/Index'; /** @@ -12,18 +12,18 @@ export class UIActor extends Actor { constructor(); constructor(xOrConfig?: number, y?: number, width?: number, height?: number); - constructor(config?: IActorArgs); + constructor(config?: ActorArgs); /** * @param x The starting x coordinate of the actor * @param y The starting y coordinate of the actor * @param width The starting width of the actor * @param height The starting height of the actor */ - constructor(xOrConfig?: number | IActorArgs, y?: number, width?: number, height?: number) { + constructor(xOrConfig?: number | ActorArgs, y?: number, width?: number, height?: number) { if (typeof xOrConfig !== 'object') { super(xOrConfig, y, width, height); } else { - super(xOrConfig); + super(xOrConfig); } this.traits = []; this.traits.push(new Traits.CapturePointer()); diff --git a/src/engine/Util/Decorators.ts b/src/engine/Util/Decorators.ts index 0527b131..d70bb2fc 100644 --- a/src/engine/Util/Decorators.ts +++ b/src/engine/Util/Decorators.ts @@ -4,7 +4,7 @@ import * as Util from './Util'; /** * Obsolete decorator options */ -export interface IObsoleteOptions { +export interface ObsoleteOptions { // Optionally specify a custom message message?: string; // Optionally indicate that an alternate method to the obsolete one exists @@ -15,7 +15,7 @@ export interface IObsoleteOptions { * Obsolete decorator for marking Excalibur methods obsolete, you can optionally specify a custom message and/or alternate replacement * method do the deprecated one. Inspired by https://github.com/jayphelps/core-decorators.js */ -export function obsolete(options?: IObsoleteOptions): any { +export function obsolete(options?: ObsoleteOptions): any { options = Util.extend({}, { message: 'This feature will be removed in future versions of Excalibur.', alternateMethod: null }, options); return function(target: any, property: string, descriptor: PropertyDescriptor): any { diff --git a/src/engine/Util/Detector.ts b/src/engine/Util/Detector.ts index af1ed3da..58066ab0 100644 --- a/src/engine/Util/Detector.ts +++ b/src/engine/Util/Detector.ts @@ -13,7 +13,7 @@ const REPORTED_FEATURES: { [key: string]: string } = { /** * Interface for detected browser features matrix */ -export interface IDetectedFeatures { +export interface DetectedFeatures { readonly canvas: boolean; readonly arraybuffer: boolean; readonly dataurl: boolean; @@ -24,7 +24,7 @@ export interface IDetectedFeatures { readonly gamepadapi: boolean; } -interface ICriticalTests { +interface CriticalTests { canvasSupport(): boolean; arrayBufferSupport(): boolean; dataUrlSupport(): boolean; @@ -32,7 +32,7 @@ interface ICriticalTests { rgbaSupport(): boolean; } -interface IWarningTests { +interface WarningTests { webAudioSupport(): boolean; webglSupport(): boolean; } @@ -41,7 +41,7 @@ interface IWarningTests { * Excalibur internal feature detection helper class */ export class Detector { - private _features: IDetectedFeatures = null; + private _features: DetectedFeatures = null; public failedTests: string[] = []; @@ -54,7 +54,7 @@ export class Detector { * treats the features as a singleton and will only calculate feature * support if it has not previously been done. */ - public getBrowserFeatures(): IDetectedFeatures { + public getBrowserFeatures(): DetectedFeatures { if (this._features === null) { this._features = this._loadBrowserFeatures(); } @@ -92,7 +92,7 @@ export class Detector { * Executes several IIFE's to get a constant reference to supported * features within the current execution context. */ - private _loadBrowserFeatures(): IDetectedFeatures { + private _loadBrowserFeatures(): DetectedFeatures { return { // IIFE to check canvas support canvas: (() => { @@ -137,7 +137,7 @@ export class Detector { } // critical browser features required for ex to run - private _criticalTests: ICriticalTests = { + private _criticalTests: CriticalTests = { // Test canvas/2d context support canvasSupport: function() { var elem = document.createElement('canvas'); @@ -176,7 +176,7 @@ export class Detector { }; // warnings excalibur performance will be degraded - private _warningTest: IWarningTests = { + private _warningTest: WarningTests = { webAudioSupport: function() { return !!( (window).AudioContext || @@ -196,7 +196,7 @@ export class Detector { // Critical test will for ex not to run var failedCritical = false; for (var test in this._criticalTests) { - if (!this._criticalTests[test].call(this)) { + if (!this._criticalTests[test].call(this)) { this.failedTests.push(test); Logger.getInstance().error('Critical browser feature missing, Excalibur requires:', test); failedCritical = true; @@ -208,7 +208,7 @@ export class Detector { // Warning tests do not for ex to return false to compatibility for (var warning in this._warningTest) { - if (!this._warningTest[warning]()) { + if (!this._warningTest[warning]()) { Logger.getInstance().warn('Warning browser feature missing, Excalibur will have reduced performance:', warning); } } diff --git a/src/engine/Util/DrawUtil.ts b/src/engine/Util/DrawUtil.ts index 2023e5c2..984d37af 100644 --- a/src/engine/Util/DrawUtil.ts +++ b/src/engine/Util/DrawUtil.ts @@ -70,7 +70,7 @@ export function vector(ctx: CanvasRenderingContext2D, color: Color, origin: Vect /** * Represents border radius values */ -export interface IBorderRadius { +export interface BorderRadius { /** * Top-left */ @@ -107,20 +107,20 @@ export function roundRect( y: number, width: number, height: number, - radius: number | IBorderRadius = 5, + radius: number | BorderRadius = 5, stroke: Color = Color.White, fill: Color = null ) { - var br: IBorderRadius; + var br: BorderRadius; if (typeof radius === 'number') { br = { tl: radius, tr: radius, br: radius, bl: radius }; } else { - var defaultRadius: IBorderRadius = { tl: 0, tr: 0, br: 0, bl: 0 }; + var defaultRadius: BorderRadius = { tl: 0, tr: 0, br: 0, bl: 0 }; for (var prop in defaultRadius) { if (defaultRadius.hasOwnProperty(prop)) { - let side = prop; + let side = prop; br[side] = radius[side] || defaultRadius[side]; } } diff --git a/src/engine/Util/Log.ts b/src/engine/Util/Log.ts index 502ea4df..c0327eb0 100644 --- a/src/engine/Util/Log.ts +++ b/src/engine/Util/Log.ts @@ -18,7 +18,7 @@ export enum LogLevel { */ export class Logger { private static _instance: Logger = null; - private _appenders: IAppender[] = []; + private _appenders: Appender[] = []; constructor() { if (Logger._instance) { @@ -49,7 +49,7 @@ export class Logger { /** * Adds a new [[IAppender]] to the list of appenders to write to */ - public addAppender(appender: IAppender): void { + public addAppender(appender: Appender): void { this._appenders.push(appender); } @@ -124,7 +124,7 @@ export class Logger { /** * Contract for any log appender (such as console/screen) */ -export interface IAppender { +export interface Appender { /** * Logs a message at the given [[LogLevel]] * @param level Level to log at @@ -136,7 +136,7 @@ export interface IAppender { /** * Console appender for browsers (i.e. `console.log`) */ -export class ConsoleAppender implements IAppender { +export class ConsoleAppender implements Appender { /** * Logs a message at the given [[LogLevel]] * @param level Level to log at @@ -183,7 +183,7 @@ export class ConsoleAppender implements IAppender { /** * On-screen (canvas) appender */ -export class ScreenAppender implements IAppender { +export class ScreenAppender implements Appender { // @todo Clean this up private _messages: string[] = []; diff --git a/src/engine/index.ts b/src/engine/index.ts index acd0a35d..90b085b0 100644 --- a/src/engine/index.ts +++ b/src/engine/index.ts @@ -8,7 +8,7 @@ export var EX_VERSION = process.env.__EX_VERSION; // that will be exposed as the `ex` global variable. export * from './Engine'; -export { Actor, IActorArgs, CollisionType } from './Actor'; +export { Actor, ActorArgs as IActorArgs, CollisionType } from './Actor'; export * from './Algebra'; export * from './Camera'; export * from './Class'; @@ -20,11 +20,11 @@ export * from './Events'; export * from './Group'; export { Label, FontStyle, FontUnit, TextAlign, BaseAlign } from './Label'; export * from './Loader'; -export { Particle, ParticleEmitter, IParticleArgs, IParticleEmitterArgs, EmitterType } from './Particles'; +export { Particle, ParticleEmitter, ParticleArgs, ParticleEmitterArgs, EmitterType } from './Particles'; export * from './Physics'; export * from './Promises'; export * from './Scene'; -export { TileMap, Cell, ITileMapArgs, ICellArgs, TileSprite } from './TileMap'; +export { TileMap, Cell, TileMapArgs, CellArgs, TileSprite } from './TileMap'; export * from './Timer'; export * from './Trigger'; export * from './UIActor'; @@ -59,3 +59,8 @@ export * from './Util/CullingBox'; export * from './Util/EasingFunctions'; export * from './Util/Log'; export * from './Util/SortedList'; + +// ex.Deprecated +import * as deprecated from './Deprecated'; +export { deprecated as Deprecated }; +export * from './Deprecated'; diff --git a/src/spec/ActorSpec.ts b/src/spec/ActorSpec.ts index 8bf1c57d..bb4ff606 100644 --- a/src/spec/ActorSpec.ts +++ b/src/spec/ActorSpec.ts @@ -1262,7 +1262,6 @@ describe('A game actor', () => { it('only has pointer events happen once per frame', () => { const actor = new ex.Actor(0, 0, 100, 100); const propSpy = spyOn(engine.input.pointers, 'propagate').and.callThrough(); - const eventName = 'pointerup'; let numPointerUps = 0; let pointerEvent: any = mock.pointerEvent('up'); @@ -1291,17 +1290,6 @@ describe('A game actor', () => { let texture = new ex.Texture('base/src/spec/images/SpriteSpec/icon.png', true); texture.load().then(() => { - let sprite = new ex.Sprite({ - image: texture, - x: 0, - y: 0, - width: 62, - height: 64, - scale: new ex.Vector(2, 2) - // rotation: Math.PI / 4, - // anchor: ex.Vector.Half.clone() - }); - var actor = new ex.Actor({ x: engine.halfCanvasWidth, y: engine.halfCanvasHeight, diff --git a/src/spec/CollisionSpec.ts b/src/spec/CollisionSpec.ts index d0b33360..7dfd7e9a 100644 --- a/src/spec/CollisionSpec.ts +++ b/src/spec/CollisionSpec.ts @@ -8,7 +8,7 @@ describe('A Collision', () => { var scene: ex.Scene = null; var engine: ex.Engine = null; var mock = new Mocks.Mocker(); - var loop: Mocks.IGameLoop; + var loop: Mocks.GameLoopLike; beforeEach(() => { engine = TestUtils.engine({ width: 600, height: 400 }); diff --git a/src/spec/EngineSpec.ts b/src/spec/EngineSpec.ts index a7672582..2d9cab71 100644 --- a/src/spec/EngineSpec.ts +++ b/src/spec/EngineSpec.ts @@ -7,7 +7,7 @@ describe('The engine', () => { var engine: ex.Engine; var scene: ex.Scene; var mock = new Mocks.Mocker(); - var loop: Mocks.IGameLoop; + var loop: Mocks.GameLoopLike; var initHiDpiSpy: jasmine.Spy; let reset = () => { diff --git a/src/spec/FrameStatsSpec.ts b/src/spec/FrameStatsSpec.ts index 7e04dffe..51ee7022 100644 --- a/src/spec/FrameStatsSpec.ts +++ b/src/spec/FrameStatsSpec.ts @@ -6,7 +6,7 @@ describe('The engine', () => { var engine: ex.Engine; var scene: ex.Scene; var mock = new Mocks.Mocker(); - var loop: Mocks.IGameLoop; + var loop: Mocks.GameLoopLike; var actor: ex.Actor; var stats: ex.IFrameStats; diff --git a/src/spec/TimescalingSpec.ts b/src/spec/TimescalingSpec.ts index 9c1a1960..9b75f869 100644 --- a/src/spec/TimescalingSpec.ts +++ b/src/spec/TimescalingSpec.ts @@ -5,7 +5,7 @@ describe('The engine', () => { var engine: ex.Engine; var scene: ex.Scene; var mock = new Mocks.Mocker(); - var loop: Mocks.IGameLoop; + var loop: Mocks.GameLoopLike; var actor: ex.Actor; beforeEach(() => { diff --git a/src/spec/TriggerSpec.ts b/src/spec/TriggerSpec.ts index ed5d06e6..e0c6ad7b 100644 --- a/src/spec/TriggerSpec.ts +++ b/src/spec/TriggerSpec.ts @@ -6,7 +6,7 @@ describe('A Trigger', () => { var scene: ex.Scene; var engine: ex.Engine; var mock = new Mocks.Mocker(); - var loop: Mocks.IGameLoop; + var loop: Mocks.GameLoopLike; beforeEach(() => { engine = TestUtils.engine({ width: 600, height: 400 }); diff --git a/src/spec/util/Mocks.ts b/src/spec/util/Mocks.ts index ba055373..feb00a8d 100644 --- a/src/spec/util/Mocks.ts +++ b/src/spec/util/Mocks.ts @@ -16,13 +16,13 @@ export namespace Mocks { this._key = key; } } - export interface ITime { + export interface TimeLike { now(): number; add(value: number): void; sub(value: number): void; } - export interface IGameLoop { + export interface GameLoopLike { advance(duration: number): void; advance(duration: number, fps: number): void; } @@ -222,7 +222,7 @@ export namespace Mocks { * Get a game loop mock that allows you to control the frame advancement * of the main loop. */ - loop(game: ex.Engine): IGameLoop { + loop(game: ex.Engine): GameLoopLike { var time = new Mocker().time(); var loop = ex.Engine.createMainLoop(game, () => 0, time.now); @@ -246,7 +246,7 @@ export namespace Mocks { /** * Get a time mock. Allows you to mock a now function and increment/decrement the value. */ - time(): ITime { + time(): TimeLike { var now = 0; return { diff --git a/tslint/tslint.json b/tslint/tslint.json index 83fdffcf..5879ce2a 100644 --- a/tslint/tslint.json +++ b/tslint/tslint.json @@ -7,7 +7,7 @@ "indent": [true, "spaces"], "label-position": true, "label-undefined": true, - "interface-name": false, + "interface-name": [true, "never-prefix"], "max-line-length": [true, 140], "no-arg": true, "no-console": [true, "debug", "info", "time", "timeEnd", "trace"],