Skip to content

Commit

Permalink
Merge pull request #549 from excaliburjs/release-prep
Browse files Browse the repository at this point in the history
Release prep
  • Loading branch information
eonarheim committed Dec 22, 2015
2 parents 380d128 + 76db33e commit e7d3546
Show file tree
Hide file tree
Showing 19 changed files with 468 additions and 213 deletions.
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "excalibur",
"version": "0.5.1",
"version": "0.6.0",
"homepage": "https://github.com/excaliburjs/Excalibur",
"authors": [
"https://github.com/excaliburjs/Excalibur/graphs/contributors"
],
"description": "Excalibur.js is a simple JavaScript game engine with TypeScript bindings for making 2D games in HTML5 Canvas. Our mission is to make web game development as simple as possible.",
"main": "dist/excalibur-0.5.1.js",
"main": "dist/excalibur-0.6.0.js",
"keywords": [
"excalibur",
"game",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "excalibur",
"description": "Excalibur.js is a simple JavaScript game engine with TypeScript bindings for making 2D games in HTML5 Canvas. Our mission is to make web game development as simple as possible.",
"main": "dist/excalibur-0.5.1.js",
"version": "0.5.1",
"main": "dist/excalibur-0.6.0.js",
"version": "0.6.0",
"author": "https://github.com/excaliburjs/Excalibur/graphs/contributors",
"homepage": "https://github.com/excaliburjs/Excalibur",
"repository": {
Expand Down
30 changes: 25 additions & 5 deletions src/engine/Actions/ActionContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,6 @@ module ex {
* in future versions to support multiple timelines/scripts, better eventing,
* and a more robust API to allow for complex and customized actions.
*
* ## Known Issues
*
* **Rotation actions do not use shortest angle**
* [Issue #282](https://github.com/excaliburjs/Excalibur/issues/282)
*
*/
export class ActionContext {
private _actors: Actor[] = [];
Expand Down Expand Up @@ -152,6 +147,31 @@ module ex {
this._actors.splice(index, 1);
this._queues.splice(index, 1);
}
}

/**
* This method will move an actor to the specified `x` and `y` position over the
* specified duration using a given [[EasingFunctions]] and return back the actor. This
* method is part of the actor 'Action' fluent API allowing action chaining.
* @param x The x location to move the actor to
* @param y The y location to move the actor to
* @param duration The time it should take the actor to move to the new location in milliseconds
* @param easingFcn Use [[EasingFunctions]] or a custom function to use to calculate position
*/
public easeTo(x: number,
y: number,
duration: number,
easingFcn: (currentTime: number,
startValue: number,
endValue: number,
duration: number) => number = ex.EasingFunctions.Linear) {
var i = 0, len = this._queues.length;
for(i; i < len; i++) {
this._queues[i].add(new ex.Internal.Actions.EaseTo(this._actors[i], x, y, duration, easingFcn));
}

return this;

}

/**
Expand Down
112 changes: 71 additions & 41 deletions src/engine/Actor.ts

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/engine/Algebra.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module ex {
/**
* A simple 2D point on a plane
* @obsolete Use [[Vector|vector]]s instead of [[Point|points]]
*/
export class Point {

Expand Down
24 changes: 12 additions & 12 deletions src/engine/Camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ module ex {
*/
export class BaseCamera {
protected _follow: Actor;
protected _focus: Point = new Point(0, 0);
protected _lerp: boolean = false;
public focus: Point = new Point(0, 0);
public lerp: boolean = false;

// camera physical quantities
public x: number = 0;
Expand Down Expand Up @@ -132,12 +132,12 @@ module ex {
* @deprecated
*/
public setFocus(x: number, y: number) {
if (!this._follow && !this._lerp) {
if (!this._follow && !this.lerp) {
this.x = x;
this.y = y;
}

if (this._lerp) {
if (this.lerp) {
this._lerpStart = this.getFocus().clone();
this._lerpEnd = new Point(x, y);
this._currentLerpTime = 0;
Expand Down Expand Up @@ -228,22 +228,22 @@ module ex {
var newCanvasWidth = canvasWidth / this.getZoom();
var newCanvasHeight = canvasHeight / this.getZoom();

if (this._lerp) {
if (this.lerp) {
if (this._currentLerpTime < this._lerpDuration && this._cameraMoving) {

if (this._lerpEnd.x < this._lerpStart.x) {
this._focus.x = this._lerpStart.x - (this._easeInOutCubic(this._currentLerpTime,
this.focus.x = this._lerpStart.x - (this._easeInOutCubic(this._currentLerpTime,
this._lerpEnd.x, this._lerpStart.x, this._lerpDuration) - this._lerpEnd.x);
} else {
this._focus.x = this._easeInOutCubic(this._currentLerpTime,
this.focus.x = this._easeInOutCubic(this._currentLerpTime,
this._lerpStart.x, this._lerpEnd.x, this._lerpDuration);
}

if (this._lerpEnd.y < this._lerpStart.y) {
this._focus.y = this._lerpStart.y - (this._easeInOutCubic(this._currentLerpTime,
this.focus.y = this._lerpStart.y - (this._easeInOutCubic(this._currentLerpTime,
this._lerpEnd.y, this._lerpStart.y, this._lerpDuration) - this._lerpEnd.y);
} else {
this._focus.y = this._easeInOutCubic(this._currentLerpTime,
this.focus.y = this._easeInOutCubic(this._currentLerpTime,
this._lerpStart.y, this._lerpEnd.y, this._lerpDuration);
}
this._currentLerpTime += delta;
Expand Down Expand Up @@ -326,9 +326,9 @@ module ex {

public getFocus() {
if (this._follow) {
return new Point(this._follow.x + this._follow.getWidth() / 2, this._focus.y);
return new Point(this._follow.x + this._follow.getWidth() / 2, this.focus.y);
} else {
return this._focus;
return this.focus;
}
}
}
Expand All @@ -346,7 +346,7 @@ module ex {
if (this._follow) {
return new Point(this._follow.x + this._follow.getWidth() / 2, this._follow.y + this._follow.getHeight() / 2);
} else {
return this._focus;
return this.focus;
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/engine/Class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ module ex {
public off(eventName: string, handler?: (event?: GameEvent) => void) {
this.eventDispatcher.unsubscribe(eventName, handler);
}

/**
* Emits a new event
* @param eventName Name of the event to emit
* @param eventObject Data associated with this event
*/
public emit(eventName: string, eventObject?: GameEvent) {
this.eventDispatcher.emit(eventName, eventObject);
}


/**
* You may wish to extend native Excalibur functionality in vanilla Javascript.
Expand Down
30 changes: 29 additions & 1 deletion src/engine/Drawing/Sprite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,38 @@ module ex {
*
* Excalibur offers many sprite effects such as [[Effects.Colorize]] to let you manipulate
* sprites. Keep in mind, more effects requires more power and can lead to memory or CPU
* constraints and hurt performance.
* constraints and hurt performance. Each effect must be reprocessed every frame for each sprite.
*
* It's still recommended to create an [[Animation]] or build in your effects to the sprites
* for optimal performance.
*
* There are a number of convenience methods available to perform sprite effects. Sprite effects are
* side-effecting.
*
* ```typescript
*
* var playerSprite = new ex.Sprite(txPlayer, 0, 0, 80, 80);
*
* // darken a sprite by a percentage
* playerSprite.darken(.2); // 20%
*
* // lighten a sprite by a percentage
* playerSprite.lighten(.2); // 20%
*
* // saturate a sprite by a percentage
* playerSprite.saturate(.2); // 20%
*
* // implement a custom effect
* class CustomEffect implements ex.EffectsISpriteEffect {
*
* updatePixel(x: number, y: number, imageData: ImageData) {
* // modify ImageData
* }
* }
*
* playerSprite.addEffect(new CustomEffect());
*
* ```
*/
export class Sprite implements IDrawable {
private _texture: Texture;
Expand Down
15 changes: 9 additions & 6 deletions src/engine/Engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ module ex {
* scene. Only one [[Scene]] can be active at once, the engine does not update/draw any other
* scene, which means any actors will not be updated/drawn if they are part of a deactivated scene.
*
* ![Engine Lifecycle](../../assets/images/docs/EngineLifeCycle.png)
*
* **Scene Graph**
*
* ```
Expand All @@ -195,13 +197,13 @@ module ex {
*
* ### Update Loop
*
* The first operation run is the [[Engine.update|update]] loop. [[Actor]] and [[Scene]] both implement
* The first operation run is the [[Engine._update|update]] loop. [[Actor]] and [[Scene]] both implement
* an overridable/extendable `update` method. Use it to perform any logic-based operations
* in your game for a particular class.
*
* ### Draw Loop
*
* The next step is the [[Engine.draw|draw]] loop. A [[Scene]] loops through its child [[Actor|actors]] and
* The next step is the [[Engine._draw|draw]] loop. A [[Scene]] loops through its child [[Actor|actors]] and
* draws each one. You can override the `draw` method on an actor to customize its drawing.
* You should **not** perform any logic in a draw call, it should only relate to drawing.
*
Expand Down Expand Up @@ -969,6 +971,7 @@ module ex {
// suspend updates untill loading is finished
return;
}
this.emit('preupdate', new PreUpdateEvent(this, delta, this));
// process engine level events
this.currentScene.update(this, delta);

Expand All @@ -983,7 +986,8 @@ module ex {
this.input.gamepads.update(delta);

// Publish update event
this.eventDispatcher.emit(EventType[EventType.Update], new UpdateEvent(delta));
this.eventDispatcher.emit('update', new UpdateEvent(delta));
this.emit('postupdate', new PreUpdateEvent(this, delta, this));
}

/**
Expand All @@ -992,7 +996,7 @@ module ex {
*/
private _draw(delta: number) {
var ctx = this.ctx;

this.emit('predraw', new PreDrawEvent(ctx, delta, this));
if (this._isLoading) {
ctx.fillStyle = 'black';
ctx.fillRect(0, 0, this.width, this.height);
Expand Down Expand Up @@ -1033,8 +1037,7 @@ module ex {
this.postProcessors[i].process(this.ctx.getImageData(0, 0, this.width, this.height), this.ctx);
}

//ctx.drawImage(currentImage, 0, 0, this.width, this.height);

this.emit('postdraw', new PreDrawEvent(ctx, delta, this));
}

/**
Expand Down
Loading

0 comments on commit e7d3546

Please sign in to comment.