First push to github
36
Phaser/.gitignore
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
|
||||
#ignore thumbnails created by windows
|
||||
Thumbs.db
|
||||
#Ignore files build by Visual Studio
|
||||
*.obj
|
||||
*.exe
|
||||
*.pdb
|
||||
*.user
|
||||
*.aps
|
||||
*.pch
|
||||
*.vspscc
|
||||
*_i.c
|
||||
*_p.c
|
||||
*.ncb
|
||||
*.suo
|
||||
*.sln
|
||||
*.tlb
|
||||
*.tlh
|
||||
*.bak
|
||||
*.cache
|
||||
*.ilk
|
||||
*.log
|
||||
*.map
|
||||
*.orig
|
||||
*.js
|
||||
!kiwi-lite.js
|
||||
*.map
|
||||
*.config
|
||||
[Bb]in
|
||||
[Dd]ebug*/
|
||||
*.lib
|
||||
*.sbr
|
||||
obj/
|
||||
[Rr]elease*/
|
||||
_ReSharper*/
|
||||
[Tt]est[Rr]esult*
|
128
Phaser/Animations.ts
Normal file
|
@ -0,0 +1,128 @@
|
|||
/// <reference path="Cache.ts" />
|
||||
/// <reference path="Game.ts" />
|
||||
/// <reference path="Sprite.ts" />
|
||||
/// <reference path="system/animation/Animation.ts" />
|
||||
/// <reference path="system/animation/AnimationLoader.ts" />
|
||||
/// <reference path="system/animation/Frame.ts" />
|
||||
/// <reference path="system/animation/FrameData.ts" />
|
||||
|
||||
class Animations {
|
||||
|
||||
constructor(game: Game, parent: Sprite) {
|
||||
|
||||
this._game = game;
|
||||
this._parent = parent;
|
||||
this._anims = {};
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
private _parent: Sprite;
|
||||
|
||||
private _anims: {};
|
||||
private _frameIndex: number;
|
||||
private _frameData: FrameData = null;
|
||||
|
||||
public currentAnim: Animation;
|
||||
public currentFrame: Frame = null;
|
||||
|
||||
public loadFrameData(frameData: FrameData) {
|
||||
|
||||
this._frameData = frameData;
|
||||
|
||||
this.frame = 0;
|
||||
|
||||
}
|
||||
|
||||
public add(name: string, frames:number[] = null, frameRate: number = 60, loop: bool = false) {
|
||||
|
||||
if (this._frameData == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (frames == null)
|
||||
{
|
||||
frames = this._frameData.getFrameIndexes();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.validateFrames(frames) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this._anims[name] = new Animation(this._game, this._parent, this._frameData, name, frames, frameRate, loop);
|
||||
|
||||
this.currentAnim = this._anims[name];
|
||||
|
||||
}
|
||||
|
||||
private validateFrames(frames:number[]):bool {
|
||||
|
||||
var result = true;
|
||||
|
||||
for (var i = 0; i < frames.length; i++)
|
||||
{
|
||||
if (frames[i] > this._frameData.total)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public play(name: string, frameRate?: number = null, loop?: bool) {
|
||||
|
||||
if (this._anims[name])
|
||||
{
|
||||
this.currentAnim = this._anims[name];
|
||||
this.currentAnim.play(frameRate, loop);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public stop(name: string) {
|
||||
|
||||
if (this._anims[name])
|
||||
{
|
||||
this.currentAnim = this._anims[name];
|
||||
this.currentAnim.stop();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public update() {
|
||||
|
||||
if (this.currentAnim && this.currentAnim.update() == true)
|
||||
{
|
||||
this.currentFrame = this.currentAnim.currentFrame;
|
||||
this._parent.bounds.width = this.currentFrame.width;
|
||||
this._parent.bounds.height = this.currentFrame.height;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public get frameTotal(): number {
|
||||
return this._frameData.total;
|
||||
}
|
||||
|
||||
public get frame(): number {
|
||||
return this._frameIndex;
|
||||
}
|
||||
|
||||
public set frame(value: number) {
|
||||
|
||||
this.currentFrame = this._frameData.getFrame(value);
|
||||
|
||||
if (this.currentFrame !== null)
|
||||
{
|
||||
this._parent.bounds.width = this.currentFrame.width;
|
||||
this._parent.bounds.height = this.currentFrame.height;
|
||||
this._frameIndex = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
138
Phaser/Basic.ts
Normal file
|
@ -0,0 +1,138 @@
|
|||
/// <reference path="Game.ts" />
|
||||
|
||||
/**
|
||||
* This is a useful "generic" object.
|
||||
* Both <code>GameObject</code> and <code>Group</code> extend this class,
|
||||
* as do the plugins. Has no size, position or graphical data.
|
||||
*
|
||||
* @author Adam Atomic
|
||||
* @author Richard Davey
|
||||
*/
|
||||
|
||||
class Basic {
|
||||
|
||||
/**
|
||||
* Instantiate the basic object.
|
||||
*/
|
||||
constructor(game:Game) {
|
||||
|
||||
this._game = game;
|
||||
this.ID = -1;
|
||||
this.exists = true;
|
||||
this.active = true;
|
||||
this.visible = true;
|
||||
this.alive = true;
|
||||
this.isGroup = false;
|
||||
this.ignoreDrawDebug = false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The essential reference to the main game object
|
||||
*/
|
||||
public _game: Game;
|
||||
|
||||
/**
|
||||
* Allows you to give this object a name. Useful for debugging, but not actually used internally.
|
||||
*/
|
||||
public name: string = '';
|
||||
|
||||
/**
|
||||
* IDs seem like they could be pretty useful, huh?
|
||||
* They're not actually used for anything yet though.
|
||||
*/
|
||||
public ID: number;
|
||||
|
||||
/**
|
||||
* A boolean to store if this object is a Group or not.
|
||||
* Saves us an expensive typeof check inside of core loops.
|
||||
*/
|
||||
public isGroup: bool;
|
||||
|
||||
/**
|
||||
* Controls whether <code>update()</code> and <code>draw()</code> are automatically called by FlxState/FlxGroup.
|
||||
*/
|
||||
public exists: bool;
|
||||
|
||||
/**
|
||||
* Controls whether <code>update()</code> is automatically called by FlxState/FlxGroup.
|
||||
*/
|
||||
public active: bool;
|
||||
|
||||
/**
|
||||
* Controls whether <code>draw()</code> is automatically called by FlxState/FlxGroup.
|
||||
*/
|
||||
public visible: bool;
|
||||
|
||||
/**
|
||||
* Useful state for many game objects - "dead" (!alive) vs alive.
|
||||
* <code>kill()</code> and <code>revive()</code> both flip this switch (along with exists, but you can override that).
|
||||
*/
|
||||
public alive: bool;
|
||||
|
||||
/**
|
||||
* Setting this to true will prevent the object from appearing
|
||||
* when the visual debug mode in the debugger overlay is toggled on.
|
||||
*/
|
||||
public ignoreDrawDebug: bool;
|
||||
|
||||
/**
|
||||
* Override this to null out iables or manually call
|
||||
* <code>destroy()</code> on class members if necessary.
|
||||
* Don't forget to call <code>super.destroy()</code>!
|
||||
*/
|
||||
public destroy() { }
|
||||
|
||||
/**
|
||||
* Pre-update is called right before <code>update()</code> on each object in the game loop.
|
||||
*/
|
||||
public preUpdate() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this to update your class's position and appearance.
|
||||
* This is where most of your game rules and behavioral code will go.
|
||||
*/
|
||||
public update() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Post-update is called right after <code>update()</code> on each object in the game loop.
|
||||
*/
|
||||
public postUpdate() {
|
||||
}
|
||||
|
||||
public render(camera:Camera, cameraOffsetX: number, cameraOffsetY: number) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Handy for "killing" game objects.
|
||||
* Default behavior is to flag them as nonexistent AND dead.
|
||||
* However, if you want the "corpse" to remain in the game,
|
||||
* like to animate an effect or whatever, you should override this,
|
||||
* setting only alive to false, and leaving exists true.
|
||||
*/
|
||||
public kill() {
|
||||
this.alive = false;
|
||||
this.exists = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handy for bringing game objects "back to life". Just sets alive and exists back to true.
|
||||
* In practice, this is most often called by <code>FlxObject.reset()</code>.
|
||||
*/
|
||||
public revive() {
|
||||
this.alive = true;
|
||||
this.exists = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert object to readable string name. Useful for debugging, save games, etc.
|
||||
*/
|
||||
public toString(): string {
|
||||
//return FlxU.getClassName(this, true);
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
165
Phaser/Cache.ts
Normal file
|
@ -0,0 +1,165 @@
|
|||
/// <reference path="system/animation/AnimationLoader.ts" />
|
||||
|
||||
class Cache {
|
||||
|
||||
constructor(game: Game) {
|
||||
|
||||
this._game = game;
|
||||
|
||||
this._canvases = {};
|
||||
this._images = {};
|
||||
this._sounds = {};
|
||||
this._text = {};
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
|
||||
private _canvases;
|
||||
private _images;
|
||||
private _sounds;
|
||||
private _text;
|
||||
|
||||
public addCanvas(key: string, canvas:HTMLCanvasElement, context:CanvasRenderingContext2D) {
|
||||
|
||||
this._canvases[key] = { canvas: canvas, context: context };
|
||||
|
||||
}
|
||||
|
||||
public addSpriteSheet(key: string, url:string, data, frameWidth:number, frameHeight:number, frameMax:number) {
|
||||
|
||||
this._images[key] = { url: url, data: data, spriteSheet: true, frameWidth: frameWidth, frameHeight: frameHeight };
|
||||
this._images[key].frameData = AnimationLoader.parseSpriteSheet(this._game, key, frameWidth, frameHeight, frameMax);
|
||||
|
||||
}
|
||||
|
||||
public addTextureAtlas(key: string, url:string, data, jsonData) {
|
||||
|
||||
this._images[key] = { url: url, data: data, spriteSheet: true };
|
||||
this._images[key].frameData = AnimationLoader.parseJSONData(this._game, jsonData);
|
||||
|
||||
}
|
||||
|
||||
public addImage(key: string, url:string, data) {
|
||||
|
||||
this._images[key] = { url: url, data: data, spriteSheet: false };
|
||||
|
||||
}
|
||||
|
||||
public addSound(key: string, url:string, data) {
|
||||
|
||||
this._sounds[key] = { url: url, data: data, decoded: false };
|
||||
|
||||
}
|
||||
|
||||
public decodedSound(key: string, data) {
|
||||
|
||||
this._sounds[key].data = data;
|
||||
this._sounds[key].decoded = true;
|
||||
|
||||
}
|
||||
|
||||
public addText(key: string, url:string, data) {
|
||||
|
||||
this._text[key] = { url: url, data: data };
|
||||
|
||||
}
|
||||
|
||||
public getCanvas(key: string) {
|
||||
|
||||
if (this._canvases[key])
|
||||
{
|
||||
return this._canvases[key].canvas;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public getImage(key: string) {
|
||||
|
||||
if (this._images[key])
|
||||
{
|
||||
return this._images[key].data;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public getFrameData(key: string):FrameData {
|
||||
|
||||
if (this._images[key] && this._images[key].spriteSheet == true)
|
||||
{
|
||||
return this._images[key].frameData;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public getSound(key: string) {
|
||||
|
||||
if (this._sounds[key])
|
||||
{
|
||||
return this._sounds[key].data;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public isSoundDecoded(key: string): bool {
|
||||
|
||||
if (this._sounds[key])
|
||||
{
|
||||
return this._sounds[key].decoded;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public isSpriteSheet(key: string): bool {
|
||||
|
||||
if (this._images[key])
|
||||
{
|
||||
return this._images[key].spriteSheet;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public getText(key: string) {
|
||||
|
||||
if (this._text[key])
|
||||
{
|
||||
return this._text[key].data;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public destroy() {
|
||||
|
||||
for (var item in this._canvases)
|
||||
{
|
||||
delete this._canvases[item['key']];
|
||||
}
|
||||
|
||||
for (var item in this._images)
|
||||
{
|
||||
delete this._images[item['key']];
|
||||
}
|
||||
|
||||
for (var item in this._sounds)
|
||||
{
|
||||
delete this._sounds[item['key']];
|
||||
}
|
||||
|
||||
for (var item in this._text)
|
||||
{
|
||||
delete this._text[item['key']];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
79
Phaser/Cameras.ts
Normal file
|
@ -0,0 +1,79 @@
|
|||
/// <reference path="Game.ts" />
|
||||
/// <reference path="GameMath.ts" />
|
||||
/// <reference path="Rectangle.ts" />
|
||||
/// <reference path="Point.ts" />
|
||||
/// <reference path="system/Camera.ts" />
|
||||
|
||||
// TODO: If the Camera is larger than the Stage size then the rotation offset isn't correct
|
||||
// TODO: Texture Repeat doesn't scroll, because it's part of the camera not the world, need to think about this more
|
||||
|
||||
class Cameras {
|
||||
|
||||
constructor(game: Game, x: number, y: number, width: number, height: number) {
|
||||
|
||||
this._game = game;
|
||||
|
||||
this._cameras = [];
|
||||
|
||||
this.current = this.addCamera(x, y, width, height);
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
|
||||
private _cameras: Camera[];
|
||||
|
||||
public current: Camera;
|
||||
|
||||
public getAll(): Camera[] {
|
||||
return this._cameras;
|
||||
}
|
||||
|
||||
public update() {
|
||||
this._cameras.forEach((camera) => camera.update());
|
||||
}
|
||||
|
||||
public render() {
|
||||
this._cameras.forEach((camera) => camera.render());
|
||||
}
|
||||
|
||||
public addCamera(x: number, y: number, width: number, height: number): Camera {
|
||||
|
||||
var newCam: Camera = new Camera(this._game, this._cameras.length, x, y, width, height);
|
||||
|
||||
this._cameras.push(newCam);
|
||||
|
||||
return newCam;
|
||||
|
||||
}
|
||||
|
||||
public removeCamera(id: number): bool {
|
||||
|
||||
if (this._cameras[id])
|
||||
{
|
||||
if (this.current === this._cameras[id])
|
||||
{
|
||||
this.current = null;
|
||||
}
|
||||
|
||||
this._cameras.splice(id, 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public destroy() {
|
||||
|
||||
this._cameras.length = 0;
|
||||
|
||||
this.current = this.addCamera(0, 0, this._game.stage.width, this._game.stage.height);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
453
Phaser/Emitter.ts
Normal file
|
@ -0,0 +1,453 @@
|
|||
/// <reference path="Group.ts" />
|
||||
/// <reference path="Particle.ts" />
|
||||
/// <reference path="Point.ts" />
|
||||
|
||||
/**
|
||||
* <code>Emitter</code> is a lightweight particle emitter.
|
||||
* It can be used for one-time explosions or for
|
||||
* continuous fx like rain and fire. <code>Emitter</code>
|
||||
* is not optimized or anything; all it does is launch
|
||||
* <code>Particle</code> objects out at set intervals
|
||||
* by setting their positions and velocities accordingly.
|
||||
* It is easy to use and relatively efficient,
|
||||
* relying on <code>Group</code>'s RECYCLE POWERS.
|
||||
*
|
||||
* @author Adam Atomic
|
||||
* @author Richard Davey
|
||||
*/
|
||||
class Emitter extends Group {
|
||||
|
||||
/**
|
||||
* Creates a new <code>FlxEmitter</code> object at a specific position.
|
||||
* Does NOT automatically generate or attach particles!
|
||||
*
|
||||
* @param X The X position of the emitter.
|
||||
* @param Y The Y position of the emitter.
|
||||
* @param Size Optional, specifies a maximum capacity for this emitter.
|
||||
*/
|
||||
constructor(game: Game, X: number = 0, Y: number = 0, Size: number = 0) {
|
||||
super(game, Size);
|
||||
this.x = X;
|
||||
this.y = Y;
|
||||
this.width = 0;
|
||||
this.height = 0;
|
||||
this.minParticleSpeed = new Point(-100, -100);
|
||||
this.maxParticleSpeed = new Point(100, 100);
|
||||
this.minRotation = -360;
|
||||
this.maxRotation = 360;
|
||||
this.gravity = 0;
|
||||
this.particleClass = null;
|
||||
this.particleDrag = new Point();
|
||||
this.frequency = 0.1;
|
||||
this.lifespan = 3;
|
||||
this.bounce = 0;
|
||||
this._quantity = 0;
|
||||
this._counter = 0;
|
||||
this._explode = true;
|
||||
this.on = false;
|
||||
this._point = new Point();
|
||||
}
|
||||
|
||||
/**
|
||||
* The X position of the top left corner of the emitter in world space.
|
||||
*/
|
||||
public x: number;
|
||||
|
||||
/**
|
||||
* The Y position of the top left corner of emitter in world space.
|
||||
*/
|
||||
public y: number;
|
||||
|
||||
/**
|
||||
* The width of the emitter. Particles can be randomly generated from anywhere within this box.
|
||||
*/
|
||||
public width: number;
|
||||
|
||||
/**
|
||||
* The height of the emitter. Particles can be randomly generated from anywhere within this box.
|
||||
*/
|
||||
public height: number;
|
||||
|
||||
/**
|
||||
* The minimum possible velocity of a particle.
|
||||
* The default value is (-100,-100).
|
||||
*/
|
||||
public minParticleSpeed: Point;
|
||||
|
||||
/**
|
||||
* The maximum possible velocity of a particle.
|
||||
* The default value is (100,100).
|
||||
*/
|
||||
public maxParticleSpeed: Point;
|
||||
|
||||
/**
|
||||
* The X and Y drag component of particles launched from the emitter.
|
||||
*/
|
||||
public particleDrag: Point;
|
||||
|
||||
/**
|
||||
* The minimum possible angular velocity of a particle. The default value is -360.
|
||||
* NOTE: rotating particles are more expensive to draw than non-rotating ones!
|
||||
*/
|
||||
public minRotation: number;
|
||||
|
||||
/**
|
||||
* The maximum possible angular velocity of a particle. The default value is 360.
|
||||
* NOTE: rotating particles are more expensive to draw than non-rotating ones!
|
||||
*/
|
||||
public maxRotation: number;
|
||||
|
||||
/**
|
||||
* Sets the <code>acceleration.y</code> member of each particle to this value on launch.
|
||||
*/
|
||||
public gravity: number;
|
||||
|
||||
/**
|
||||
* Determines whether the emitter is currently emitting particles.
|
||||
* It is totally safe to directly toggle this.
|
||||
*/
|
||||
public on: bool;
|
||||
|
||||
/**
|
||||
* How often a particle is emitted (if emitter is started with Explode == false).
|
||||
*/
|
||||
public frequency: number;
|
||||
|
||||
/**
|
||||
* How long each particle lives once it is emitted.
|
||||
* Set lifespan to 'zero' for particles to live forever.
|
||||
*/
|
||||
public lifespan: number;
|
||||
|
||||
/**
|
||||
* How much each particle should bounce. 1 = full bounce, 0 = no bounce.
|
||||
*/
|
||||
public bounce: number;
|
||||
|
||||
/**
|
||||
* Set your own particle class type here.
|
||||
* Default is <code>Particle</code>.
|
||||
*/
|
||||
public particleClass;
|
||||
|
||||
/**
|
||||
* Internal helper for deciding how many particles to launch.
|
||||
*/
|
||||
private _quantity: number;
|
||||
|
||||
/**
|
||||
* Internal helper for the style of particle emission (all at once, or one at a time).
|
||||
*/
|
||||
private _explode: bool;
|
||||
|
||||
/**
|
||||
* Internal helper for deciding when to launch particles or kill them.
|
||||
*/
|
||||
private _timer: number;
|
||||
|
||||
/**
|
||||
* Internal counter for figuring out how many particles to launch.
|
||||
*/
|
||||
private _counter: number;
|
||||
|
||||
/**
|
||||
* Internal point object, handy for reusing for memory mgmt purposes.
|
||||
*/
|
||||
private _point: Point;
|
||||
|
||||
/**
|
||||
* Clean up memory.
|
||||
*/
|
||||
public destroy() {
|
||||
this.minParticleSpeed = null;
|
||||
this.maxParticleSpeed = null;
|
||||
this.particleDrag = null;
|
||||
this.particleClass = null;
|
||||
this._point = null;
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function generates a new array of particle sprites to attach to the emitter.
|
||||
*
|
||||
* @param Graphics If you opted to not pre-configure an array of FlxSprite objects, you can simply pass in a particle image or sprite sheet.
|
||||
* @param Quantity The number of particles to generate when using the "create from image" option.
|
||||
* @param BakedRotations How many frames of baked rotation to use (boosts performance). Set to zero to not use baked rotations.
|
||||
* @param Multiple Whether the image in the Graphics param is a single particle or a bunch of particles (if it's a bunch, they need to be square!).
|
||||
* @param Collide Whether the particles should be flagged as not 'dead' (non-colliding particles are higher performance). 0 means no collisions, 0-1 controls scale of particle's bounding box.
|
||||
*
|
||||
* @return This FlxEmitter instance (nice for chaining stuff together, if you're into that).
|
||||
*/
|
||||
public makeParticles(Graphics, Quantity: number = 50, BakedRotations: number = 16, Multiple: bool = false, Collide: number = 0.8): Emitter {
|
||||
|
||||
this.maxSize = Quantity;
|
||||
|
||||
var totalFrames: number = 1;
|
||||
|
||||
/*
|
||||
if(Multiple)
|
||||
{
|
||||
var sprite:Sprite = new Sprite(this._game);
|
||||
sprite.loadGraphic(Graphics,true);
|
||||
totalFrames = sprite.frames;
|
||||
sprite.destroy();
|
||||
}
|
||||
*/
|
||||
|
||||
var randomFrame: number;
|
||||
var particle: Particle;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < Quantity)
|
||||
{
|
||||
if (this.particleClass == null)
|
||||
{
|
||||
particle = new Particle(this._game);
|
||||
}
|
||||
else
|
||||
{
|
||||
particle = new this.particleClass(this._game);
|
||||
}
|
||||
|
||||
if (Multiple)
|
||||
{
|
||||
/*
|
||||
randomFrame = this._game.math.random()*totalFrames;
|
||||
if(BakedRotations > 0)
|
||||
particle.loadRotatedGraphic(Graphics,BakedRotations,randomFrame);
|
||||
else
|
||||
{
|
||||
particle.loadGraphic(Graphics,true);
|
||||
particle.frame = randomFrame;
|
||||
}
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
if (BakedRotations > 0)
|
||||
particle.loadRotatedGraphic(Graphics,BakedRotations);
|
||||
else
|
||||
particle.loadGraphic(Graphics);
|
||||
*/
|
||||
|
||||
if (Graphics)
|
||||
{
|
||||
particle.loadGraphic(Graphics);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (Collide > 0)
|
||||
{
|
||||
particle.width *= Collide;
|
||||
particle.height *= Collide;
|
||||
//particle.centerOffsets();
|
||||
}
|
||||
else
|
||||
{
|
||||
particle.allowCollisions = GameObject.NONE;
|
||||
}
|
||||
|
||||
particle.exists = false;
|
||||
|
||||
this.add(particle);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called automatically by the game loop, decides when to launch particles and when to "die".
|
||||
*/
|
||||
public update() {
|
||||
|
||||
if (this.on)
|
||||
{
|
||||
if (this._explode)
|
||||
{
|
||||
this.on = false;
|
||||
|
||||
var i: number = 0;
|
||||
var l: number = this._quantity;
|
||||
|
||||
if ((l <= 0) || (l > this.length))
|
||||
{
|
||||
l = this.length;
|
||||
}
|
||||
|
||||
while (i < l)
|
||||
{
|
||||
this.emitParticle();
|
||||
i++;
|
||||
}
|
||||
|
||||
this._quantity = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._timer += this._game.time.elapsed;
|
||||
|
||||
while ((this.frequency > 0) && (this._timer > this.frequency) && this.on)
|
||||
{
|
||||
this._timer -= this.frequency;
|
||||
this.emitParticle();
|
||||
|
||||
if ((this._quantity > 0) && (++this._counter >= this._quantity))
|
||||
{
|
||||
this.on = false;
|
||||
this._quantity = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.update();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this function to turn off all the particles and the emitter.
|
||||
*/
|
||||
public kill() {
|
||||
|
||||
this.on = false;
|
||||
|
||||
super.kill();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this function to start emitting particles.
|
||||
*
|
||||
* @param Explode Whether the particles should all burst out at once.
|
||||
* @param Lifespan How long each particle lives once emitted. 0 = forever.
|
||||
* @param Frequency Ignored if Explode is set to true. Frequency is how often to emit a particle. 0 = never emit, 0.1 = 1 particle every 0.1 seconds, 5 = 1 particle every 5 seconds.
|
||||
* @param Quantity How many particles to launch. 0 = "all of the particles".
|
||||
*/
|
||||
public start(Explode: bool = true, Lifespan: number = 0, Frequency: number = 0.1, Quantity: number = 0) {
|
||||
|
||||
this.revive();
|
||||
|
||||
this.visible = true;
|
||||
this.on = true;
|
||||
|
||||
this._explode = Explode;
|
||||
this.lifespan = Lifespan;
|
||||
this.frequency = Frequency;
|
||||
this._quantity += Quantity;
|
||||
|
||||
this._counter = 0;
|
||||
this._timer = 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This function can be used both internally and externally to emit the next particle.
|
||||
*/
|
||||
public emitParticle() {
|
||||
|
||||
var particle: Particle = this.recycle(Particle);
|
||||
|
||||
particle.lifespan = this.lifespan;
|
||||
particle.elasticity = this.bounce;
|
||||
particle.reset(this.x - (particle.width >> 1) + this._game.math.random() * this.width, this.y - (particle.height >> 1) + this._game.math.random() * this.height);
|
||||
particle.visible = true;
|
||||
|
||||
if (this.minParticleSpeed.x != this.maxParticleSpeed.x)
|
||||
{
|
||||
particle.velocity.x = this.minParticleSpeed.x + this._game.math.random() * (this.maxParticleSpeed.x - this.minParticleSpeed.x);
|
||||
}
|
||||
else
|
||||
{
|
||||
particle.velocity.x = this.minParticleSpeed.x;
|
||||
}
|
||||
|
||||
if (this.minParticleSpeed.y != this.maxParticleSpeed.y)
|
||||
{
|
||||
particle.velocity.y = this.minParticleSpeed.y + this._game.math.random() * (this.maxParticleSpeed.y - this.minParticleSpeed.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
particle.velocity.y = this.minParticleSpeed.y;
|
||||
}
|
||||
|
||||
particle.acceleration.y = this.gravity;
|
||||
|
||||
if (this.minRotation != this.maxRotation)
|
||||
{
|
||||
particle.angularVelocity = this.minRotation + this._game.math.random() * (this.maxRotation - this.minRotation);
|
||||
}
|
||||
else
|
||||
{
|
||||
particle.angularVelocity = this.minRotation;
|
||||
}
|
||||
|
||||
if (particle.angularVelocity != 0)
|
||||
{
|
||||
particle.angle = this._game.math.random() * 360 - 180;
|
||||
}
|
||||
|
||||
particle.drag.x = this.particleDrag.x;
|
||||
particle.drag.y = this.particleDrag.y;
|
||||
particle.onEmit();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A more compact way of setting the width and height of the emitter.
|
||||
*
|
||||
* @param Width The desired width of the emitter (particles are spawned randomly within these dimensions).
|
||||
* @param Height The desired height of the emitter.
|
||||
*/
|
||||
public setSize(Width: number, Height: number) {
|
||||
this.width = Width;
|
||||
this.height = Height;
|
||||
}
|
||||
|
||||
/**
|
||||
* A more compact way of setting the X velocity range of the emitter.
|
||||
*
|
||||
* @param Min The minimum value for this range.
|
||||
* @param Max The maximum value for this range.
|
||||
*/
|
||||
public setXSpeed(Min: number = 0, Max: number = 0) {
|
||||
this.minParticleSpeed.x = Min;
|
||||
this.maxParticleSpeed.x = Max;
|
||||
}
|
||||
|
||||
/**
|
||||
* A more compact way of setting the Y velocity range of the emitter.
|
||||
*
|
||||
* @param Min The minimum value for this range.
|
||||
* @param Max The maximum value for this range.
|
||||
*/
|
||||
public setYSpeed(Min: number = 0, Max: number = 0) {
|
||||
this.minParticleSpeed.y = Min;
|
||||
this.maxParticleSpeed.y = Max;
|
||||
}
|
||||
|
||||
/**
|
||||
* A more compact way of setting the angular velocity constraints of the emitter.
|
||||
*
|
||||
* @param Min The minimum value for this range.
|
||||
* @param Max The maximum value for this range.
|
||||
*/
|
||||
public setRotation(Min: number = 0, Max: number = 0) {
|
||||
this.minRotation = Min;
|
||||
this.maxRotation = Max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the emitter's midpoint to match the midpoint of a <code>FlxObject</code>.
|
||||
*
|
||||
* @param Object The <code>FlxObject</code> that you want to sync up with.
|
||||
*/
|
||||
public at(Object) {
|
||||
Object.getMidpoint(this._point);
|
||||
this.x = this._point.x - (this.width >> 1);
|
||||
this.y = this._point.y - (this.height >> 1);
|
||||
}
|
||||
}
|
367
Phaser/Game.ts
Normal file
|
@ -0,0 +1,367 @@
|
|||
/// <reference path="Cache.ts" />
|
||||
/// <reference path="Cameras.ts" />
|
||||
/// <reference path="Emitter.ts" />
|
||||
/// <reference path="Group.ts" />
|
||||
/// <reference path="Loader.ts" />
|
||||
/// <reference path="Sound.ts" />
|
||||
/// <reference path="Sprite.ts" />
|
||||
/// <reference path="Stage.ts" />
|
||||
/// <reference path="Time.ts" />
|
||||
/// <reference path="GameMath.ts" />
|
||||
/// <reference path="World.ts" />
|
||||
/// <reference path="system/input/Input.ts" />
|
||||
/// <reference path="system/RequestAnimationFrame.ts" />
|
||||
|
||||
/**
|
||||
* Phaser
|
||||
*
|
||||
* v0.5 - April 12th 2013
|
||||
*
|
||||
* A small and feature-packed 2D canvas game framework born from the firey pits of Flixel and Kiwi.
|
||||
*
|
||||
* Richard Davey (@photonstorm)
|
||||
* Adam Saltsman (@ADAMATOMIC) (original Flixel code)
|
||||
*
|
||||
* "If you want your children to be intelligent, read them fairy tales."
|
||||
* "If you want them to be more intelligent, read them more fairy tales."
|
||||
* -- Albert Einstein
|
||||
*/
|
||||
|
||||
class Game {
|
||||
|
||||
constructor(callbackContext, parent?:string = '', width?: number = 800, height?: number = 600, initCallback = null, createCallback = null, updateCallback = null, renderCallback = null) {
|
||||
|
||||
this.callbackContext = callbackContext;
|
||||
this.onInitCallback = initCallback;
|
||||
this.onCreateCallback = createCallback;
|
||||
this.onUpdateCallback = updateCallback;
|
||||
this.onRenderCallback = renderCallback;
|
||||
|
||||
if (document.readyState === 'complete' || document.readyState === 'interactive')
|
||||
{
|
||||
this.boot(parent, width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
document.addEventListener('DOMContentLoaded', () => this.boot(parent, width, height), false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private _raf: RequestAnimationFrame;
|
||||
private _maxAccumulation: number = 32;
|
||||
private _accumulator: number = 0;
|
||||
private _step: number = 0;
|
||||
private _loadComplete: bool = false;
|
||||
private _paused: bool = false;
|
||||
private _pendingState = null;
|
||||
|
||||
public static VERSION: string = 'Phaser version 0.5';
|
||||
|
||||
// Event callbacks
|
||||
public callbackContext;
|
||||
public onInitCallback = null;
|
||||
public onCreateCallback = null;
|
||||
public onUpdateCallback = null;
|
||||
public onRenderCallback = null;
|
||||
public onPausedCallback = null;
|
||||
|
||||
public camera: Camera; // quick reference to the default created camera, access the rest via .world
|
||||
public cache: Cache;
|
||||
public input: Input;
|
||||
public loader: Loader;
|
||||
public sound: SoundManager;
|
||||
public stage: Stage;
|
||||
public time: Time;
|
||||
public math: GameMath;
|
||||
public world: World;
|
||||
|
||||
public isBooted: bool = false;
|
||||
|
||||
private boot(parent:string, width: number, height: number) {
|
||||
|
||||
if (!document.body)
|
||||
{
|
||||
window.setTimeout(() => this.boot(parent, width, height), 13);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.stage = new Stage(this, parent, width, height);
|
||||
this.world = new World(this, width, height);
|
||||
this.sound = new SoundManager(this);
|
||||
this.cache = new Cache(this);
|
||||
this.loader = new Loader(this, this.loadComplete);
|
||||
this.time = new Time(this);
|
||||
this.input = new Input(this);
|
||||
this.math = new GameMath(this);
|
||||
|
||||
this.framerate = 60;
|
||||
|
||||
// Display the default game screen?
|
||||
if (this.onInitCallback == null && this.onCreateCallback == null && this.onUpdateCallback == null && this.onRenderCallback == null && this._pendingState == null)
|
||||
{
|
||||
this.isBooted = false;
|
||||
this.stage.drawInitScreen();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.isBooted = true;
|
||||
this._loadComplete = false;
|
||||
|
||||
this._raf = new RequestAnimationFrame(this.loop, this);
|
||||
|
||||
if (this._pendingState)
|
||||
{
|
||||
this.switchState(this._pendingState, false, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.startState();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private loadComplete() {
|
||||
|
||||
// Called when the loader has finished after init was run
|
||||
this._loadComplete = true;
|
||||
|
||||
}
|
||||
|
||||
private loop() {
|
||||
|
||||
if (this._paused == true)
|
||||
{
|
||||
if (this.onPausedCallback !== null)
|
||||
{
|
||||
this.onPausedCallback.call(this.callbackContext);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
this.time.update();
|
||||
this.input.update();
|
||||
this.stage.update();
|
||||
|
||||
this._accumulator += this.time.delta;
|
||||
|
||||
if (this._accumulator > this._maxAccumulation)
|
||||
{
|
||||
this._accumulator = this._maxAccumulation;
|
||||
}
|
||||
|
||||
while (this._accumulator >= this._step)
|
||||
{
|
||||
this.time.elapsed = this.time.timeScale * (this._step / 1000);
|
||||
this.world.update();
|
||||
this._accumulator = this._accumulator - this._step;
|
||||
}
|
||||
|
||||
if (this._loadComplete && this.onUpdateCallback)
|
||||
{
|
||||
this.onUpdateCallback.call(this.callbackContext);
|
||||
}
|
||||
|
||||
this.world.render();
|
||||
|
||||
if (this._loadComplete && this.onRenderCallback)
|
||||
{
|
||||
this.onRenderCallback.call(this.callbackContext);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private startState() {
|
||||
|
||||
if (this.onInitCallback !== null)
|
||||
{
|
||||
this.onInitCallback.call(this.callbackContext);
|
||||
}
|
||||
else
|
||||
{
|
||||
// No init? Then there was nothing to load either
|
||||
if (this.onCreateCallback !== null)
|
||||
{
|
||||
this.onCreateCallback.call(this.callbackContext);
|
||||
}
|
||||
|
||||
this._loadComplete = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public setCallbacks(initCallback = null, createCallback = null, updateCallback = null, renderCallback = null) {
|
||||
|
||||
this.onInitCallback = initCallback;
|
||||
this.onCreateCallback = createCallback;
|
||||
this.onUpdateCallback = updateCallback;
|
||||
this.onRenderCallback = renderCallback;
|
||||
|
||||
}
|
||||
|
||||
public switchState(state, clearWorld: bool = true, clearCache:bool = false) {
|
||||
|
||||
if (this.isBooted == false)
|
||||
{
|
||||
this._pendingState = state;
|
||||
return;
|
||||
}
|
||||
|
||||
// Prototype?
|
||||
if (typeof state === 'function')
|
||||
{
|
||||
state = new state(this);
|
||||
}
|
||||
|
||||
// Ok, have we got the right functions?
|
||||
if (state['create'] || state['update'])
|
||||
{
|
||||
this.callbackContext = state;
|
||||
|
||||
this.onInitCallback = null;
|
||||
this.onCreateCallback = null;
|
||||
this.onUpdateCallback = null;
|
||||
this.onRenderCallback = null;
|
||||
this.onPausedCallback = null;
|
||||
|
||||
// Bingo, let's set them up
|
||||
if (state['init'])
|
||||
{
|
||||
this.onInitCallback = state['init'];
|
||||
}
|
||||
|
||||
if (state['create'])
|
||||
{
|
||||
this.onCreateCallback = state['create'];
|
||||
}
|
||||
|
||||
if (state['update'])
|
||||
{
|
||||
this.onUpdateCallback = state['update'];
|
||||
}
|
||||
|
||||
if (state['render'])
|
||||
{
|
||||
this.onRenderCallback = state['render'];
|
||||
}
|
||||
|
||||
if (state['paused'])
|
||||
{
|
||||
this.onPausedCallback = state['paused'];
|
||||
}
|
||||
|
||||
if (clearWorld)
|
||||
{
|
||||
this.world.destroy();
|
||||
|
||||
if (clearCache == true)
|
||||
{
|
||||
this.cache.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
this._loadComplete = false;
|
||||
|
||||
this.startState();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Error("Invalid State object given. Must contain at least a create or update function.");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Nuke the whole game from orbit
|
||||
public destroy() {
|
||||
|
||||
this.callbackContext = null;
|
||||
this.onInitCallback = null;
|
||||
this.onCreateCallback = null;
|
||||
this.onUpdateCallback = null;
|
||||
this.onRenderCallback = null;
|
||||
this.onPausedCallback = null;
|
||||
this.camera = null;
|
||||
this.cache = null;
|
||||
this.input = null;
|
||||
this.loader = null;
|
||||
this.sound = null;
|
||||
this.stage = null;
|
||||
this.time = null;
|
||||
this.math = null;
|
||||
this.world = null;
|
||||
this.isBooted = false;
|
||||
|
||||
}
|
||||
|
||||
public get pause(): bool {
|
||||
return this._paused;
|
||||
}
|
||||
|
||||
public set pause(value:bool) {
|
||||
|
||||
if (value == true && this._paused == false)
|
||||
{
|
||||
this._paused = true;
|
||||
}
|
||||
else if (value == false && this._paused == true)
|
||||
{
|
||||
this._paused = false;
|
||||
this.time.time = Date.now();
|
||||
this.input.reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public get framerate(): number {
|
||||
return 1000 / this._step;
|
||||
}
|
||||
|
||||
public set framerate(value: number) {
|
||||
|
||||
this._step = 1000 / value;
|
||||
|
||||
if (this._maxAccumulation < this._step)
|
||||
{
|
||||
this._maxAccumulation = this._step;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Handy Proxy methods
|
||||
|
||||
public createCamera(x: number, y: number, width: number, height: number): Camera {
|
||||
return this.world.createCamera(x, y, width, height);
|
||||
}
|
||||
|
||||
public createSprite(x: number, y: number, key?: string = ''): Sprite {
|
||||
return this.world.createSprite(x, y, key);
|
||||
}
|
||||
|
||||
public createGroup(MaxSize?: number = 0): Group {
|
||||
return this.world.createGroup(MaxSize);
|
||||
}
|
||||
|
||||
public createParticle(): Particle {
|
||||
return this.world.createParticle();
|
||||
}
|
||||
|
||||
public createEmitter(x?: number = 0, y?: number = 0, size?:number = 0): Emitter {
|
||||
return this.world.createEmitter(x, y, size);
|
||||
}
|
||||
|
||||
public createTilemap(key:string, mapData:string, format:number, tileWidth?:number,tileHeight?:number): Tilemap {
|
||||
return this.world.createTilemap(key, mapData, format, tileWidth, tileHeight);
|
||||
}
|
||||
|
||||
public collide(ObjectOrGroup1: Basic = null, ObjectOrGroup2: Basic = null, NotifyCallback = null): bool {
|
||||
return this.world.overlap(ObjectOrGroup1, ObjectOrGroup2, NotifyCallback, World.separate);
|
||||
}
|
||||
|
||||
}
|
984
Phaser/GameMath.ts
Normal file
|
@ -0,0 +1,984 @@
|
|||
/**
|
||||
* Phaser - GameMath
|
||||
*
|
||||
* @desc Adds a set of extra Math functions and extends a few commonly used ones.
|
||||
* Includes methods written by Dylan Engelman and Adam Saltsman.
|
||||
*
|
||||
* @version 1.0 - 17th March 2013
|
||||
* @author Richard Davey
|
||||
*/
|
||||
|
||||
class GameMath {
|
||||
|
||||
constructor(game: Game) {
|
||||
|
||||
this._game = game;
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
|
||||
public static PI: number = 3.141592653589793; //number pi
|
||||
public static PI_2: number = 1.5707963267948965; //PI / 2 OR 90 deg
|
||||
public static PI_4: number = 0.7853981633974483; //PI / 4 OR 45 deg
|
||||
public static PI_8: number = 0.39269908169872413; //PI / 8 OR 22.5 deg
|
||||
public static PI_16: number = 0.19634954084936206; //PI / 16 OR 11.25 deg
|
||||
public static TWO_PI: number = 6.283185307179586; //2 * PI OR 180 deg
|
||||
public static THREE_PI_2: number = 4.7123889803846895; //3 * PI_2 OR 270 deg
|
||||
public static E: number = 2.71828182845905; //number e
|
||||
public static LN10: number = 2.302585092994046; //ln(10)
|
||||
public static LN2: number = 0.6931471805599453; //ln(2)
|
||||
public static LOG10E: number = 0.4342944819032518; //logB10(e)
|
||||
public static LOG2E: number = 1.442695040888963387; //logB2(e)
|
||||
public static SQRT1_2: number = 0.7071067811865476; //sqrt( 1 / 2 )
|
||||
public static SQRT2: number = 1.4142135623730951; //sqrt( 2 )
|
||||
public static DEG_TO_RAD: number = 0.017453292519943294444444444444444; //PI / 180;
|
||||
public static RAD_TO_DEG: number = 57.295779513082325225835265587527; // 180.0 / PI;
|
||||
|
||||
public static B_16: number = 65536;//2^16
|
||||
public static B_31: number = 2147483648;//2^31
|
||||
public static B_32: number = 4294967296;//2^32
|
||||
public static B_48: number = 281474976710656;//2^48
|
||||
public static B_53: number = 9007199254740992;//2^53 !!NOTE!! largest accurate double floating point whole value
|
||||
public static B_64: number = 18446744073709551616;//2^64 !!NOTE!! Not accurate see B_53
|
||||
|
||||
public static ONE_THIRD: number = 0.333333333333333333333333333333333; // 1.0/3.0;
|
||||
public static TWO_THIRDS: number = 0.666666666666666666666666666666666; // 2.0/3.0;
|
||||
public static ONE_SIXTH: number = 0.166666666666666666666666666666666; // 1.0/6.0;
|
||||
|
||||
public static COS_PI_3: number = 0.86602540378443864676372317075294;//COS( PI / 3 )
|
||||
public static SIN_2PI_3: number = 0.03654595;// SIN( 2*PI/3 )
|
||||
|
||||
public static CIRCLE_ALPHA: number = 0.5522847498307933984022516322796; //4*(Math.sqrt(2)-1)/3.0;
|
||||
|
||||
public static ON: bool = true;
|
||||
public static OFF: bool = false;
|
||||
|
||||
public static SHORT_EPSILON: number = 0.1;//round integer epsilon
|
||||
public static PERC_EPSILON: number = 0.001;//percentage epsilon
|
||||
public static EPSILON: number = 0.0001;//single float average epsilon
|
||||
public static LONG_EPSILON: number = 0.00000001;//arbitrary 8 digit epsilon
|
||||
|
||||
public computeMachineEpsilon(): number {
|
||||
// Machine epsilon ala Eispack
|
||||
var fourThirds: number = 4.0 / 3.0;
|
||||
var third: number = fourThirds - 1.0;
|
||||
var one: number = third + third + third;
|
||||
return Math.abs(1.0 - one);
|
||||
}
|
||||
|
||||
public fuzzyEqual(a: number, b: number, epsilon: number = 0.0001): bool {
|
||||
return Math.abs(a - b) < epsilon;
|
||||
}
|
||||
|
||||
public fuzzyLessThan(a: number, b: number, epsilon: number = 0.0001): bool {
|
||||
return a < b + epsilon;
|
||||
}
|
||||
|
||||
public fuzzyGreaterThan(a: number, b: number, epsilon: number = 0.0001): bool {
|
||||
return a > b - epsilon;
|
||||
}
|
||||
|
||||
public fuzzyCeil(val: number, epsilon: number = 0.0001): number {
|
||||
return Math.ceil(val - epsilon);
|
||||
}
|
||||
|
||||
public fuzzyFloor(val: number, epsilon: number = 0.0001): number {
|
||||
return Math.floor(val + epsilon);
|
||||
}
|
||||
|
||||
public average(...args: any[]): number {
|
||||
var avg: number = 0;
|
||||
|
||||
for (var i = 0; i < args.length; i++)
|
||||
{
|
||||
avg += args[i];
|
||||
}
|
||||
|
||||
return avg / args.length;
|
||||
}
|
||||
|
||||
public slam(value: number, target: number, epsilon: number = 0.0001): number {
|
||||
return (Math.abs(value - target) < epsilon) ? target : value;
|
||||
}
|
||||
|
||||
/**
|
||||
* ratio of value to a range
|
||||
*/
|
||||
public percentageMinMax(val: number, max: number, min: number = 0): number {
|
||||
val -= min;
|
||||
max -= min;
|
||||
|
||||
if (!max) return 0;
|
||||
else return val / max;
|
||||
}
|
||||
|
||||
/**
|
||||
* a value representing the sign of the value.
|
||||
* -1 for negative, +1 for positive, 0 if value is 0
|
||||
*/
|
||||
public sign(n: number): number {
|
||||
if (n) return n / Math.abs(n);
|
||||
else return 0;
|
||||
}
|
||||
|
||||
public truncate(n: number): number {
|
||||
return (n > 0) ? Math.floor(n) : Math.ceil(n);
|
||||
}
|
||||
|
||||
public shear(n: number): number {
|
||||
return n % 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* wrap a value around a range, similar to modulus with a floating minimum
|
||||
*/
|
||||
public wrap(val: number, max: number, min: number = 0): number {
|
||||
val -= min;
|
||||
max -= min;
|
||||
if (max == 0) return min;
|
||||
val %= max;
|
||||
val += min;
|
||||
while (val < min)
|
||||
val += max;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
* arithmetic version of wrap... need to decide which is more efficient
|
||||
*/
|
||||
public arithWrap(value: number, max: number, min: number = 0): number {
|
||||
max -= min;
|
||||
if (max == 0) return min;
|
||||
return value - max * Math.floor((value - min) / max);
|
||||
}
|
||||
|
||||
/**
|
||||
* force a value within the boundaries of two values
|
||||
*
|
||||
* if max < min, min is returned
|
||||
*/
|
||||
public clamp(input: number, max: number, min: number = 0): number {
|
||||
return Math.max(min, Math.min(max, input));
|
||||
}
|
||||
|
||||
/**
|
||||
* Snap a value to nearest grid slice, using rounding.
|
||||
*
|
||||
* example if you have an interval gap of 5 and a position of 12... you will snap to 10. Where as 14 will snap to 15
|
||||
*
|
||||
* @param input - the value to snap
|
||||
* @param gap - the interval gap of the grid
|
||||
* @param start - optional starting offset for gap
|
||||
*/
|
||||
public snapTo(input: number, gap: number, start: number = 0): number {
|
||||
if (gap == 0) return input;
|
||||
|
||||
input -= start;
|
||||
input = gap * Math.round(input / gap);
|
||||
return start + input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Snap a value to nearest grid slice, using floor.
|
||||
*
|
||||
* example if you have an interval gap of 5 and a position of 12... you will snap to 10. As will 14 snap to 10... but 16 will snap to 15
|
||||
*
|
||||
* @param input - the value to snap
|
||||
* @param gap - the interval gap of the grid
|
||||
* @param start - optional starting offset for gap
|
||||
*/
|
||||
public snapToFloor(input: number, gap: number, start: number = 0): number {
|
||||
if (gap == 0) return input;
|
||||
|
||||
input -= start;
|
||||
input = gap * Math.floor(input / gap);
|
||||
return start + input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Snap a value to nearest grid slice, using ceil.
|
||||
*
|
||||
* example if you have an interval gap of 5 and a position of 12... you will snap to 15. As will 14 will snap to 15... but 16 will snap to 20
|
||||
*
|
||||
* @param input - the value to snap
|
||||
* @param gap - the interval gap of the grid
|
||||
* @param start - optional starting offset for gap
|
||||
*/
|
||||
public snapToCeil(input: number, gap: number, start: number = 0): number {
|
||||
if (gap == 0) return input;
|
||||
|
||||
input -= start;
|
||||
input = gap * Math.ceil(input / gap);
|
||||
return start + input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Snaps a value to the nearest value in an array.
|
||||
*/
|
||||
public snapToInArray(input: number, arr: number[], sort?: bool = true): number {
|
||||
|
||||
if (sort) arr.sort();
|
||||
if (input < arr[0]) return arr[0];
|
||||
|
||||
var i: number = 1;
|
||||
|
||||
while (arr[i] < input)
|
||||
i++;
|
||||
|
||||
var low: number = arr[i - 1];
|
||||
var high: number = (i < arr.length) ? arr[i] : Number.POSITIVE_INFINITY;
|
||||
|
||||
return ((high - input) <= (input - low)) ? high : low;
|
||||
}
|
||||
|
||||
/**
|
||||
* roundTo some place comparative to a 'base', default is 10 for decimal place
|
||||
*
|
||||
* 'place' is represented by the power applied to 'base' to get that place
|
||||
*
|
||||
* @param value - the value to round
|
||||
* @param place - the place to round to
|
||||
* @param base - the base to round in... default is 10 for decimal
|
||||
*
|
||||
* e.g.
|
||||
*
|
||||
* 2000/7 ~= 285.714285714285714285714 ~= (bin)100011101.1011011011011011
|
||||
*
|
||||
* roundTo(2000/7,3) == 0
|
||||
* roundTo(2000/7,2) == 300
|
||||
* roundTo(2000/7,1) == 290
|
||||
* roundTo(2000/7,0) == 286
|
||||
* roundTo(2000/7,-1) == 285.7
|
||||
* roundTo(2000/7,-2) == 285.71
|
||||
* roundTo(2000/7,-3) == 285.714
|
||||
* roundTo(2000/7,-4) == 285.7143
|
||||
* roundTo(2000/7,-5) == 285.71429
|
||||
*
|
||||
* roundTo(2000/7,3,2) == 288 -- 100100000
|
||||
* roundTo(2000/7,2,2) == 284 -- 100011100
|
||||
* roundTo(2000/7,1,2) == 286 -- 100011110
|
||||
* roundTo(2000/7,0,2) == 286 -- 100011110
|
||||
* roundTo(2000/7,-1,2) == 285.5 -- 100011101.1
|
||||
* roundTo(2000/7,-2,2) == 285.75 -- 100011101.11
|
||||
* roundTo(2000/7,-3,2) == 285.75 -- 100011101.11
|
||||
* roundTo(2000/7,-4,2) == 285.6875 -- 100011101.1011
|
||||
* roundTo(2000/7,-5,2) == 285.71875 -- 100011101.10111
|
||||
*
|
||||
* note what occurs when we round to the 3rd space (8ths place), 100100000, this is to be assumed
|
||||
* because we are rounding 100011.1011011011011011 which rounds up.
|
||||
*/
|
||||
public roundTo(value: number, place: number = 0, base: number = 10): number {
|
||||
var p: number = Math.pow(base, -place);
|
||||
return Math.round(value * p) / p;
|
||||
}
|
||||
|
||||
public floorTo(value: number, place: number = 0, base: number = 10): number {
|
||||
var p: number = Math.pow(base, -place);
|
||||
return Math.floor(value * p) / p;
|
||||
}
|
||||
|
||||
public ceilTo(value: number, place: number = 0, base: number = 10): number {
|
||||
var p: number = Math.pow(base, -place);
|
||||
return Math.ceil(value * p) / p;
|
||||
}
|
||||
|
||||
/**
|
||||
* a one dimensional linear interpolation of a value.
|
||||
*/
|
||||
public interpolateFloat(a: number, b: number, weight: number): number {
|
||||
return (b - a) * weight + a;
|
||||
}
|
||||
|
||||
/**
|
||||
* convert radians to degrees
|
||||
*/
|
||||
public radiansToDegrees(angle: number): number {
|
||||
return angle * GameMath.RAD_TO_DEG;
|
||||
}
|
||||
|
||||
/**
|
||||
* convert degrees to radians
|
||||
*/
|
||||
public degreesToRadians(angle: number): number {
|
||||
return angle * GameMath.DEG_TO_RAD;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the angle of a segment from (x1, y1) -> (x2, y2 )
|
||||
*/
|
||||
public angleBetween(x1: number, y1: number, x2: number, y2: number): number {
|
||||
return Math.atan2(y2 - y1, x2 - x1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set an angle with in the bounds of -PI to PI
|
||||
*/
|
||||
public normalizeAngle(angle: number, radians: bool = true): number {
|
||||
var rd: number = (radians) ? GameMath.PI : 180;
|
||||
return this.wrap(angle, rd, -rd);
|
||||
}
|
||||
|
||||
/**
|
||||
* closest angle between two angles from a1 to a2
|
||||
* absolute value the return for exact angle
|
||||
*/
|
||||
public nearestAngleBetween(a1: number, a2: number, radians: bool = true): number {
|
||||
|
||||
var rd: number = (radians) ? GameMath.PI : 180;
|
||||
|
||||
a1 = this.normalizeAngle(a1, radians);
|
||||
a2 = this.normalizeAngle(a2, radians);
|
||||
|
||||
if (a1 < -rd / 2 && a2 > rd / 2) a1 += rd * 2;
|
||||
if (a2 < -rd / 2 && a1 > rd / 2) a2 += rd * 2;
|
||||
|
||||
return a2 - a1;
|
||||
}
|
||||
|
||||
/**
|
||||
* normalizes independent and then sets dep to the nearest value respective to independent
|
||||
*
|
||||
* for instance if dep=-170 and ind=170 then 190 will be returned as an alternative to -170
|
||||
*/
|
||||
public normalizeAngleToAnother(dep: number, ind: number, radians: bool = true): number {
|
||||
return ind + this.nearestAngleBetween(ind, dep, radians);
|
||||
}
|
||||
|
||||
/**
|
||||
* normalize independent and dependent and then set dependent to an angle relative to 'after/clockwise' independent
|
||||
*
|
||||
* for instance dep=-170 and ind=170, then 190 will be reutrned as alternative to -170
|
||||
*/
|
||||
public normalizeAngleAfterAnother(dep: number, ind: number, radians: bool = true): number {
|
||||
|
||||
dep = this.normalizeAngle(dep - ind, radians);
|
||||
return ind + dep;
|
||||
}
|
||||
|
||||
/**
|
||||
* normalizes indendent and dependent and then sets dependent to an angle relative to 'before/counterclockwise' independent
|
||||
*
|
||||
* for instance dep = 190 and ind = 170, then -170 will be returned as an alternative to 190
|
||||
*/
|
||||
public normalizeAngleBeforeAnother(dep: number, ind: number, radians: bool = true): number {
|
||||
|
||||
dep = this.normalizeAngle(ind - dep, radians);
|
||||
return ind - dep;
|
||||
}
|
||||
|
||||
/**
|
||||
* interpolate across the shortest arc between two angles
|
||||
*/
|
||||
public interpolateAngles(a1: number, a2: number, weight: number, radians: bool = true, ease = null): number {
|
||||
|
||||
a1 = this.normalizeAngle(a1, radians);
|
||||
a2 = this.normalizeAngleToAnother(a2, a1, radians);
|
||||
|
||||
return (typeof ease === 'function') ? ease(weight, a1, a2 - a1, 1) : this.interpolateFloat(a1, a2, weight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the logarithm of any value of any base
|
||||
*
|
||||
* a logarithm is the exponent that some constant (base) would have to be raised to
|
||||
* to be equal to value.
|
||||
*
|
||||
* i.e.
|
||||
* 4 ^ x = 16
|
||||
* can be rewritten as to solve for x
|
||||
* logB4(16) = x
|
||||
* which with this function would be
|
||||
* LoDMath.logBaseOf(16,4)
|
||||
*
|
||||
* which would return 2, because 4^2 = 16
|
||||
*/
|
||||
public logBaseOf(value: number, base: number): number {
|
||||
return Math.log(value) / Math.log(base);
|
||||
}
|
||||
|
||||
/**
|
||||
* Greatest Common Denominator using Euclid's algorithm
|
||||
*/
|
||||
public GCD(m: number, n: number): number {
|
||||
var r: number;
|
||||
|
||||
//make sure positive, GCD is always positive
|
||||
m = Math.abs(m);
|
||||
n = Math.abs(n);
|
||||
|
||||
//m must be >= n
|
||||
if (m < n)
|
||||
{
|
||||
r = m;
|
||||
m = n;
|
||||
n = r;
|
||||
}
|
||||
|
||||
//now start loop
|
||||
while (true)
|
||||
{
|
||||
r = m % n;
|
||||
if (!r) return n;
|
||||
m = n;
|
||||
n = r;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lowest Common Multiple
|
||||
*/
|
||||
public LCM(m: number, n: number): number {
|
||||
return (m * n) / this.GCD(m, n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Factorial - N!
|
||||
*
|
||||
* simple product series
|
||||
*
|
||||
* by definition:
|
||||
* 0! == 1
|
||||
*/
|
||||
public factorial(value: number): number {
|
||||
if (value == 0) return 1;
|
||||
|
||||
var res: number = value;
|
||||
|
||||
while (--value)
|
||||
{
|
||||
res *= value;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gamma function
|
||||
*
|
||||
* defined: gamma(N) == (N - 1)!
|
||||
*/
|
||||
public gammaFunction(value: number): number {
|
||||
return this.factorial(value - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* falling factorial
|
||||
*
|
||||
* defined: (N)! / (N - x)!
|
||||
*
|
||||
* written subscript: (N)x OR (base)exp
|
||||
*/
|
||||
public fallingFactorial(base: number, exp: number): number {
|
||||
return this.factorial(base) / this.factorial(base - exp);
|
||||
}
|
||||
|
||||
/**
|
||||
* rising factorial
|
||||
*
|
||||
* defined: (N + x - 1)! / (N - 1)!
|
||||
*
|
||||
* written superscript N^(x) OR base^(exp)
|
||||
*/
|
||||
public risingFactorial(base: number, exp: number): number {
|
||||
//expanded from gammaFunction for speed
|
||||
return this.factorial(base + exp - 1) / this.factorial(base - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* binomial coefficient
|
||||
*
|
||||
* defined: N! / (k!(N-k)!)
|
||||
* reduced: N! / (N-k)! == (N)k (fallingfactorial)
|
||||
* reduced: (N)k / k!
|
||||
*/
|
||||
public binCoef(n: number, k: number): number {
|
||||
return this.fallingFactorial(n, k) / this.factorial(k);
|
||||
}
|
||||
|
||||
/**
|
||||
* rising binomial coefficient
|
||||
*
|
||||
* as one can notice in the analysis of binCoef(...) that
|
||||
* binCoef is the (N)k divided by k!. Similarly rising binCoef
|
||||
* is merely N^(k) / k!
|
||||
*/
|
||||
public risingBinCoef(n: number, k: number): number {
|
||||
return this.risingFactorial(n, k) / this.factorial(k);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a random boolean result based on the chance value
|
||||
* <p>
|
||||
* Returns true or false based on the chance value (default 50%). For example if you wanted a player to have a 30% chance
|
||||
* of getting a bonus, call chanceRoll(30) - true means the chance passed, false means it failed.
|
||||
* </p>
|
||||
* @param chance The chance of receiving the value. A number between 0 and 100 (effectively 0% to 100%)
|
||||
* @return true if the roll passed, or false
|
||||
*/
|
||||
public chanceRoll(chance: number = 50): bool {
|
||||
|
||||
if (chance <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (chance >= 100)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Math.random() * 100 >= chance)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given amount to the value, but never lets the value go over the specified maximum
|
||||
*
|
||||
* @param value The value to add the amount to
|
||||
* @param amount The amount to add to the value
|
||||
* @param max The maximum the value is allowed to be
|
||||
* @return The new value
|
||||
*/
|
||||
public maxAdd(value: number, amount: number, max: number): number {
|
||||
|
||||
value += amount;
|
||||
|
||||
if (value > max)
|
||||
{
|
||||
value = max;
|
||||
}
|
||||
|
||||
return value;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtracts the given amount from the value, but never lets the value go below the specified minimum
|
||||
*
|
||||
* @param value The base value
|
||||
* @param amount The amount to subtract from the base value
|
||||
* @param min The minimum the value is allowed to be
|
||||
* @return The new value
|
||||
*/
|
||||
public minSub(value: number, amount: number, min: number): number {
|
||||
|
||||
value -= amount;
|
||||
|
||||
if (value < min)
|
||||
{
|
||||
value = min;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds value to amount and ensures that the result always stays between 0 and max, by wrapping the value around.
|
||||
* <p>Values must be positive integers, and are passed through Math.abs</p>
|
||||
*
|
||||
* @param value The value to add the amount to
|
||||
* @param amount The amount to add to the value
|
||||
* @param max The maximum the value is allowed to be
|
||||
* @return The wrapped value
|
||||
*/
|
||||
public wrapValue(value: number, amount: number, max: number): number {
|
||||
|
||||
var diff: number;
|
||||
|
||||
value = Math.abs(value);
|
||||
amount = Math.abs(amount);
|
||||
max = Math.abs(max);
|
||||
|
||||
diff = (value + amount) % max;
|
||||
|
||||
return diff;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Randomly returns either a 1 or -1
|
||||
*
|
||||
* @return 1 or -1
|
||||
*/
|
||||
public randomSign(): number {
|
||||
return (Math.random() > 0.5) ? 1 : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the number given is odd.
|
||||
*
|
||||
* @param n The number to check
|
||||
*
|
||||
* @return True if the given number is odd. False if the given number is even.
|
||||
*/
|
||||
public isOdd(n: number): bool {
|
||||
|
||||
if (n & 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the number given is even.
|
||||
*
|
||||
* @param n The number to check
|
||||
*
|
||||
* @return True if the given number is even. False if the given number is odd.
|
||||
*/
|
||||
public isEven(n: number): bool {
|
||||
|
||||
if (n & 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Keeps an angle value between -180 and +180<br>
|
||||
* Should be called whenever the angle is updated on the Sprite to stop it from going insane.
|
||||
*
|
||||
* @param angle The angle value to check
|
||||
*
|
||||
* @return The new angle value, returns the same as the input angle if it was within bounds
|
||||
*/
|
||||
public wrapAngle(angle: number): number {
|
||||
|
||||
var result: number = angle;
|
||||
|
||||
// Nothing needs to change
|
||||
if (angle >= -180 && angle <= 180)
|
||||
{
|
||||
return angle;
|
||||
}
|
||||
|
||||
// Else normalise it to -180, 180
|
||||
result = (angle + 180) % 360;
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
result += 360;
|
||||
}
|
||||
|
||||
return result - 180;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Keeps an angle value between the given min and max values
|
||||
*
|
||||
* @param angle The angle value to check. Must be between -180 and +180
|
||||
* @param min The minimum angle that is allowed (must be -180 or greater)
|
||||
* @param max The maximum angle that is allowed (must be 180 or less)
|
||||
*
|
||||
* @return The new angle value, returns the same as the input angle if it was within bounds
|
||||
*/
|
||||
public angleLimit(angle: number, min: number, max: number): number {
|
||||
|
||||
var result: number = angle;
|
||||
|
||||
if (angle > max)
|
||||
{
|
||||
result = max;
|
||||
}
|
||||
else if (angle < min)
|
||||
{
|
||||
result = min;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method linear
|
||||
* @param {Any} v
|
||||
* @param {Any} k
|
||||
* @static
|
||||
*/
|
||||
public linearInterpolation(v, k) {
|
||||
|
||||
var m = v.length - 1;
|
||||
var f = m * k;
|
||||
var i = Math.floor(f);
|
||||
|
||||
if (k < 0) return this.linear(v[0], v[1], f);
|
||||
if (k > 1) return this.linear(v[m], v[m - 1], m - f);
|
||||
|
||||
return this.linear(v[i], v[i + 1 > m ? m : i + 1], f - i);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @method Bezier
|
||||
* @param {Any} v
|
||||
* @param {Any} k
|
||||
* @static
|
||||
*/
|
||||
public bezierInterpolation(v, k) {
|
||||
|
||||
var b = 0;
|
||||
var n = v.length - 1;
|
||||
|
||||
for (var i = 0; i <= n; i++)
|
||||
{
|
||||
b += Math.pow(1 - k, n - i) * Math.pow(k, i) * v[i] * this.bernstein(n, i);
|
||||
}
|
||||
|
||||
return b;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @method CatmullRom
|
||||
* @param {Any} v
|
||||
* @param {Any} k
|
||||
* @static
|
||||
*/
|
||||
public catmullRomInterpolation(v, k) {
|
||||
|
||||
var m = v.length - 1;
|
||||
var f = m * k;
|
||||
var i = Math.floor(f);
|
||||
|
||||
if (v[0] === v[m])
|
||||
{
|
||||
if (k < 0) i = Math.floor(f = m * (1 + k));
|
||||
|
||||
return this.catmullRom(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (k < 0) return v[0] - (this.catmullRom(v[0], v[0], v[1], v[1], -f) - v[0]);
|
||||
|
||||
if (k > 1) return v[m] - (this.catmullRom(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]);
|
||||
|
||||
return this.catmullRom(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @method Linear
|
||||
* @param {Any} p0
|
||||
* @param {Any} p1
|
||||
* @param {Any} t
|
||||
* @static
|
||||
*/
|
||||
public linear(p0, p1, t) {
|
||||
|
||||
return (p1 - p0) * t + p0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @method Bernstein
|
||||
* @param {Any} n
|
||||
* @param {Any} i
|
||||
* @static
|
||||
*/
|
||||
public bernstein(n, i) {
|
||||
|
||||
return this.factorial(n) / this.factorial(i) / this.factorial(n - i);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @method CatmullRom
|
||||
* @param {Any} p0
|
||||
* @param {Any} p1
|
||||
* @param {Any} p2
|
||||
* @param {Any} p3
|
||||
* @param {Any} t
|
||||
* @static
|
||||
*/
|
||||
public catmullRom(p0, p1, p2, p3, t) {
|
||||
|
||||
var v0 = (p2 - p0) * 0.5, v1 = (p3 - p1) * 0.5, t2 = t * t, t3 = t * t2;
|
||||
return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1;
|
||||
|
||||
}
|
||||
|
||||
public difference(a: number, b: number): number {
|
||||
|
||||
return Math.abs(a - b);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A tween-like function that takes a starting velocity
|
||||
* and some other factors and returns an altered velocity.
|
||||
*
|
||||
* @param Velocity Any component of velocity (e.g. 20).
|
||||
* @param Acceleration Rate at which the velocity is changing.
|
||||
* @param Drag Really kind of a deceleration, this is how much the velocity changes if Acceleration is not set.
|
||||
* @param Max An absolute value cap for the velocity.
|
||||
*
|
||||
* @return The altered Velocity value.
|
||||
*/
|
||||
public computeVelocity(Velocity: number, Acceleration: number = 0, Drag: number = 0, Max: number = 10000): number {
|
||||
|
||||
if (Acceleration !== 0)
|
||||
{
|
||||
Velocity += Acceleration * this._game.time.elapsed;
|
||||
}
|
||||
else if (Drag !== 0)
|
||||
{
|
||||
var drag: number = Drag * this._game.time.elapsed;
|
||||
|
||||
if (Velocity - drag > 0)
|
||||
{
|
||||
Velocity = Velocity - drag;
|
||||
}
|
||||
else if (Velocity + drag < 0)
|
||||
{
|
||||
Velocity += drag;
|
||||
}
|
||||
else
|
||||
{
|
||||
Velocity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ((Velocity != 0) && (Max != 10000))
|
||||
{
|
||||
if (Velocity > Max)
|
||||
{
|
||||
Velocity = Max;
|
||||
}
|
||||
else if (Velocity < -Max)
|
||||
{
|
||||
Velocity = -Max;
|
||||
}
|
||||
}
|
||||
|
||||
return Velocity;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the angle and speed calculate the velocity and return it as a Point
|
||||
*
|
||||
* @param angle The angle (in degrees) calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative)
|
||||
* @param speed The speed it will move, in pixels per second sq
|
||||
*
|
||||
* @return A Point where Point.x contains the velocity x value and Point.y contains the velocity y value
|
||||
*/
|
||||
public velocityFromAngle(angle: number, speed: number): Point {
|
||||
var a: number = this.degreesToRadians(angle);
|
||||
|
||||
return new Point((Math.cos(a) * speed), (Math.sin(a) * speed));
|
||||
}
|
||||
|
||||
/**
|
||||
* The global random number generator seed (for deterministic behavior in recordings and saves).
|
||||
*/
|
||||
public globalSeed: number = Math.random();
|
||||
|
||||
/**
|
||||
* Generates a random number. Deterministic, meaning safe
|
||||
* to use if you want to record replays in random environments.
|
||||
*
|
||||
* @return A <code>Number</code> between 0 and 1.
|
||||
*/
|
||||
public random(): number {
|
||||
return this.globalSeed = this.srand(this.globalSeed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a random number based on the seed provided.
|
||||
*
|
||||
* @param Seed A number between 0 and 1, used to generate a predictable random number (very optional).
|
||||
*
|
||||
* @return A <code>Number</code> between 0 and 1.
|
||||
*/
|
||||
public srand(Seed: number): number {
|
||||
|
||||
return ((69621 * (Seed * 0x7FFFFFFF)) % 0x7FFFFFFF) / 0x7FFFFFFF;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a random entry from the given array.
|
||||
* Will return null if random selection is missing, or array has no entries.
|
||||
* <code>FlxG.getRandom()</code> is deterministic and safe for use with replays/recordings.
|
||||
* HOWEVER, <code>FlxU.getRandom()</code> is NOT deterministic and unsafe for use with replays/recordings.
|
||||
*
|
||||
* @param Objects An array of objects.
|
||||
* @param StartIndex Optional offset off the front of the array. Default value is 0, or the beginning of the array.
|
||||
* @param Length Optional restriction on the number of values you want to randomly select from.
|
||||
*
|
||||
* @return The random object that was selected.
|
||||
*/
|
||||
public getRandom(Objects, StartIndex: number = 0, Length: number = 0) {
|
||||
|
||||
if (Objects != null)
|
||||
{
|
||||
var l: number = Length;
|
||||
|
||||
if ((l == 0) || (l > Objects.length - StartIndex))
|
||||
{
|
||||
l = Objects.length - StartIndex;
|
||||
}
|
||||
|
||||
if (l > 0)
|
||||
{
|
||||
return Objects[StartIndex + Math.floor(Math.random() * l)];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Round down to the next whole number. E.g. floor(1.7) == 1, and floor(-2.7) == -2.
|
||||
*
|
||||
* @param Value Any number.
|
||||
*
|
||||
* @return The rounded value of that number.
|
||||
*/
|
||||
public floor(Value: number): number {
|
||||
var n: number = Value|0;
|
||||
return (Value > 0) ? (n) : ((n != Value) ? (n - 1) : (n));
|
||||
}
|
||||
|
||||
/**
|
||||
* Round up to the next whole number. E.g. ceil(1.3) == 2, and ceil(-2.3) == -3.
|
||||
*
|
||||
* @param Value Any number.
|
||||
*
|
||||
* @return The rounded value of that number.
|
||||
*/
|
||||
public ceil(Value: number): number {
|
||||
var n: number = Value|0;
|
||||
return (Value > 0) ? ((n != Value) ? (n + 1) : (n)) : (n);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
499
Phaser/GameObject.ts
Normal file
|
@ -0,0 +1,499 @@
|
|||
/// <reference path="Basic.ts" />
|
||||
/// <reference path="Game.ts" />
|
||||
/// <reference path="GameMath.ts" />
|
||||
/// <reference path="Rectangle.ts" />
|
||||
/// <reference path="Point.ts" />
|
||||
|
||||
class GameObject extends Basic {
|
||||
|
||||
constructor(game:Game, x?: number = 0, y?: number = 0, width?: number = 16, height?: number = 16) {
|
||||
|
||||
super(game);
|
||||
|
||||
this.bounds = new Rectangle(x, y, width, height);
|
||||
this.exists = true;
|
||||
this.active = true;
|
||||
this.visible = true;
|
||||
this.alive = true;
|
||||
this.isGroup = false;
|
||||
this.alpha = 1;
|
||||
this.scale = new Point(1, 1);
|
||||
|
||||
this.last = new Point(x, y);
|
||||
this.origin = new Point(this.bounds.halfWidth, this.bounds.halfHeight);
|
||||
this.mass = 1.0;
|
||||
this.elasticity = 0.0;
|
||||
this.health = 1;
|
||||
this.immovable = false;
|
||||
this.moves = true;
|
||||
|
||||
this.touching = GameObject.NONE;
|
||||
this.wasTouching = GameObject.NONE;
|
||||
this.allowCollisions = GameObject.ANY;
|
||||
|
||||
this.velocity = new Point();
|
||||
this.acceleration = new Point();
|
||||
this.drag = new Point();
|
||||
this.maxVelocity = new Point(10000, 10000);
|
||||
|
||||
this.angle = 0;
|
||||
this.angularVelocity = 0;
|
||||
this.angularAcceleration = 0;
|
||||
this.angularDrag = 0;
|
||||
this.maxAngular = 10000;
|
||||
|
||||
this.scrollFactor = new Point(1.0, 1.0);
|
||||
|
||||
}
|
||||
|
||||
private _angle: number = 0;
|
||||
public _point: Point;
|
||||
|
||||
public static LEFT: number = 0x0001;
|
||||
public static RIGHT: number = 0x0010;
|
||||
public static UP: number = 0x0100;
|
||||
public static DOWN: number = 0x1000;
|
||||
public static NONE: number = 0;
|
||||
public static CEILING: number = GameObject.UP;
|
||||
public static FLOOR: number = GameObject.DOWN;
|
||||
public static WALL: number = GameObject.LEFT | GameObject.RIGHT;
|
||||
public static ANY: number = GameObject.LEFT | GameObject.RIGHT | GameObject.UP | GameObject.DOWN;
|
||||
public static OVERLAP_BIAS: number = 4;
|
||||
|
||||
public bounds: Rectangle;
|
||||
public alpha: number;
|
||||
public scale: Point;
|
||||
public origin: Point;
|
||||
|
||||
// Physics properties
|
||||
public immovable: bool;
|
||||
public velocity: Point;
|
||||
public mass: number;
|
||||
public elasticity: number;
|
||||
public acceleration: Point;
|
||||
public drag: Point;
|
||||
public maxVelocity: Point;
|
||||
public angularVelocity: number;
|
||||
public angularAcceleration: number;
|
||||
public angularDrag: number;
|
||||
public maxAngular: number;
|
||||
public scrollFactor: Point;
|
||||
|
||||
public health: number;
|
||||
public moves: bool = true;
|
||||
public touching: number;
|
||||
public wasTouching: number;
|
||||
public allowCollisions: number;
|
||||
public last: Point;
|
||||
|
||||
public preUpdate() {
|
||||
|
||||
// flicker time
|
||||
|
||||
this.last.x = this.bounds.x;
|
||||
this.last.y = this.bounds.y;
|
||||
|
||||
}
|
||||
|
||||
public update() {
|
||||
}
|
||||
|
||||
public postUpdate() {
|
||||
|
||||
if (this.moves)
|
||||
{
|
||||
this.updateMotion();
|
||||
}
|
||||
|
||||
this.wasTouching = this.touching;
|
||||
this.touching = GameObject.NONE;
|
||||
|
||||
}
|
||||
|
||||
private updateMotion() {
|
||||
|
||||
var delta: number;
|
||||
var velocityDelta: number;
|
||||
|
||||
velocityDelta = (this._game.math.computeVelocity(this.angularVelocity, this.angularAcceleration, this.angularDrag, this.maxAngular) - this.angularVelocity) / 2;
|
||||
this.angularVelocity += velocityDelta;
|
||||
this._angle += this.angularVelocity * this._game.time.elapsed;
|
||||
this.angularVelocity += velocityDelta;
|
||||
|
||||
velocityDelta = (this._game.math.computeVelocity(this.velocity.x, this.acceleration.x, this.drag.x, this.maxVelocity.x) - this.velocity.x) / 2;
|
||||
this.velocity.x += velocityDelta;
|
||||
delta = this.velocity.x * this._game.time.elapsed;
|
||||
this.velocity.x += velocityDelta;
|
||||
this.bounds.x += delta;
|
||||
|
||||
velocityDelta = (this._game.math.computeVelocity(this.velocity.y, this.acceleration.y, this.drag.y, this.maxVelocity.y) - this.velocity.y) / 2;
|
||||
this.velocity.y += velocityDelta;
|
||||
delta = this.velocity.y * this._game.time.elapsed;
|
||||
this.velocity.y += velocityDelta;
|
||||
this.bounds.y += delta;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if some <code>GameObject</code> overlaps this <code>GameObject</code> or <code>FlxGroup</code>.
|
||||
* If the group has a LOT of things in it, it might be faster to use <code>FlxG.overlaps()</code>.
|
||||
* WARNING: Currently tilemaps do NOT support screen space overlap checks!
|
||||
*
|
||||
* @param ObjectOrGroup The object or group being tested.
|
||||
* @param InScreenSpace Whether to take scroll factors numbero account when checking for overlap. Default is false, or "only compare in world space."
|
||||
* @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
|
||||
*
|
||||
* @return Whether or not the two objects overlap.
|
||||
*/
|
||||
public overlaps(ObjectOrGroup, InScreenSpace: bool = false, Camera: Camera = null): bool {
|
||||
|
||||
if (ObjectOrGroup.isGroup)
|
||||
{
|
||||
var results: bool = false;
|
||||
var i: number = 0;
|
||||
var members = <Group> ObjectOrGroup.members;
|
||||
|
||||
while (i < length)
|
||||
{
|
||||
if (this.overlaps(members[i++], InScreenSpace, Camera))
|
||||
{
|
||||
results = true;
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
if (typeof ObjectOrGroup === 'FlxTilemap')
|
||||
{
|
||||
//Since tilemap's have to be the caller, not the target, to do proper tile-based collisions,
|
||||
// we redirect the call to the tilemap overlap here.
|
||||
return ObjectOrGroup.overlaps(this, InScreenSpace, Camera);
|
||||
}
|
||||
*/
|
||||
|
||||
//var object: GameObject = ObjectOrGroup;
|
||||
|
||||
if (!InScreenSpace)
|
||||
{
|
||||
return (ObjectOrGroup.x + ObjectOrGroup.width > this.x) && (ObjectOrGroup.x < this.x + this.width) &&
|
||||
(ObjectOrGroup.y + ObjectOrGroup.height > this.y) && (ObjectOrGroup.y < this.y + this.height);
|
||||
}
|
||||
|
||||
if (Camera == null)
|
||||
{
|
||||
Camera = this._game.camera;
|
||||
}
|
||||
|
||||
var objectScreenPos: Point = ObjectOrGroup.getScreenXY(null, Camera);
|
||||
|
||||
this.getScreenXY(this._point, Camera);
|
||||
|
||||
return (objectScreenPos.x + ObjectOrGroup.width > this._point.x) && (objectScreenPos.x < this._point.x + this.width) &&
|
||||
(objectScreenPos.y + ObjectOrGroup.height > this._point.y) && (objectScreenPos.y < this._point.y + this.height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if this <code>GameObject</code> were located at the given position, would it overlap the <code>GameObject</code> or <code>FlxGroup</code>?
|
||||
* This is distinct from overlapsPoint(), which just checks that ponumber, rather than taking the object's size numbero account.
|
||||
* WARNING: Currently tilemaps do NOT support screen space overlap checks!
|
||||
*
|
||||
* @param X The X position you want to check. Pretends this object (the caller, not the parameter) is located here.
|
||||
* @param Y The Y position you want to check. Pretends this object (the caller, not the parameter) is located here.
|
||||
* @param ObjectOrGroup The object or group being tested.
|
||||
* @param InScreenSpace Whether to take scroll factors numbero account when checking for overlap. Default is false, or "only compare in world space."
|
||||
* @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
|
||||
*
|
||||
* @return Whether or not the two objects overlap.
|
||||
*/
|
||||
public overlapsAt(X: number, Y: number, ObjectOrGroup, InScreenSpace: bool = false, Camera: Camera = null): bool {
|
||||
|
||||
if (ObjectOrGroup.isGroup)
|
||||
{
|
||||
var results: bool = false;
|
||||
var basic;
|
||||
var i: number = 0;
|
||||
var members = ObjectOrGroup.members;
|
||||
|
||||
while (i < length)
|
||||
{
|
||||
if (this.overlapsAt(X, Y, members[i++], InScreenSpace, Camera))
|
||||
{
|
||||
results = true;
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/*
|
||||
if (typeof ObjectOrGroup === 'FlxTilemap')
|
||||
{
|
||||
//Since tilemap's have to be the caller, not the target, to do proper tile-based collisions,
|
||||
// we redirect the call to the tilemap overlap here.
|
||||
//However, since this is overlapsAt(), we also have to invent the appropriate position for the tilemap.
|
||||
//So we calculate the offset between the player and the requested position, and subtract that from the tilemap.
|
||||
var tilemap: FlxTilemap = ObjectOrGroup;
|
||||
return tilemap.overlapsAt(tilemap.x - (X - this.x), tilemap.y - (Y - this.y), this, InScreenSpace, Camera);
|
||||
}
|
||||
*/
|
||||
|
||||
//var object: GameObject = ObjectOrGroup;
|
||||
|
||||
if (!InScreenSpace)
|
||||
{
|
||||
return (ObjectOrGroup.x + ObjectOrGroup.width > X) && (ObjectOrGroup.x < X + this.width) &&
|
||||
(ObjectOrGroup.y + ObjectOrGroup.height > Y) && (ObjectOrGroup.y < Y + this.height);
|
||||
}
|
||||
|
||||
if (Camera == null)
|
||||
{
|
||||
Camera = this._game.camera;
|
||||
}
|
||||
|
||||
var objectScreenPos: Point = ObjectOrGroup.getScreenXY(null, Camera);
|
||||
|
||||
this._point.x = X - Camera.scroll.x * this.scrollFactor.x; //copied from getScreenXY()
|
||||
this._point.y = Y - Camera.scroll.y * this.scrollFactor.y;
|
||||
this._point.x += (this._point.x > 0) ? 0.0000001 : -0.0000001;
|
||||
this._point.y += (this._point.y > 0) ? 0.0000001 : -0.0000001;
|
||||
|
||||
return (objectScreenPos.x + ObjectOrGroup.width > this._point.x) && (objectScreenPos.x < this._point.x + this.width) &&
|
||||
(objectScreenPos.y + ObjectOrGroup.height > this._point.y) && (objectScreenPos.y < this._point.y + this.height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if a ponumber in 2D world space overlaps this <code>GameObject</code> object.
|
||||
*
|
||||
* @param Point The ponumber in world space you want to check.
|
||||
* @param InScreenSpace Whether to take scroll factors numbero account when checking for overlap.
|
||||
* @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
|
||||
*
|
||||
* @return Whether or not the ponumber overlaps this object.
|
||||
*/
|
||||
public overlapsPoint(point: Point, InScreenSpace: bool = false, Camera: Camera = null): bool {
|
||||
|
||||
if (!InScreenSpace)
|
||||
{
|
||||
return (point.x > this.x) && (point.x < this.x + this.width) && (point.y > this.y) && (point.y < this.y + this.height);
|
||||
}
|
||||
|
||||
if (Camera == null)
|
||||
{
|
||||
Camera = this._game.camera;
|
||||
}
|
||||
|
||||
var X: number = point.x - Camera.scroll.x;
|
||||
var Y: number = point.y - Camera.scroll.y;
|
||||
|
||||
this.getScreenXY(this._point, Camera);
|
||||
|
||||
return (X > this._point.x) && (X < this._point.x + this.width) && (Y > this._point.y) && (Y < this._point.y + this.height);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check and see if this object is currently on screen.
|
||||
*
|
||||
* @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
|
||||
*
|
||||
* @return Whether the object is on screen or not.
|
||||
*/
|
||||
public onScreen(Camera: Camera = null): bool {
|
||||
|
||||
if (Camera == null)
|
||||
{
|
||||
Camera = this._game.camera;
|
||||
}
|
||||
|
||||
this.getScreenXY(this._point, Camera);
|
||||
|
||||
return (this._point.x + this.width > 0) && (this._point.x < Camera.width) && (this._point.y + this.height > 0) && (this._point.y < Camera.height);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this to figure out the on-screen position of the object.
|
||||
*
|
||||
* @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
|
||||
* @param Point Takes a <code>Point</code> object and assigns the post-scrolled X and Y values of this object to it.
|
||||
*
|
||||
* @return The <code>Point</code> you passed in, or a new <code>Point</code> if you didn't pass one, containing the screen X and Y position of this object.
|
||||
*/
|
||||
public getScreenXY(point: Point = null, Camera: Camera = null): Point {
|
||||
|
||||
if (point == null)
|
||||
{
|
||||
point = new Point();
|
||||
}
|
||||
|
||||
if (Camera == null)
|
||||
{
|
||||
Camera = this._game.camera;
|
||||
}
|
||||
|
||||
point.x = this.x - Camera.scroll.x * this.scrollFactor.x;
|
||||
point.y = this.y - Camera.scroll.y * this.scrollFactor.y;
|
||||
point.x += (point.x > 0) ? 0.0000001 : -0.0000001;
|
||||
point.y += (point.y > 0) ? 0.0000001 : -0.0000001;
|
||||
|
||||
return point;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the object collides or not. For more control over what directions
|
||||
* the object will collide from, use collision constants (like LEFT, FLOOR, etc)
|
||||
* to set the value of allowCollisions directly.
|
||||
*/
|
||||
public get solid(): bool {
|
||||
return (this.allowCollisions & GameObject.ANY) > GameObject.NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
public set solid(Solid: bool) {
|
||||
|
||||
if (Solid)
|
||||
{
|
||||
this.allowCollisions = GameObject.ANY;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.allowCollisions = GameObject.NONE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the midponumber of this object in world coordinates.
|
||||
*
|
||||
* @Point Allows you to pass in an existing <code>Point</code> object if you're so inclined. Otherwise a new one is created.
|
||||
*
|
||||
* @return A <code>Point</code> object containing the midponumber of this object in world coordinates.
|
||||
*/
|
||||
public getMidpoint(point: Point = null): Point {
|
||||
|
||||
if (point == null)
|
||||
{
|
||||
point = new Point();
|
||||
}
|
||||
|
||||
point.x = this.x + this.width * 0.5;
|
||||
point.y = this.y + this.height * 0.5;
|
||||
|
||||
return point;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handy for reviving game objects.
|
||||
* Resets their existence flags and position.
|
||||
*
|
||||
* @param X The new X position of this object.
|
||||
* @param Y The new Y position of this object.
|
||||
*/
|
||||
public reset(X: number, Y: number) {
|
||||
|
||||
this.revive();
|
||||
this.touching = GameObject.NONE;
|
||||
this.wasTouching = GameObject.NONE;
|
||||
this.x = X;
|
||||
this.y = Y;
|
||||
this.last.x = X;
|
||||
this.last.y = Y;
|
||||
this.velocity.x = 0;
|
||||
this.velocity.y = 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handy for checking if this object is touching a particular surface.
|
||||
* For slightly better performance you can just & the value directly numbero <code>touching</code>.
|
||||
* However, this method is good for readability and accessibility.
|
||||
*
|
||||
* @param Direction Any of the collision flags (e.g. LEFT, FLOOR, etc).
|
||||
*
|
||||
* @return Whether the object is touching an object in (any of) the specified direction(s) this frame.
|
||||
*/
|
||||
public isTouching(Direction: number): bool {
|
||||
return (this.touching & Direction) > GameObject.NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handy for checking if this object is just landed on a particular surface.
|
||||
*
|
||||
* @param Direction Any of the collision flags (e.g. LEFT, FLOOR, etc).
|
||||
*
|
||||
* @return Whether the object just landed on (any of) the specified surface(s) this frame.
|
||||
*/
|
||||
public justTouched(Direction: number): bool {
|
||||
return ((this.touching & Direction) > GameObject.NONE) && ((this.wasTouching & Direction) <= GameObject.NONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reduces the "health" variable of this sprite by the amount specified in Damage.
|
||||
* Calls kill() if health drops to or below zero.
|
||||
*
|
||||
* @param Damage How much health to take away (use a negative number to give a health bonus).
|
||||
*/
|
||||
public hurt(Damage: number) {
|
||||
|
||||
this.health = this.health - Damage;
|
||||
|
||||
if (this.health <= 0)
|
||||
{
|
||||
this.kill();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public destroy() {
|
||||
|
||||
}
|
||||
|
||||
public get x(): number {
|
||||
return this.bounds.x;
|
||||
}
|
||||
|
||||
public set x(value: number) {
|
||||
this.bounds.x = value;
|
||||
}
|
||||
|
||||
public get y(): number {
|
||||
return this.bounds.y;
|
||||
}
|
||||
|
||||
public set y(value: number) {
|
||||
this.bounds.y = value;
|
||||
}
|
||||
|
||||
public get rotation(): number {
|
||||
return this._angle;
|
||||
}
|
||||
|
||||
public set rotation(value: number) {
|
||||
this._angle = this._game.math.wrap(value, 360, 0);
|
||||
}
|
||||
|
||||
public get angle(): number {
|
||||
return this._angle;
|
||||
}
|
||||
|
||||
public set angle(value: number) {
|
||||
this._angle = this._game.math.wrap(value, 360, 0);
|
||||
}
|
||||
|
||||
public get width(): number {
|
||||
return this.bounds.width;
|
||||
}
|
||||
|
||||
public get height(): number {
|
||||
return this.bounds.height;
|
||||
}
|
||||
|
||||
|
||||
}
|
742
Phaser/Group.ts
Normal file
|
@ -0,0 +1,742 @@
|
|||
/// <reference path="Basic.ts" />
|
||||
/// <reference path="Sprite.ts" />
|
||||
|
||||
/**
|
||||
* This is an organizational class that can update and render a bunch of <code>Basic</code>s.
|
||||
* NOTE: Although <code>Group</code> extends <code>Basic</code>, it will not automatically
|
||||
* add itself to the global collisions quad tree, it will only add its members.
|
||||
*
|
||||
* @author Adam Atomic
|
||||
* @author Richard Davey
|
||||
*/
|
||||
class Group extends Basic {
|
||||
|
||||
constructor(game: Game, MaxSize?: number = 0) {
|
||||
|
||||
super(game);
|
||||
|
||||
this.isGroup = true;
|
||||
this.members = [];
|
||||
this.length = 0;
|
||||
this._maxSize = MaxSize;
|
||||
this._marker = 0;
|
||||
this._sortIndex = null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Use with <code>sort()</code> to sort in ascending order.
|
||||
*/
|
||||
public static ASCENDING: number = -1;
|
||||
|
||||
/**
|
||||
* Use with <code>sort()</code> to sort in descending order.
|
||||
*/
|
||||
public static DESCENDING: number = 1;
|
||||
|
||||
/**
|
||||
* Array of all the <code>Basic</code>s that exist in this group.
|
||||
*/
|
||||
public members: Basic[];
|
||||
|
||||
/**
|
||||
* The number of entries in the members array.
|
||||
* For performance and safety you should check this variable
|
||||
* instead of members.length unless you really know what you're doing!
|
||||
*/
|
||||
public length: number;
|
||||
|
||||
/**
|
||||
* Internal tracker for the maximum capacity of the group.
|
||||
* Default is 0, or no max capacity.
|
||||
*/
|
||||
private _maxSize: number;
|
||||
|
||||
/**
|
||||
* Internal helper variable for recycling objects a la <code>FlxEmitter</code>.
|
||||
*/
|
||||
private _marker: number;
|
||||
|
||||
/**
|
||||
* Helper for sort.
|
||||
*/
|
||||
private _sortIndex: string;
|
||||
|
||||
/**
|
||||
* Helper for sort.
|
||||
*/
|
||||
private _sortOrder: number;
|
||||
|
||||
/**
|
||||
* Override this function to handle any deleting or "shutdown" type operations you might need,
|
||||
* such as removing traditional Flash children like Basic objects.
|
||||
*/
|
||||
public destroy() {
|
||||
|
||||
if (this.members != null)
|
||||
{
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if (basic != null)
|
||||
{
|
||||
basic.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
this.members.length = 0;
|
||||
}
|
||||
|
||||
this._sortIndex = null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically goes through and calls update on everything you added.
|
||||
*/
|
||||
public update() {
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if ((basic != null) && basic.exists && basic.active)
|
||||
{
|
||||
basic.preUpdate();
|
||||
basic.update();
|
||||
basic.postUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically goes through and calls render on everything you added.
|
||||
*/
|
||||
public render(camera:Camera, cameraOffsetX: number, cameraOffsetY: number) {
|
||||
|
||||
var basic:Basic;
|
||||
var i:number = 0;
|
||||
|
||||
while (i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if ((basic != null) && basic.exists && basic.visible)
|
||||
{
|
||||
basic.render(camera, cameraOffsetX, cameraOffsetY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The maximum capacity of this group. Default is 0, meaning no max capacity, and the group can just grow.
|
||||
*/
|
||||
public get maxSize(): number {
|
||||
return this._maxSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
public set maxSize(Size: number) {
|
||||
|
||||
this._maxSize = Size;
|
||||
|
||||
if (this._marker >= this._maxSize)
|
||||
{
|
||||
this._marker = 0;
|
||||
}
|
||||
|
||||
if ((this._maxSize == 0) || (this.members == null) || (this._maxSize >= this.members.length))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//If the max size has shrunk, we need to get rid of some objects
|
||||
var basic: Basic;
|
||||
var i: number = this._maxSize;
|
||||
var l: number = this.members.length;
|
||||
|
||||
while (i < l)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if (basic != null)
|
||||
{
|
||||
basic.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
this.length = this.members.length = this._maxSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new <code>Basic</code> subclass (Basic, FlxBasic, Enemy, etc) to the group.
|
||||
* Group will try to replace a null member of the array first.
|
||||
* Failing that, Group will add it to the end of the member array,
|
||||
* assuming there is room for it, and doubling the size of the array if necessary.
|
||||
*
|
||||
* <p>WARNING: If the group has a maxSize that has already been met,
|
||||
* the object will NOT be added to the group!</p>
|
||||
*
|
||||
* @param Object The object you want to add to the group.
|
||||
*
|
||||
* @return The same <code>Basic</code> object that was passed in.
|
||||
*/
|
||||
public add(Object: Basic) {
|
||||
|
||||
//Don't bother adding an object twice.
|
||||
if (this.members.indexOf(Object) >= 0)
|
||||
{
|
||||
return Object;
|
||||
}
|
||||
|
||||
//First, look for a null entry where we can add the object.
|
||||
var i: number = 0;
|
||||
var l: number = this.members.length;
|
||||
|
||||
while (i < l)
|
||||
{
|
||||
if (this.members[i] == null)
|
||||
{
|
||||
this.members[i] = Object;
|
||||
|
||||
if (i >= this.length)
|
||||
{
|
||||
this.length = i + 1;
|
||||
}
|
||||
|
||||
return Object;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
//Failing that, expand the array (if we can) and add the object.
|
||||
if (this._maxSize > 0)
|
||||
{
|
||||
if (this.members.length >= this._maxSize)
|
||||
{
|
||||
return Object;
|
||||
}
|
||||
else if (this.members.length * 2 <= this._maxSize)
|
||||
{
|
||||
this.members.length *= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.members.length = this._maxSize;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.members.length *= 2;
|
||||
}
|
||||
|
||||
//If we made it this far, then we successfully grew the group,
|
||||
//and we can go ahead and add the object at the first open slot.
|
||||
this.members[i] = Object;
|
||||
this.length = i + 1;
|
||||
|
||||
return Object;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Recycling is designed to help you reuse game objects without always re-allocating or "newing" them.
|
||||
*
|
||||
* <p>If you specified a maximum size for this group (like in Emitter),
|
||||
* then recycle will employ what we're calling "rotating" recycling.
|
||||
* Recycle() will first check to see if the group is at capacity yet.
|
||||
* If group is not yet at capacity, recycle() returns a new object.
|
||||
* If the group IS at capacity, then recycle() just returns the next object in line.</p>
|
||||
*
|
||||
* <p>If you did NOT specify a maximum size for this group,
|
||||
* then recycle() will employ what we're calling "grow-style" recycling.
|
||||
* Recycle() will return either the first object with exists == false,
|
||||
* or, finding none, add a new object to the array,
|
||||
* doubling the size of the array if necessary.</p>
|
||||
*
|
||||
* <p>WARNING: If this function needs to create a new object,
|
||||
* and no object class was provided, it will return null
|
||||
* instead of a valid object!</p>
|
||||
*
|
||||
* @param ObjectClass The class type you want to recycle (e.g. FlxBasic, EvilRobot, etc). Do NOT "new" the class in the parameter!
|
||||
*
|
||||
* @return A reference to the object that was created. Don't forget to cast it back to the Class you want (e.g. myObject = myGroup.recycle(myObjectClass) as myObjectClass;).
|
||||
*/
|
||||
public recycle(ObjectClass = null) {
|
||||
|
||||
var basic;
|
||||
|
||||
if (this._maxSize > 0)
|
||||
{
|
||||
if (this.length < this._maxSize)
|
||||
{
|
||||
if (ObjectClass == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.add(new ObjectClass());
|
||||
}
|
||||
else
|
||||
{
|
||||
basic = this.members[this._marker++];
|
||||
|
||||
if (this._marker >= this._maxSize)
|
||||
{
|
||||
this._marker = 0;
|
||||
}
|
||||
|
||||
return basic;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
basic = this.getFirstAvailable(ObjectClass);
|
||||
|
||||
if (basic != null)
|
||||
{
|
||||
return basic;
|
||||
}
|
||||
|
||||
if (ObjectClass == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.add(new ObjectClass());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an object from the group.
|
||||
*
|
||||
* @param Object The <code>Basic</code> you want to remove.
|
||||
* @param Splice Whether the object should be cut from the array entirely or not.
|
||||
*
|
||||
* @return The removed object.
|
||||
*/
|
||||
public remove(Object: Basic, Splice: bool = false): Basic {
|
||||
|
||||
var index: number = this.members.indexOf(Object);
|
||||
|
||||
if ((index < 0) || (index >= this.members.length))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (Splice)
|
||||
{
|
||||
this.members.splice(index, 1);
|
||||
this.length--;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.members[index] = null;
|
||||
}
|
||||
|
||||
return Object;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces an existing <code>Basic</code> with a new one.
|
||||
*
|
||||
* @param OldObject The object you want to replace.
|
||||
* @param NewObject The new object you want to use instead.
|
||||
*
|
||||
* @return The new object.
|
||||
*/
|
||||
public replace(OldObject: Basic, NewObject: Basic): Basic {
|
||||
|
||||
var index: number = this.members.indexOf(OldObject);
|
||||
|
||||
if ((index < 0) || (index >= this.members.length))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
this.members[index] = NewObject;
|
||||
|
||||
return NewObject;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this function to sort the group according to a particular value and order.
|
||||
* For example, to sort game objects for Zelda-style overlaps you might call
|
||||
* <code>myGroup.sort("y",Group.ASCENDING)</code> at the bottom of your
|
||||
* <code>FlxState.update()</code> override. To sort all existing objects after
|
||||
* a big explosion or bomb attack, you might call <code>myGroup.sort("exists",Group.DESCENDING)</code>.
|
||||
*
|
||||
* @param Index The <code>string</code> name of the member variable you want to sort on. Default value is "y".
|
||||
* @param Order A <code>Group</code> constant that defines the sort order. Possible values are <code>Group.ASCENDING</code> and <code>Group.DESCENDING</code>. Default value is <code>Group.ASCENDING</code>.
|
||||
*/
|
||||
public sort(Index: string = "y", Order: number = Group.ASCENDING) {
|
||||
|
||||
this._sortIndex = Index;
|
||||
this._sortOrder = Order;
|
||||
this.members.sort(this.sortHandler);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Go through and set the specified variable to the specified value on all members of the group.
|
||||
*
|
||||
* @param VariableName The string representation of the variable name you want to modify, for example "visible" or "scrollFactor".
|
||||
* @param Value The value you want to assign to that variable.
|
||||
* @param Recurse Default value is true, meaning if <code>setAll()</code> encounters a member that is a group, it will call <code>setAll()</code> on that group rather than modifying its variable.
|
||||
*/
|
||||
public setAll(VariableName: string, Value: Object, Recurse: bool = true) {
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if (basic != null)
|
||||
{
|
||||
if (Recurse && (basic.isGroup == true))
|
||||
{
|
||||
<Group> basic['setAll'](VariableName, Value, Recurse);
|
||||
}
|
||||
else
|
||||
{
|
||||
basic[VariableName] = Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Go through and call the specified function on all members of the group.
|
||||
* Currently only works on functions that have no required parameters.
|
||||
*
|
||||
* @param FunctionName The string representation of the function you want to call on each object, for example "kill()" or "init()".
|
||||
* @param Recurse Default value is true, meaning if <code>callAll()</code> encounters a member that is a group, it will call <code>callAll()</code> on that group rather than calling the group's function.
|
||||
*/
|
||||
public callAll(FunctionName: string, Recurse: bool = true) {
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if (basic != null)
|
||||
{
|
||||
if (Recurse && (basic.isGroup == true))
|
||||
{
|
||||
<Group> basic['callAll'](FunctionName, Recurse);
|
||||
}
|
||||
else
|
||||
{
|
||||
basic[FunctionName]();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public forEach(callback, Recurse: bool = false) {
|
||||
|
||||
var basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if (basic != null)
|
||||
{
|
||||
if (Recurse && (basic.isGroup == true))
|
||||
{
|
||||
basic.forEach(callback, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
callback.call(this, basic);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this function to retrieve the first object with exists == false in the group.
|
||||
* This is handy for recycling in general, e.g. respawning enemies.
|
||||
*
|
||||
* @param ObjectClass An optional parameter that lets you narrow the results to instances of this particular class.
|
||||
*
|
||||
* @return A <code>Basic</code> currently flagged as not existing.
|
||||
*/
|
||||
public getFirstAvailable(ObjectClass = null) {
|
||||
|
||||
var basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if ((basic != null) && !basic.exists && ((ObjectClass == null) || (typeof basic === ObjectClass)))
|
||||
{
|
||||
return basic;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this function to retrieve the first index set to 'null'.
|
||||
* Returns -1 if no index stores a null object.
|
||||
*
|
||||
* @return An <code>int</code> indicating the first null slot in the group.
|
||||
*/
|
||||
public getFirstNull(): number {
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
var l: number = this.members.length;
|
||||
|
||||
while (i < l)
|
||||
{
|
||||
if (this.members[i] == null)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this function to retrieve the first object with exists == true in the group.
|
||||
* This is handy for checking if everything's wiped out, or choosing a squad leader, etc.
|
||||
*
|
||||
* @return A <code>Basic</code> currently flagged as existing.
|
||||
*/
|
||||
public getFirstExtant(): Basic {
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if ((basic != null) && basic.exists)
|
||||
{
|
||||
return basic;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this function to retrieve the first object with dead == false in the group.
|
||||
* This is handy for checking if everything's wiped out, or choosing a squad leader, etc.
|
||||
*
|
||||
* @return A <code>Basic</code> currently flagged as not dead.
|
||||
*/
|
||||
public getFirstAlive(): Basic {
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if ((basic != null) && basic.exists && basic.alive)
|
||||
{
|
||||
return basic;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this function to retrieve the first object with dead == true in the group.
|
||||
* This is handy for checking if everything's wiped out, or choosing a squad leader, etc.
|
||||
*
|
||||
* @return A <code>Basic</code> currently flagged as dead.
|
||||
*/
|
||||
public getFirstDead(): Basic {
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if ((basic != null) && !basic.alive)
|
||||
{
|
||||
return basic;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this function to find out how many members of the group are not dead.
|
||||
*
|
||||
* @return The number of <code>Basic</code>s flagged as not dead. Returns -1 if group is empty.
|
||||
*/
|
||||
public countLiving(): number {
|
||||
|
||||
var count: number = -1;
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if (basic != null)
|
||||
{
|
||||
if (count < 0)
|
||||
{
|
||||
count = 0;
|
||||
}
|
||||
|
||||
if (basic.exists && basic.alive)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this function to find out how many members of the group are dead.
|
||||
*
|
||||
* @return The number of <code>Basic</code>s flagged as dead. Returns -1 if group is empty.
|
||||
*/
|
||||
public countDead(): number {
|
||||
|
||||
var count: number = -1;
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if (basic != null)
|
||||
{
|
||||
if (count < 0)
|
||||
{
|
||||
count = 0;
|
||||
}
|
||||
|
||||
if (!basic.alive)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a member at random from the group.
|
||||
*
|
||||
* @param StartIndex Optional offset off the front of the array. Default value is 0, or the beginning of the array.
|
||||
* @param Length Optional restriction on the number of values you want to randomly select from.
|
||||
*
|
||||
* @return A <code>Basic</code> from the members list.
|
||||
*/
|
||||
public getRandom(StartIndex: number = 0, Length: number = 0): Basic {
|
||||
|
||||
if (Length == 0)
|
||||
{
|
||||
Length = this.length;
|
||||
}
|
||||
|
||||
return this._game.math.getRandom(this.members, StartIndex, Length);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all instances of <code>Basic</code> subclass (FlxBasic, FlxBlock, etc) from the list.
|
||||
* WARNING: does not destroy() or kill() any of these objects!
|
||||
*/
|
||||
public clear() {
|
||||
this.length = this.members.length = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls kill on the group's members and then on the group itself.
|
||||
*/
|
||||
public kill() {
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if ((basic != null) && basic.exists)
|
||||
{
|
||||
basic.kill();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for the sort process.
|
||||
*
|
||||
* @param Obj1 The first object being sorted.
|
||||
* @param Obj2 The second object being sorted.
|
||||
*
|
||||
* @return An integer value: -1 (Obj1 before Obj2), 0 (same), or 1 (Obj1 after Obj2).
|
||||
*/
|
||||
public sortHandler(Obj1: Basic, Obj2: Basic): number {
|
||||
|
||||
if (Obj1[this._sortIndex] < Obj2[this._sortIndex])
|
||||
{
|
||||
return this._sortOrder;
|
||||
}
|
||||
else if (Obj1[this._sortIndex] > Obj2[this._sortIndex])
|
||||
{
|
||||
return -this._sortOrder;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
329
Phaser/Loader.ts
Normal file
|
@ -0,0 +1,329 @@
|
|||
/// <reference path="Cache.ts" />
|
||||
|
||||
class Loader {
|
||||
|
||||
constructor(game: Game, callback) {
|
||||
|
||||
this._game = game;
|
||||
this._gameCreateComplete = callback;
|
||||
this._keys = [];
|
||||
this._fileList = {};
|
||||
this._xhr = new XMLHttpRequest();
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
private _keys: string [];
|
||||
private _fileList;
|
||||
private _gameCreateComplete;
|
||||
private _onComplete;
|
||||
private _onFileLoad;
|
||||
private _progressChunk: number;
|
||||
private _xhr: XMLHttpRequest;
|
||||
|
||||
public hasLoaded: bool;
|
||||
public progress: number;
|
||||
|
||||
private checkKeyExists(key: string): bool {
|
||||
|
||||
if (this._fileList[key])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public addImageFile(key:string, url: string) {
|
||||
|
||||
if (this.checkKeyExists(key) === false)
|
||||
{
|
||||
this._fileList[key] = { type: 'image', key: key, url: url, data: null, error: false, loaded: false };
|
||||
this._keys.push(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public addSpriteSheet(key:string, url: string, frameWidth:number, frameHeight:number, frameMax?:number = -1) {
|
||||
|
||||
if (this.checkKeyExists(key) === false)
|
||||
{
|
||||
this._fileList[key] = { type: 'spritesheet', key: key, url: url, data: null, frameWidth: frameWidth, frameHeight: frameHeight, frameMax: frameMax, error: false, loaded: false };
|
||||
this._keys.push(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public addTextureAtlas(key: string, url: string, jsonURL?:string = null, jsonData? = null) {
|
||||
|
||||
//console.log('addTextureAtlas');
|
||||
//console.log(typeof jsonData);
|
||||
|
||||
if (this.checkKeyExists(key) === false)
|
||||
{
|
||||
if (jsonURL !== null)
|
||||
{
|
||||
//console.log('A URL to a json file has been given');
|
||||
// A URL to a json file has been given
|
||||
this._fileList[key] = { type: 'textureatlas', key: key, url: url, data: null, jsonURL: jsonURL, jsonData: null, error: false, loaded: false };
|
||||
this._keys.push(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
// A json string or object has been given
|
||||
if (typeof jsonData === 'string')
|
||||
{
|
||||
//console.log('A json string has been given');
|
||||
var data = JSON.parse(jsonData);
|
||||
//console.log(data);
|
||||
// Malformed?
|
||||
if (data['frames'])
|
||||
{
|
||||
//console.log('frames array found');
|
||||
this._fileList[key] = { type: 'textureatlas', key: key, url: url, data: null, jsonURL: null, jsonData: data['frames'], error: false, loaded: false };
|
||||
this._keys.push(key);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//console.log('A json object has been given', jsonData);
|
||||
// Malformed?
|
||||
if (jsonData['frames'])
|
||||
{
|
||||
//console.log('frames array found');
|
||||
this._fileList[key] = { type: 'textureatlas', key: key, url: url, data: null, jsonURL: null, jsonData: jsonData['frames'], error: false, loaded: false };
|
||||
this._keys.push(key);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public addAudioFile(key:string, url: string) {
|
||||
|
||||
if (this.checkKeyExists(key) === false)
|
||||
{
|
||||
this._fileList[key] = { type: 'audio', key: key, url: url, data: null, buffer: null, error: false, loaded: false };
|
||||
this._keys.push(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public addTextFile(key:string, url: string) {
|
||||
|
||||
if (this.checkKeyExists(key) === false)
|
||||
{
|
||||
this._fileList[key] = { type: 'text', key: key, url: url, data: null, error: false, loaded: false };
|
||||
this._keys.push(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public removeFile(key: string) {
|
||||
|
||||
delete this._fileList[key];
|
||||
|
||||
}
|
||||
|
||||
public removeAll() {
|
||||
|
||||
this._fileList = {};
|
||||
|
||||
}
|
||||
|
||||
public load(onFileLoadCallback = null, onCompleteCallback = null) {
|
||||
|
||||
this.progress = 0;
|
||||
this.hasLoaded = false;
|
||||
|
||||
this._onComplete = onCompleteCallback;
|
||||
|
||||
if (onCompleteCallback == null)
|
||||
{
|
||||
this._onComplete = this._game.onCreateCallback;
|
||||
}
|
||||
|
||||
this._onFileLoad = onFileLoadCallback;
|
||||
|
||||
if (this._keys.length > 0)
|
||||
{
|
||||
this._progressChunk = 100 / this._keys.length;
|
||||
this.loadFile();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.progress = 1;
|
||||
this.hasLoaded = true;
|
||||
this._gameCreateComplete.call(this._game);
|
||||
|
||||
if (this._onComplete !== null)
|
||||
{
|
||||
this._onComplete.call(this._game.callbackContext);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private loadFile() {
|
||||
|
||||
var file = this._fileList[this._keys.pop()];
|
||||
|
||||
// Image or Data?
|
||||
|
||||
switch (file.type)
|
||||
{
|
||||
case 'image':
|
||||
case 'spritesheet':
|
||||
case 'textureatlas':
|
||||
file.data = new Image();
|
||||
file.data.name = file.key;
|
||||
file.data.onload = () => this.fileComplete(file.key);
|
||||
file.data.onerror = () => this.fileError(file.key);
|
||||
file.data.src = file.url;
|
||||
break;
|
||||
|
||||
case 'audio':
|
||||
this._xhr.open("GET", file.url, true);
|
||||
this._xhr.responseType = "arraybuffer";
|
||||
this._xhr.onload = () => this.fileComplete(file.key);
|
||||
this._xhr.onerror = () => this.fileError(file.key);
|
||||
this._xhr.send();
|
||||
break;
|
||||
|
||||
case 'text':
|
||||
this._xhr.open("GET", file.url, true);
|
||||
this._xhr.responseType = "text";
|
||||
this._xhr.onload = () => this.fileComplete(file.key);
|
||||
this._xhr.onerror = () => this.fileError(file.key);
|
||||
this._xhr.send();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fileError(key: string) {
|
||||
|
||||
this._fileList[key].loaded = true;
|
||||
this._fileList[key].error = true;
|
||||
|
||||
this.nextFile(key, false);
|
||||
|
||||
}
|
||||
|
||||
private fileComplete(key:string) {
|
||||
|
||||
this._fileList[key].loaded = true;
|
||||
|
||||
var file = this._fileList[key];
|
||||
var loadNext: bool = true;
|
||||
|
||||
switch (file.type)
|
||||
{
|
||||
case 'image':
|
||||
this._game.cache.addImage(file.key, file.url, file.data);
|
||||
break;
|
||||
|
||||
case 'spritesheet':
|
||||
this._game.cache.addSpriteSheet(file.key, file.url, file.data, file.frameWidth, file.frameHeight, file.frameMax);
|
||||
break;
|
||||
|
||||
case 'textureatlas':
|
||||
//console.log('texture atlas loaded');
|
||||
if (file.jsonURL == null)
|
||||
{
|
||||
this._game.cache.addTextureAtlas(file.key, file.url, file.data, file.jsonData);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Load the JSON before carrying on with the next file
|
||||
//console.log('Loading the JSON before carrying on with the next file');
|
||||
loadNext = false;
|
||||
this._xhr.open("GET", file.jsonURL, true);
|
||||
this._xhr.responseType = "text";
|
||||
this._xhr.onload = () => this.jsonLoadComplete(file.key);
|
||||
this._xhr.onerror = () => this.jsonLoadError(file.key);
|
||||
this._xhr.send();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'audio':
|
||||
file.data = this._xhr.response;
|
||||
this._game.cache.addSound(file.key, file.url, file.data);
|
||||
break;
|
||||
|
||||
case 'text':
|
||||
file.data = this._xhr.response;
|
||||
this._game.cache.addText(file.key, file.url, file.data);
|
||||
break;
|
||||
}
|
||||
|
||||
if (loadNext)
|
||||
{
|
||||
this.nextFile(key, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private jsonLoadComplete(key:string) {
|
||||
|
||||
//console.log('json load complete');
|
||||
|
||||
var data = JSON.parse(this._xhr.response);
|
||||
|
||||
//console.log(data);
|
||||
|
||||
// Malformed?
|
||||
if (data['frames'])
|
||||
{
|
||||
var file = this._fileList[key];
|
||||
this._game.cache.addTextureAtlas(file.key, file.url, file.data, data['frames']);
|
||||
}
|
||||
|
||||
this.nextFile(key, true);
|
||||
|
||||
}
|
||||
|
||||
private jsonLoadError(key:string) {
|
||||
|
||||
//console.log('json load error');
|
||||
|
||||
var file = this._fileList[key];
|
||||
file.error = true;
|
||||
this.nextFile(key, true);
|
||||
|
||||
}
|
||||
|
||||
private nextFile(previousKey:string, success:bool) {
|
||||
|
||||
this.progress = Math.round(this.progress + this._progressChunk);
|
||||
|
||||
if (this._onFileLoad)
|
||||
{
|
||||
this._onFileLoad.call(this._game.callbackContext, this.progress, previousKey, success);
|
||||
}
|
||||
|
||||
if (this._keys.length > 0)
|
||||
{
|
||||
this.loadFile();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.hasLoaded = true;
|
||||
this.removeAll();
|
||||
this._gameCreateComplete.call(this._game);
|
||||
|
||||
if (this._onComplete !== null)
|
||||
{
|
||||
this._onComplete.call(this._game.callbackContext);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
104
Phaser/Particle.ts
Normal file
|
@ -0,0 +1,104 @@
|
|||
/// <reference path="Sprite.ts" />
|
||||
|
||||
/**
|
||||
* This is a simple particle class that extends the default behavior
|
||||
* of <code>Sprite</code> to have slightly more specialized behavior
|
||||
* common to many game scenarios. You can override and extend this class
|
||||
* just like you would <code>Sprite</code>. While <code>Emitter</code>
|
||||
* used to work with just any old sprite, it now requires a
|
||||
* <code>Particle</code> based class.
|
||||
*
|
||||
* @author Adam Atomic
|
||||
* @author Richard Davey
|
||||
*/
|
||||
class Particle extends Sprite {
|
||||
|
||||
/**
|
||||
* Instantiate a new particle. Like <code>Sprite</code>, all meaningful creation
|
||||
* happens during <code>loadGraphic()</code> or <code>makeGraphic()</code> or whatever.
|
||||
*/
|
||||
constructor(game: Game) {
|
||||
|
||||
super(game);
|
||||
|
||||
this.lifespan = 0;
|
||||
this.friction = 500;
|
||||
}
|
||||
|
||||
/**
|
||||
* How long this particle lives before it disappears.
|
||||
* NOTE: this is a maximum, not a minimum; the object
|
||||
* could get recycled before its lifespan is up.
|
||||
*/
|
||||
public lifespan: number;
|
||||
|
||||
/**
|
||||
* Determines how quickly the particles come to rest on the ground.
|
||||
* Only used if the particle has gravity-like acceleration applied.
|
||||
* @default 500
|
||||
*/
|
||||
public friction: number;
|
||||
|
||||
/**
|
||||
* The particle's main update logic. Basically it checks to see if it should
|
||||
* be dead yet, and then has some special bounce behavior if there is some gravity on it.
|
||||
*/
|
||||
public update() {
|
||||
//lifespan behavior
|
||||
if (this.lifespan <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.lifespan -= this._game.time.elapsed;
|
||||
|
||||
if (this.lifespan <= 0)
|
||||
{
|
||||
this.kill();
|
||||
}
|
||||
|
||||
//simpler bounce/spin behavior for now
|
||||
if (this.touching)
|
||||
{
|
||||
if (this.angularVelocity != 0)
|
||||
{
|
||||
this.angularVelocity = -this.angularVelocity;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.acceleration.y > 0) //special behavior for particles with gravity
|
||||
{
|
||||
if (this.touching & GameObject.FLOOR)
|
||||
{
|
||||
this.drag.x = this.friction;
|
||||
|
||||
if (!(this.wasTouching & GameObject.FLOOR))
|
||||
{
|
||||
if (this.velocity.y < -this.elasticity * 10)
|
||||
{
|
||||
if (this.angularVelocity != 0)
|
||||
{
|
||||
this.angularVelocity *= -this.elasticity;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.velocity.y = 0;
|
||||
this.angularVelocity = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.drag.x = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggered whenever this object is launched by a <code>Emitter</code>.
|
||||
* You can override this to add custom behavior like a sound or AI or something.
|
||||
*/
|
||||
public onEmit() {
|
||||
}
|
||||
}
|
97
Phaser/Phaser.csproj
Normal file
|
@ -0,0 +1,97 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<ProjectGuid>{A90BE60F-CAEA-4747-904A-CDB097BA2459}</ProjectGuid>
|
||||
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<OutputPath>bin</OutputPath>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<DebugType>full</DebugType>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<UseIISExpress>true</UseIISExpress>
|
||||
<IISExpressSSLPort />
|
||||
<IISExpressAnonymousAuthentication />
|
||||
<IISExpressWindowsAuthentication />
|
||||
<IISExpressUseClassicPipelineMode />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<RootNamespace>Phaser</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
||||
<WebProjectProperties>
|
||||
<UseIIS>True</UseIIS>
|
||||
<AutoAssignPort>True</AutoAssignPort>
|
||||
<DevelopmentServerPort>0</DevelopmentServerPort>
|
||||
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||
<IISUrl>http://localhost:51891/</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
<UseCustomServer>False</UseCustomServer>
|
||||
<CustomServerUrl>
|
||||
</CustomServerUrl>
|
||||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||
</WebProjectProperties>
|
||||
</FlavorProperties>
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
|
||||
<TypeScriptTarget>ES5</TypeScriptTarget>
|
||||
<TypeScriptIncludeComments>true</TypeScriptIncludeComments>
|
||||
<TypeScriptSourceMap>false</TypeScriptSourceMap>
|
||||
<TypeScriptOutFile>phaser.js</TypeScriptOutFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
|
||||
<TypeScriptTarget>ES5</TypeScriptTarget>
|
||||
<TypeScriptIncludeComments>false</TypeScriptIncludeComments>
|
||||
<TypeScriptSourceMap>true</TypeScriptSourceMap>
|
||||
<TypeScriptOutFile>phaser.js</TypeScriptOutFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<TypeScriptCompile Include="Animations.ts" />
|
||||
<TypeScriptCompile Include="Basic.ts" />
|
||||
<TypeScriptCompile Include="Cache.ts" />
|
||||
<TypeScriptCompile Include="Cameras.ts" />
|
||||
<TypeScriptCompile Include="Emitter.ts" />
|
||||
<TypeScriptCompile Include="Game.ts" />
|
||||
<TypeScriptCompile Include="GameMath.ts" />
|
||||
<TypeScriptCompile Include="GameObject.ts" />
|
||||
<TypeScriptCompile Include="Group.ts" />
|
||||
<TypeScriptCompile Include="Loader.ts" />
|
||||
<TypeScriptCompile Include="Particle.ts" />
|
||||
<TypeScriptCompile Include="Point.ts" />
|
||||
<TypeScriptCompile Include="Rectangle.ts" />
|
||||
<TypeScriptCompile Include="Sound.ts" />
|
||||
<TypeScriptCompile Include="Sprite.ts" />
|
||||
<TypeScriptCompile Include="Stage.ts" />
|
||||
<TypeScriptCompile Include="State.ts" />
|
||||
<TypeScriptCompile Include="system\animation\Animation.ts" />
|
||||
<TypeScriptCompile Include="system\animation\AnimationLoader.ts" />
|
||||
<TypeScriptCompile Include="system\animation\Frame.ts" />
|
||||
<TypeScriptCompile Include="system\animation\FrameData.ts" />
|
||||
<TypeScriptCompile Include="system\Camera.ts" />
|
||||
<TypeScriptCompile Include="system\input\Input.ts" />
|
||||
<TypeScriptCompile Include="system\input\Keyboard.ts" />
|
||||
<TypeScriptCompile Include="system\input\Mouse.ts" />
|
||||
<TypeScriptCompile Include="system\LinkedList.ts" />
|
||||
<TypeScriptCompile Include="system\QuadTree.ts" />
|
||||
<TypeScriptCompile Include="system\RequestAnimationFrame.ts" />
|
||||
<TypeScriptCompile Include="system\Tile.ts" />
|
||||
<TypeScriptCompile Include="system\TilemapBuffer.ts" />
|
||||
<TypeScriptCompile Include="Tilemap.ts" />
|
||||
<TypeScriptCompile Include="Time.ts" />
|
||||
<TypeScriptCompile Include="World.ts" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\TypeScript\Microsoft.TypeScript.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>cd $(ProjectDir)
|
||||
copy $(ProjectDir)phaser.js ..\Tests\</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
339
Phaser/Point.ts
Normal file
|
@ -0,0 +1,339 @@
|
|||
/**
|
||||
* Point
|
||||
*
|
||||
* @desc The Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal axis and y represents the vertical axis.
|
||||
*
|
||||
* @version 1.2 - 27th February 2013
|
||||
* @author Richard Davey
|
||||
* @todo polar, interpolate
|
||||
*/
|
||||
|
||||
class Point {
|
||||
|
||||
/**
|
||||
* Creates a new point. If you pass no parameters to this method, a point is created at (0,0).
|
||||
* @class Point
|
||||
* @constructor
|
||||
* @param {Number} x One-liner. Default is ?.
|
||||
* @param {Number} y One-liner. Default is ?.
|
||||
**/
|
||||
constructor(x: number = 0, y: number = 0) {
|
||||
|
||||
this.setTo(x, y);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The horizontal position of this point (default 0)
|
||||
* @property x
|
||||
* @type Number
|
||||
**/
|
||||
public x: number;
|
||||
|
||||
/**
|
||||
* The vertical position of this point (default 0)
|
||||
* @property y
|
||||
* @type Number
|
||||
**/
|
||||
public y: number;
|
||||
|
||||
/**
|
||||
* Adds the coordinates of another point to the coordinates of this point to create a new point.
|
||||
* @method add
|
||||
* @param {Point} point - The point to be added.
|
||||
* @return {Point} The new Point object.
|
||||
**/
|
||||
public add(toAdd: Point, output?: Point = new Point): Point {
|
||||
|
||||
return output.setTo(this.x + toAdd.x, this.y + toAdd.y);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given values to the coordinates of this point and returns it
|
||||
* @method addTo
|
||||
* @param {Number} x - The amount to add to the x value of the point
|
||||
* @param {Number} y - The amount to add to the x value of the point
|
||||
* @return {Point} This Point object.
|
||||
**/
|
||||
public addTo(x?: number = 0, y?: number = 0): Point {
|
||||
|
||||
return this.setTo(this.x + x, this.y + y);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given values to the coordinates of this point and returns it
|
||||
* @method addTo
|
||||
* @param {Number} x - The amount to add to the x value of the point
|
||||
* @param {Number} y - The amount to add to the x value of the point
|
||||
* @return {Point} This Point object.
|
||||
**/
|
||||
public subtractFrom(x?: number = 0, y?: number = 0): Point {
|
||||
|
||||
return this.setTo(this.x - x, this.y - y);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Inverts the x and y values of this point
|
||||
* @method invert
|
||||
* @return {Point} This Point object.
|
||||
**/
|
||||
public invert(): Point {
|
||||
|
||||
return this.setTo(this.y, this.x);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clamps this Point object to be between the given min and max
|
||||
* @method clamp
|
||||
* @param {number} The minimum value to clamp this Point to
|
||||
* @param {number} The maximum value to clamp this Point to
|
||||
* @return {Point} This Point object.
|
||||
**/
|
||||
public clamp(min: number, max: number): Point {
|
||||
|
||||
this.clampX(min, max);
|
||||
this.clampY(min, max);
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clamps the x value of this Point object to be between the given min and max
|
||||
* @method clampX
|
||||
* @param {number} The minimum value to clamp this Point to
|
||||
* @param {number} The maximum value to clamp this Point to
|
||||
* @return {Point} This Point object.
|
||||
**/
|
||||
public clampX(min: number, max: number): Point {
|
||||
|
||||
this.x = Math.max(Math.min(this.x, max), min);
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clamps the y value of this Point object to be between the given min and max
|
||||
* @method clampY
|
||||
* @param {number} The minimum value to clamp this Point to
|
||||
* @param {number} The maximum value to clamp this Point to
|
||||
* @return {Point} This Point object.
|
||||
**/
|
||||
public clampY(min: number, max: number): Point {
|
||||
|
||||
this.x = Math.max(Math.min(this.x, max), min);
|
||||
this.y = Math.max(Math.min(this.y, max), min);
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy of this Point.
|
||||
* @method clone
|
||||
* @param {Point} output Optional Point object. If given the values will be set into this object, otherwise a brand new Point object will be created and returned.
|
||||
* @return {Point} The new Point object.
|
||||
**/
|
||||
public clone(output?: Point = new Point): Point {
|
||||
|
||||
return output.setTo(this.x, this.y);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the point data from the source Point object into this Point object.
|
||||
* @method copyFrom
|
||||
* @param {Point} source - The point to copy from.
|
||||
* @return {Point} This Point object. Useful for chaining method calls.
|
||||
**/
|
||||
public copyFrom(source: Point): Point {
|
||||
|
||||
return this.setTo(source.x, source.y);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the point data from this Point object to the given target Point object.
|
||||
* @method copyTo
|
||||
* @param {Point} target - The point to copy to.
|
||||
* @return {Point} The target Point object.
|
||||
**/
|
||||
public copyTo(target: Point): Point {
|
||||
|
||||
return target.setTo(this.x, this.y);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the distance from this Point object to the given Point object.
|
||||
* @method distanceFrom
|
||||
* @param {Point} target - The destination Point object.
|
||||
* @param {Boolean} round - Round the distance to the nearest integer (default false)
|
||||
* @return {Number} The distance between this Point object and the destination Point object.
|
||||
**/
|
||||
public distanceTo(target: Point, round?: bool = false): number {
|
||||
|
||||
var dx = this.x - target.x;
|
||||
var dy = this.y - target.y;
|
||||
|
||||
if (round === true)
|
||||
{
|
||||
return Math.round(Math.sqrt(dx * dx + dy * dy));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Math.sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the distance between the two Point objects.
|
||||
* @method distanceBetween
|
||||
* @param {Point} pointA - The first Point object.
|
||||
* @param {Point} pointB - The second Point object.
|
||||
* @param {Boolean} round - Round the distance to the nearest integer (default false)
|
||||
* @return {Number} The distance between the two Point objects.
|
||||
**/
|
||||
public static distanceBetween(pointA: Point, pointB: Point, round?: bool = false): number {
|
||||
|
||||
var dx: number = pointA.x - pointB.x;
|
||||
var dy: number = pointA.y - pointB.y;
|
||||
|
||||
if (round === true)
|
||||
{
|
||||
return Math.round(Math.sqrt(dx * dx + dy * dy));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Math.sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the distance between this point and a target point is greater than or equal a specified distance.
|
||||
* This avoids using a costly square root operation
|
||||
* @method distanceCompare
|
||||
* @param {Point} target - The Point object to use for comparison.
|
||||
* @param {Number} distance - The distance to use for comparison.
|
||||
* @return {Boolena} True if distance is >= specified distance.
|
||||
**/
|
||||
public distanceCompare(target: Point, distance: number): bool {
|
||||
|
||||
if (this.distanceTo(target) >= distance)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether this Point object and the given point object are equal. They are equal if they have the same x and y values.
|
||||
* @method equals
|
||||
* @param {Point} point - The point to compare against.
|
||||
* @return {Boolean} A value of true if the object is equal to this Point object; false if it is not equal.
|
||||
**/
|
||||
public equals(toCompare: Point): bool {
|
||||
|
||||
if (this.x === toCompare.x && this.y === toCompare.y)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines a point between two specified points. The parameter f determines where the new interpolated point is located relative to the two end points specified by parameters pt1 and pt2.
|
||||
* The closer the value of the parameter f is to 1.0, the closer the interpolated point is to the first point (parameter pt1). The closer the value of the parameter f is to 0, the closer the interpolated point is to the second point (parameter pt2).
|
||||
* @method interpolate
|
||||
* @param {Point} pointA - The first Point object.
|
||||
* @param {Point} pointB - The second Point object.
|
||||
* @param {Number} f - The level of interpolation between the two points. Indicates where the new point will be, along the line between pt1 and pt2. If f=1, pt1 is returned; if f=0, pt2 is returned.
|
||||
* @return {Point} The new interpolated Point object.
|
||||
**/
|
||||
public interpolate(pointA, pointB, f) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Offsets the Point object by the specified amount. The value of dx is added to the original value of x to create the new x value.
|
||||
* The value of dy is added to the original value of y to create the new y value.
|
||||
* @method offset
|
||||
* @param {Number} dx - The amount by which to offset the horizontal coordinate, x.
|
||||
* @param {Number} dy - The amount by which to offset the vertical coordinate, y.
|
||||
* @return {Point} This Point object. Useful for chaining method calls.
|
||||
**/
|
||||
public offset(dx: number, dy: number): Point {
|
||||
|
||||
this.x += dx;
|
||||
this.y += dy;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a pair of polar coordinates to a Cartesian point coordinate.
|
||||
* @method polar
|
||||
* @param {Number} length - The length coordinate of the polar pair.
|
||||
* @param {Number} angle - The angle, in radians, of the polar pair.
|
||||
* @return {Point} The new Cartesian Point object.
|
||||
**/
|
||||
public polar(length, angle) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the x and y values of this Point object to the given coordinates.
|
||||
* @method set
|
||||
* @param {Number} x - The horizontal position of this point.
|
||||
* @param {Number} y - The vertical position of this point.
|
||||
* @return {Point} This Point object. Useful for chaining method calls.
|
||||
**/
|
||||
public setTo(x: number, y: number): Point {
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtracts the coordinates of another point from the coordinates of this point to create a new point.
|
||||
* @method subtract
|
||||
* @param {Point} point - The point to be subtracted.
|
||||
* @param {Point} output Optional Point object. If given the values will be set into this object, otherwise a brand new Point object will be created and returned.
|
||||
* @return {Point} The new Point object.
|
||||
**/
|
||||
public subtract(point: Point, output?: Point = new Point): Point {
|
||||
|
||||
return output.setTo(this.x - point.x, this.y - point.y);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this object.
|
||||
* @method toString
|
||||
* @return {string} a string representation of the instance.
|
||||
**/
|
||||
public toString(): string {
|
||||
|
||||
return '[{Point (x=' + this.x + ' y=' + this.y + ')}]';
|
||||
|
||||
}
|
||||
|
||||
}
|
604
Phaser/Rectangle.ts
Normal file
|
@ -0,0 +1,604 @@
|
|||
/// <reference path="Point.ts" />
|
||||
|
||||
/**
|
||||
* Rectangle
|
||||
*
|
||||
* @desc A Rectangle object is an area defined by its position, as indicated by its top-left corner (x,y) and width and height.
|
||||
*
|
||||
* @version 1.2 - 15th October 2012
|
||||
* @author Richard Davey
|
||||
*/
|
||||
|
||||
class Rectangle {
|
||||
|
||||
/**
|
||||
* Creates a new Rectangle object with the top-left corner specified by the x and y parameters and with the specified width and height parameters. If you call this function without parameters, a rectangle with x, y, width, and height properties set to 0 is created.
|
||||
* @class Rectangle
|
||||
* @constructor
|
||||
* @param {Number} x The x coordinate of the top-left corner of the rectangle.
|
||||
* @param {Number} y The y coordinate of the top-left corner of the rectangle.
|
||||
* @param {Number} width The width of the rectangle in pixels.
|
||||
* @param {Number} height The height of the rectangle in pixels.
|
||||
* @return {Rectangle} This rectangle object
|
||||
**/
|
||||
constructor(x: number = 0, y: number = 0, width: number = 0, height: number = 0) {
|
||||
|
||||
this.setTo(x, y, width, height);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The x coordinate of the top-left corner of the rectangle
|
||||
* @property x
|
||||
* @type Number
|
||||
**/
|
||||
x: number = 0;
|
||||
|
||||
/**
|
||||
* The y coordinate of the top-left corner of the rectangle
|
||||
* @property y
|
||||
* @type Number
|
||||
**/
|
||||
y: number = 0;
|
||||
|
||||
/**
|
||||
* The width of the rectangle in pixels
|
||||
* @property width
|
||||
* @type Number
|
||||
**/
|
||||
width: number = 0;
|
||||
|
||||
/**
|
||||
* The height of the rectangle in pixels
|
||||
* @property height
|
||||
* @type Number
|
||||
**/
|
||||
height: number = 0;
|
||||
|
||||
get halfWidth(): number {
|
||||
|
||||
return Math.round(this.width / 2);
|
||||
|
||||
}
|
||||
|
||||
get halfHeight(): number {
|
||||
|
||||
return Math.round(this.height / 2);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The sum of the y and height properties. Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property.
|
||||
* @method bottom
|
||||
* @return {Number}
|
||||
**/
|
||||
get bottom(): number {
|
||||
|
||||
return this.y + this.height;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The sum of the y and height properties. Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property.
|
||||
* @method bottom
|
||||
* @param {Number} value
|
||||
**/
|
||||
set bottom(value: number) {
|
||||
|
||||
if (value < this.y)
|
||||
{
|
||||
this.height = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.height = this.y + value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Point containing the location of the Rectangle's bottom-right corner, determined by the values of the right and bottom properties.
|
||||
* @method bottomRight
|
||||
* @return {Point}
|
||||
**/
|
||||
get bottomRight(): Point {
|
||||
|
||||
return new Point(this.right, this.bottom);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the bottom-right corner of this Rectangle, determined by the values of the given Point object.
|
||||
* @method bottomRight
|
||||
* @param {Point} value
|
||||
**/
|
||||
set bottomRight(value: Point) {
|
||||
|
||||
this.right = value.x;
|
||||
this.bottom = value.y;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The x coordinate of the top-left corner of the rectangle. Changing the left property of a Rectangle object has no effect on the y and height properties. However it does affect the width property, whereas changing the x value does not affect the width property.
|
||||
* @method left
|
||||
* @ return {number}
|
||||
**/
|
||||
get left(): number {
|
||||
|
||||
return this.x;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The x coordinate of the top-left corner of the rectangle. Changing the left property of a Rectangle object has no effect on the y and height properties. However it does affect the width property, whereas changing the x value does not affect the width property.
|
||||
* @method left
|
||||
* @param {Number} value
|
||||
**/
|
||||
set left(value: number) {
|
||||
|
||||
var diff = this.x - value;
|
||||
|
||||
if (this.width + diff < 0)
|
||||
{
|
||||
this.width = 0;
|
||||
|
||||
this.x = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.width += diff;
|
||||
|
||||
this.x = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The sum of the x and width properties. Changing the right property of a Rectangle object has no effect on the x, y and height properties. However it does affect the width property.
|
||||
* @method right
|
||||
* @return {Number}
|
||||
**/
|
||||
get right(): number {
|
||||
|
||||
return this.x + this.width;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The sum of the x and width properties. Changing the right property of a Rectangle object has no effect on the x, y and height properties. However it does affect the width property.
|
||||
* @method right
|
||||
* @param {Number} value
|
||||
**/
|
||||
set right(value: number) {
|
||||
|
||||
if (value < this.x)
|
||||
{
|
||||
this.width = 0;
|
||||
|
||||
return this.x;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.width = (value - this.x);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The size of the Rectangle object, expressed as a Point object with the values of the width and height properties.
|
||||
* @method size
|
||||
* @param {Point} output Optional Point object. If given the values will be set into the object, otherwise a brand new Point object will be created and returned.
|
||||
* @return {Point} The size of the Rectangle object
|
||||
**/
|
||||
size(output?: Point = new Point): Point {
|
||||
|
||||
return output.setTo(this.width, this.height);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The volume of the Rectangle object in pixels, derived from width * height
|
||||
* @method volume
|
||||
* @return {Number}
|
||||
**/
|
||||
get volume(): number {
|
||||
|
||||
return this.width * this.height;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The perimeter size of the Rectangle object in pixels. This is the sum of all 4 sides.
|
||||
* @method perimeter
|
||||
* @return {Number}
|
||||
**/
|
||||
get perimeter(): number {
|
||||
|
||||
return (this.width * 2) + (this.height * 2);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The y coordinate of the top-left corner of the rectangle. Changing the top property of a Rectangle object has no effect on the x and width properties. However it does affect the height property, whereas changing the y value does not affect the height property.
|
||||
* @method top
|
||||
* @return {Number}
|
||||
**/
|
||||
get top(): number {
|
||||
|
||||
return this.y;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The y coordinate of the top-left corner of the rectangle. Changing the top property of a Rectangle object has no effect on the x and width properties. However it does affect the height property, whereas changing the y value does not affect the height property.
|
||||
* @method top
|
||||
* @param {Number} value
|
||||
**/
|
||||
set top(value: number) {
|
||||
|
||||
var diff = this.y - value;
|
||||
|
||||
if (this.height + diff < 0)
|
||||
{
|
||||
this.height = 0;
|
||||
|
||||
this.y = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.height += diff;
|
||||
|
||||
this.y = value;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The location of the Rectangle object's top-left corner, determined by the x and y coordinates of the point.
|
||||
* @method topLeft
|
||||
* @return {Point}
|
||||
**/
|
||||
get topLeft(): Point {
|
||||
|
||||
return new Point(this.x, this.y);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The location of the Rectangle object's top-left corner, determined by the x and y coordinates of the point.
|
||||
* @method topLeft
|
||||
* @param {Point} value
|
||||
**/
|
||||
set topLeft(value: Point) {
|
||||
|
||||
this.x = value.x;
|
||||
this.y = value.y;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object.
|
||||
* @method clone
|
||||
* @param {Rectangle} output Optional Rectangle object. If given the values will be set into the object, otherwise a brand new Rectangle object will be created and returned.
|
||||
* @return {Rectangle}
|
||||
**/
|
||||
clone(output?: Rectangle = new Rectangle): Rectangle {
|
||||
|
||||
return output.setTo(this.x, this.y, this.width, this.height);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the specified coordinates are contained within the region defined by this Rectangle object.
|
||||
* @method contains
|
||||
* @param {Number} x The x coordinate of the point to test.
|
||||
* @param {Number} y The y coordinate of the point to test.
|
||||
* @return {Boolean} A value of true if the Rectangle object contains the specified point; otherwise false.
|
||||
**/
|
||||
contains(x: number, y: number): bool {
|
||||
|
||||
if (x >= this.x && x <= this.right && y >= this.y && y <= this.bottom)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. This method is similar to the Rectangle.contains() method, except that it takes a Point object as a parameter.
|
||||
* @method containsPoint
|
||||
* @param {Point} point The point object being checked. Can be Point or any object with .x and .y values.
|
||||
* @return {Boolean} A value of true if the Rectangle object contains the specified point; otherwise false.
|
||||
**/
|
||||
containsPoint(point: Point): bool {
|
||||
|
||||
return this.contains(point.x, point.y);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the Rectangle object specified by the rect parameter is contained within this Rectangle object. A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first.
|
||||
* @method containsRect
|
||||
* @param {Rectangle} rect The rectangle object being checked.
|
||||
* @return {Boolean} A value of true if the Rectangle object contains the specified point; otherwise false.
|
||||
**/
|
||||
containsRect(rect: Rectangle): bool {
|
||||
|
||||
// If the given rect has a larger volume than this one then it can never contain it
|
||||
if (rect.volume > this.volume)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rect.x >= this.x && rect.y >= this.y && rect.right <= this.right && rect.bottom <= this.bottom)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies all of rectangle data from the source Rectangle object into the calling Rectangle object.
|
||||
* @method copyFrom
|
||||
* @param {Rectangle} rect The source rectangle object to copy from
|
||||
* @return {Rectangle} This rectangle object
|
||||
**/
|
||||
copyFrom(source: Rectangle): Rectangle {
|
||||
|
||||
return this.setTo(source.x, source.y, source.width, source.height);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies all the rectangle data from this Rectangle object into the destination Rectangle object.
|
||||
* @method copyTo
|
||||
* @param {Rectangle} rect The destination rectangle object to copy in to
|
||||
* @return {Rectangle} The destination rectangle object
|
||||
**/
|
||||
copyTo(target: Rectangle): Rectangle {
|
||||
|
||||
return target.copyFrom(this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the object specified in the toCompare parameter is equal to this Rectangle object. This method compares the x, y, width, and height properties of an object against the same properties of this Rectangle object.
|
||||
* @method equals
|
||||
* @param {Rectangle} toCompare The rectangle to compare to this Rectangle object.
|
||||
* @return {Boolean} A value of true if the object has exactly the same values for the x, y, width, and height properties as this Rectangle object; otherwise false.
|
||||
**/
|
||||
equals(toCompare: Rectangle): bool {
|
||||
|
||||
if (this.x === toCompare.x && this.y === toCompare.y && this.width === toCompare.width && this.height === toCompare.height)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Increases the size of the Rectangle object by the specified amounts. The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value.
|
||||
* @method inflate
|
||||
* @param {Number} dx The amount to be added to the left side of this Rectangle.
|
||||
* @param {Number} dy The amount to be added to the bottom side of this Rectangle.
|
||||
* @return {Rectangle} This Rectangle object.
|
||||
**/
|
||||
inflate(dx: number, dy: number): Rectangle {
|
||||
|
||||
if (!isNaN(dx) && !isNaN(dy))
|
||||
{
|
||||
this.x -= dx;
|
||||
this.width += 2 * dx;
|
||||
|
||||
this.y -= dy;
|
||||
this.height += 2 * dy;
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Increases the size of the Rectangle object. This method is similar to the Rectangle.inflate() method except it takes a Point object as a parameter.
|
||||
* @method inflatePoint
|
||||
* @param {Point} point The x property of this Point object is used to increase the horizontal dimension of the Rectangle object. The y property is used to increase the vertical dimension of the Rectangle object.
|
||||
* @return {Rectangle} This Rectangle object.
|
||||
**/
|
||||
inflatePoint(point: Point): Rectangle {
|
||||
|
||||
return this.inflate(point.x, point.y);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, returns the area of intersection as a Rectangle object. If the rectangles do not intersect, this method returns an empty Rectangle object with its properties set to 0.
|
||||
* @method intersection
|
||||
* @param {Rectangle} toIntersect The Rectangle object to compare against to see if it intersects with this Rectangle object.
|
||||
* @param {Rectangle} output Optional Rectangle object. If given the intersection values will be set into this object, otherwise a brand new Rectangle object will be created and returned.
|
||||
* @return {Rectangle} A Rectangle object that equals the area of intersection. If the rectangles do not intersect, this method returns an empty Rectangle object; that is, a rectangle with its x, y, width, and height properties set to 0.
|
||||
**/
|
||||
intersection(toIntersect: Rectangle, output?: Rectangle = new Rectangle): Rectangle {
|
||||
|
||||
if (this.intersects(toIntersect) === true)
|
||||
{
|
||||
output.x = Math.max(toIntersect.x, this.x);
|
||||
output.y = Math.max(toIntersect.y, this.y);
|
||||
output.width = Math.min(toIntersect.right, this.right) - output.x;
|
||||
output.height = Math.min(toIntersect.bottom, this.bottom) - output.y;
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the object specified in the toIntersect parameter intersects with this Rectangle object. This method checks the x, y, width, and height properties of the specified Rectangle object to see if it intersects with this Rectangle object.
|
||||
* @method intersects
|
||||
* @param {Rectangle} toIntersect The Rectangle object to compare against to see if it intersects with this Rectangle object.
|
||||
* @return {Boolean} A value of true if the specified object intersects with this Rectangle object; otherwise false.
|
||||
**/
|
||||
intersects(toIntersect: Rectangle): bool {
|
||||
|
||||
if (toIntersect.x >= this.right)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (toIntersect.right <= this.x)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (toIntersect.bottom <= this.y)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (toIntersect.y >= this.bottom)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for overlaps between this Rectangle and the given Rectangle. Returns an object with boolean values for each check.
|
||||
* @method overlap
|
||||
* @return {Boolean} true if the rectangles overlap, otherwise false
|
||||
**/
|
||||
overlap(rect: Rectangle): bool {
|
||||
|
||||
return (rect.x + rect.width > this.x) && (rect.x < this.x + this.width) && (rect.y + rect.height > this.y) && (rect.y < this.y + this.height);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether or not this Rectangle object is empty.
|
||||
* @method isEmpty
|
||||
* @return {Boolean} A value of true if the Rectangle object's width or height is less than or equal to 0; otherwise false.
|
||||
**/
|
||||
get isEmpty(): bool {
|
||||
|
||||
if (this.width < 1 || this.height < 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the location of the Rectangle object, as determined by its top-left corner, by the specified amounts.
|
||||
* @method offset
|
||||
* @param {Number} dx Moves the x value of the Rectangle object by this amount.
|
||||
* @param {Number} dy Moves the y value of the Rectangle object by this amount.
|
||||
* @return {Rectangle} This Rectangle object.
|
||||
**/
|
||||
offset(dx: number, dy: number): Rectangle {
|
||||
|
||||
if (!isNaN(dx) && !isNaN(dy))
|
||||
{
|
||||
this.x += dx;
|
||||
this.y += dy;
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the location of the Rectangle object using a Point object as a parameter. This method is similar to the Rectangle.offset() method, except that it takes a Point object as a parameter.
|
||||
* @method offsetPoint
|
||||
* @param {Point} point A Point object to use to offset this Rectangle object.
|
||||
* @return {Rectangle} This Rectangle object.
|
||||
**/
|
||||
offsetPoint(point: Point): Rectangle {
|
||||
|
||||
return this.offset(point.x, point.y);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets all of the Rectangle object's properties to 0. A Rectangle object is empty if its width or height is less than or equal to 0.
|
||||
* @method setEmpty
|
||||
* @return {Rectangle} This rectangle object
|
||||
**/
|
||||
setEmpty() {
|
||||
|
||||
return this.setTo(0, 0, 0, 0);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the members of Rectangle to the specified values.
|
||||
* @method setTo
|
||||
* @param {Number} x The x coordinate of the top-left corner of the rectangle.
|
||||
* @param {Number} y The y coordinate of the top-left corner of the rectangle.
|
||||
* @param {Number} width The width of the rectangle in pixels.
|
||||
* @param {Number} height The height of the rectangle in pixels.
|
||||
* @return {Rectangle} This rectangle object
|
||||
**/
|
||||
setTo(x: number, y: number, width: number, height: number): Rectangle {
|
||||
|
||||
if (!isNaN(x) && !isNaN(y) && !isNaN(width) && !isNaN(height))
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
||||
if (width > 0)
|
||||
{
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
if (height > 0)
|
||||
{
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds two rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two rectangles.
|
||||
* @method union
|
||||
* @param {Rectangle} toUnion A Rectangle object to add to this Rectangle object.
|
||||
* @param {Rectangle} output Optional Rectangle object. If given the new values will be set into this object, otherwise a brand new Rectangle object will be created and returned.
|
||||
* @return {Rectangle} A Rectangle object that is the union of the two rectangles.
|
||||
**/
|
||||
union(toUnion: Rectangle, output?: Rectangle = new Rectangle): Rectangle {
|
||||
|
||||
return output.setTo(
|
||||
Math.min(toUnion.x, this.x),
|
||||
Math.min(toUnion.y, this.y),
|
||||
Math.max(toUnion.right, this.right),
|
||||
Math.max(toUnion.bottom, this.bottom)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this object.
|
||||
* @method toString
|
||||
* @return {string} a string representation of the instance.
|
||||
**/
|
||||
toString(): string {
|
||||
|
||||
return "[{Rectangle (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + " empty=" + this.isEmpty + ")}]";
|
||||
|
||||
}
|
||||
|
||||
}
|
216
Phaser/Sound.ts
Normal file
|
@ -0,0 +1,216 @@
|
|||
class SoundManager {
|
||||
|
||||
constructor(game:Game) {
|
||||
|
||||
this._game = game;
|
||||
|
||||
if (!!window['AudioContext'])
|
||||
{
|
||||
this._context = new window['AudioContext']();
|
||||
}
|
||||
else if (!!window['webkitAudioContext'])
|
||||
{
|
||||
this._context = new window['webkitAudioContext']();
|
||||
}
|
||||
|
||||
if (this._context !== null)
|
||||
{
|
||||
this._gainNode = this._context.createGainNode();
|
||||
this._gainNode.connect(this._context.destination);
|
||||
this._volume = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
|
||||
private _context = null;
|
||||
private _gainNode;
|
||||
private _volume: number;
|
||||
|
||||
public mute() {
|
||||
|
||||
this._gainNode.gain.value = 0;
|
||||
|
||||
}
|
||||
|
||||
public unmute() {
|
||||
|
||||
this._gainNode.gain.value = this._volume;
|
||||
|
||||
}
|
||||
|
||||
public set volume(value: number) {
|
||||
|
||||
this._volume = value;
|
||||
this._gainNode.gain.value = this._volume;
|
||||
|
||||
}
|
||||
|
||||
public get volume(): number {
|
||||
return this._volume;
|
||||
}
|
||||
|
||||
public decode(key: string, callback = null, sound?: Sound = null) {
|
||||
|
||||
var soundData = this._game.cache.getSound(key);
|
||||
|
||||
if (soundData)
|
||||
{
|
||||
if (this._game.cache.isSoundDecoded(key) === false)
|
||||
{
|
||||
var that = this;
|
||||
|
||||
this._context.decodeAudioData(soundData, function (buffer) {
|
||||
that._game.cache.decodedSound(key, buffer);
|
||||
|
||||
if (sound)
|
||||
{
|
||||
sound.setDecodedBuffer(buffer);
|
||||
}
|
||||
|
||||
callback();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public play(key:string, volume?: number = 1, loop?: bool = false): Sound {
|
||||
|
||||
if (this._context === null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var soundData = this._game.cache.getSound(key);
|
||||
|
||||
if (soundData)
|
||||
{
|
||||
// Does the sound need decoding?
|
||||
if (this._game.cache.isSoundDecoded(key) === true)
|
||||
{
|
||||
return new Sound(this._context, this._gainNode, soundData, volume, loop);
|
||||
}
|
||||
else
|
||||
{
|
||||
var tempSound: Sound = new Sound(this._context, this._gainNode, null, volume, loop);
|
||||
|
||||
// this is an async process, so we can return the Sound object anyway, it just won't be playing yet
|
||||
this.decode(key, () => this.play(key), tempSound);
|
||||
|
||||
return tempSound;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Sound {
|
||||
|
||||
constructor(context, gainNode, data, volume?: number = 1, loop?: bool = false) {
|
||||
|
||||
this._context = context;
|
||||
this._gainNode = gainNode;
|
||||
this._buffer = data;
|
||||
this._volume = volume;
|
||||
this.loop = loop;
|
||||
|
||||
// Local volume control
|
||||
if (this._context !== null)
|
||||
{
|
||||
this._localGainNode = this._context.createGainNode();
|
||||
this._localGainNode.connect(this._gainNode);
|
||||
this._localGainNode.gain.value = this._volume;
|
||||
}
|
||||
|
||||
if (this._buffer === null)
|
||||
{
|
||||
this.isDecoding = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.play();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private _context;
|
||||
private _gainNode;
|
||||
private _localGainNode;
|
||||
private _buffer;
|
||||
private _volume: number;
|
||||
private _sound;
|
||||
|
||||
loop: bool = false;
|
||||
duration: number;
|
||||
isPlaying: bool = false;
|
||||
isDecoding: bool = false;
|
||||
|
||||
public setDecodedBuffer(data) {
|
||||
|
||||
this._buffer = data;
|
||||
this.isDecoding = false;
|
||||
this.play();
|
||||
|
||||
}
|
||||
|
||||
public play() {
|
||||
|
||||
if (this._buffer === null || this.isDecoding === true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this._sound = this._context.createBufferSource();
|
||||
this._sound.buffer = this._buffer;
|
||||
this._sound.connect(this._localGainNode);
|
||||
|
||||
if (this.loop)
|
||||
{
|
||||
this._sound.loop = true;
|
||||
}
|
||||
|
||||
this._sound.noteOn(0); // the zero is vitally important, crashes iOS6 without it
|
||||
|
||||
this.duration = this._sound.buffer.duration;
|
||||
this.isPlaying = true;
|
||||
|
||||
}
|
||||
|
||||
public stop () {
|
||||
|
||||
if (this.isPlaying === true)
|
||||
{
|
||||
this.isPlaying = false;
|
||||
|
||||
this._sound.noteOff(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public mute() {
|
||||
|
||||
this._localGainNode.gain.value = 0;
|
||||
|
||||
}
|
||||
|
||||
public unmute() {
|
||||
|
||||
this._localGainNode.gain.value = this._volume;
|
||||
|
||||
}
|
||||
|
||||
public set volume(value: number) {
|
||||
|
||||
this._volume = value;
|
||||
this._localGainNode.gain.value = this._volume;
|
||||
|
||||
}
|
||||
|
||||
public get volume(): number {
|
||||
return this._volume;
|
||||
}
|
||||
|
||||
}
|
226
Phaser/Sprite.ts
Normal file
|
@ -0,0 +1,226 @@
|
|||
/// <reference path="Animations.ts" />
|
||||
/// <reference path="GameObject.ts" />
|
||||
/// <reference path="Game.ts" />
|
||||
/// <reference path="GameMath.ts" />
|
||||
/// <reference path="Rectangle.ts" />
|
||||
/// <reference path="Point.ts" />
|
||||
|
||||
class Sprite extends GameObject {
|
||||
|
||||
constructor(game: Game, x?: number = 0, y?: number = 0, key?: string = null) {
|
||||
|
||||
super(game, x, y);
|
||||
|
||||
this._texture = null;
|
||||
|
||||
this.animations = new Animations(this._game, this);
|
||||
|
||||
if (key !== null)
|
||||
{
|
||||
this.loadGraphic(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.bounds.width = 16;
|
||||
this.bounds.height = 16;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private _texture;
|
||||
private _canvas: HTMLCanvasElement;
|
||||
private _context: CanvasRenderingContext2D;
|
||||
|
||||
public animations: Animations;
|
||||
|
||||
// local rendering related temp vars to help avoid gc spikes
|
||||
private _sx: number = 0;
|
||||
private _sy: number = 0;
|
||||
private _sw: number = 0;
|
||||
private _sh: number = 0;
|
||||
private _dx: number = 0;
|
||||
private _dy: number = 0;
|
||||
private _dw: number = 0;
|
||||
private _dh: number = 0;
|
||||
|
||||
public loadGraphic(key: string): Sprite {
|
||||
|
||||
if (this._game.cache.isSpriteSheet(key) == false)
|
||||
{
|
||||
this._texture = this._game.cache.getImage(key);
|
||||
this.bounds.width = this._texture.width;
|
||||
this.bounds.height = this._texture.height;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._texture = this._game.cache.getImage(key);
|
||||
this.animations.loadFrameData(this._game.cache.getFrameData(key));
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
public makeGraphic(width: number, height: number, color: number = 0xffffffff): Sprite {
|
||||
|
||||
this._texture = null;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public inCamera(camera: Rectangle): bool {
|
||||
|
||||
if (this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0)
|
||||
{
|
||||
this._dx = this.bounds.x - (camera.x * this.scrollFactor.x);
|
||||
this._dy = this.bounds.y - (camera.y * this.scrollFactor.x);
|
||||
this._dw = this.bounds.width * this.scale.x;
|
||||
this._dh = this.bounds.height * this.scale.y;
|
||||
|
||||
return (camera.right > this._dx) && (camera.x < this._dx + this._dw) && (camera.bottom > this._dy) && (camera.y < this._dy + this._dh);
|
||||
}
|
||||
else
|
||||
{
|
||||
return camera.overlap(this.bounds);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public postUpdate() {
|
||||
|
||||
this.animations.update();
|
||||
|
||||
super.postUpdate();
|
||||
|
||||
}
|
||||
|
||||
public set frame(value?: number) {
|
||||
this.animations.frame = value;
|
||||
}
|
||||
|
||||
public get frame(): number {
|
||||
return this.animations.frame;
|
||||
}
|
||||
|
||||
public render(camera:Camera, cameraOffsetX: number, cameraOffsetY: number): bool {
|
||||
|
||||
// Render checks
|
||||
if (this.visible === false || this.scale.x == 0 || this.scale.y == 0 || this.alpha < 0.1 || this.inCamera(camera.worldView) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Alpha
|
||||
if (this.alpha !== 1)
|
||||
{
|
||||
var globalAlpha = this._game.stage.context.globalAlpha;
|
||||
this._game.stage.context.globalAlpha = this.alpha;
|
||||
}
|
||||
|
||||
//if (this.flip === true)
|
||||
//{
|
||||
// this.context.save();
|
||||
// this.context.translate(game.canvas.width, 0);
|
||||
// this.context.scale(-1, 1);
|
||||
//}
|
||||
|
||||
this._sx = 0;
|
||||
this._sy = 0;
|
||||
this._sw = this.bounds.width;
|
||||
this._sh = this.bounds.height;
|
||||
this._dx = cameraOffsetX + (this.bounds.x - camera.worldView.x);
|
||||
this._dy = cameraOffsetY + (this.bounds.y - camera.worldView.y);
|
||||
this._dw = this.bounds.width * this.scale.x;
|
||||
this._dh = this.bounds.height * this.scale.y;
|
||||
|
||||
if (this.animations.currentFrame)
|
||||
{
|
||||
this._sx = this.animations.currentFrame.x;
|
||||
this._sy = this.animations.currentFrame.y;
|
||||
|
||||
if (this.animations.currentFrame.trimmed)
|
||||
{
|
||||
this._dx += this.animations.currentFrame.spriteSourceSizeX;
|
||||
this._dy += this.animations.currentFrame.spriteSourceSizeY;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply camera difference
|
||||
if (this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0)
|
||||
{
|
||||
this._dx -= (camera.worldView.x * this.scrollFactor.x);
|
||||
this._dy -= (camera.worldView.y * this.scrollFactor.y);
|
||||
}
|
||||
|
||||
// Rotation
|
||||
if (this.angle !== 0)
|
||||
{
|
||||
this._game.stage.context.save();
|
||||
this._game.stage.context.translate(this._dx + (this._dw / 2), this._dy + (this._dh / 2));
|
||||
this._game.stage.context.rotate(this.angle * (Math.PI / 180));
|
||||
this._dx = -(this._dw / 2);
|
||||
this._dy = -(this._dh / 2);
|
||||
}
|
||||
|
||||
this._sx = Math.round(this._sx);
|
||||
this._sy = Math.round(this._sy);
|
||||
this._sw = Math.round(this._sw);
|
||||
this._sh = Math.round(this._sh);
|
||||
this._dx = Math.round(this._dx);
|
||||
this._dy = Math.round(this._dy);
|
||||
this._dw = Math.round(this._dw);
|
||||
this._dh = Math.round(this._dh);
|
||||
|
||||
// Debug test
|
||||
//this._game.stage.context.fillStyle = 'rgba(255,0,0,0.3)';
|
||||
//this._game.stage.context.fillRect(this._dx, this._dy, this._dw, this._dh);
|
||||
|
||||
if (this._texture != null)
|
||||
{
|
||||
this._game.stage.context.drawImage(
|
||||
this._texture, // Source Image
|
||||
this._sx, // Source X (location within the source image)
|
||||
this._sy, // Source Y
|
||||
this._sw, // Source Width
|
||||
this._sh, // Source Height
|
||||
this._dx, // Destination X (where on the canvas it'll be drawn)
|
||||
this._dy, // Destination Y
|
||||
this._dw, // Destination Width (always same as Source Width unless scaled)
|
||||
this._dh // Destination Height (always same as Source Height unless scaled)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._game.stage.context.fillStyle = 'rgb(255,255,255)';
|
||||
this._game.stage.context.fillRect(this._dx, this._dy, this._dw, this._dh);
|
||||
}
|
||||
|
||||
//if (this.flip === true || this.rotation !== 0)
|
||||
if (this.rotation !== 0)
|
||||
{
|
||||
this._game.stage.context.translate(0, 0);
|
||||
this._game.stage.context.restore();
|
||||
}
|
||||
|
||||
if (globalAlpha > -1)
|
||||
{
|
||||
this._game.stage.context.globalAlpha = globalAlpha;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
|
||||
|
||||
this._game.stage.context.fillStyle = color;
|
||||
this._game.stage.context.fillText('Sprite: ' + this.name + ' (' + this.bounds.width + ' x ' + this.bounds.height + ')', x, y);
|
||||
this._game.stage.context.fillText('x: ' + this.bounds.x.toFixed(1) + ' y: ' + this.bounds.y.toFixed(1) + ' rotation: ' + this.angle.toFixed(1), x, y + 14);
|
||||
this._game.stage.context.fillText('dx: ' + this._dx.toFixed(1) + ' dy: ' + this._dy.toFixed(1) + ' dw: ' + this._dw.toFixed(1) + ' dh: ' + this._dh.toFixed(1), x, y + 28);
|
||||
this._game.stage.context.fillText('sx: ' + this._sx.toFixed(1) + ' sy: ' + this._sy.toFixed(1) + ' sw: ' + this._sw.toFixed(1) + ' sh: ' + this._sh.toFixed(1), x, y + 42);
|
||||
|
||||
}
|
||||
|
||||
}
|
184
Phaser/Stage.ts
Normal file
|
@ -0,0 +1,184 @@
|
|||
/// <reference path="Game.ts" />
|
||||
/// <reference path="Point.ts" />
|
||||
/// <reference path="Rectangle.ts" />
|
||||
|
||||
class Stage {
|
||||
|
||||
constructor(game:Game, parent:string, width: number, height: number) {
|
||||
|
||||
this._game = game;
|
||||
|
||||
this.canvas = <HTMLCanvasElement> document.createElement('canvas');
|
||||
this.canvas.width = width;
|
||||
this.canvas.height = height;
|
||||
|
||||
if (document.getElementById(parent))
|
||||
{
|
||||
document.getElementById(parent).appendChild(this.canvas);
|
||||
}
|
||||
else
|
||||
{
|
||||
document.body.appendChild(this.canvas);
|
||||
}
|
||||
|
||||
var offset:Point = this.getOffset(this.canvas);
|
||||
|
||||
this.bounds = new Rectangle(offset.x, offset.y, width, height);
|
||||
|
||||
this.context = this.canvas.getContext('2d');
|
||||
|
||||
//document.addEventListener('visibilitychange', (event) => this.visibilityChange(event), false);
|
||||
//document.addEventListener('webkitvisibilitychange', (event) => this.visibilityChange(event), false);
|
||||
window.onblur = (event) => this.visibilityChange(event);
|
||||
window.onfocus = (event) => this.visibilityChange(event);
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
private _bgColor: string;
|
||||
|
||||
public bounds: Rectangle;
|
||||
public clear: bool = true;
|
||||
public canvas: HTMLCanvasElement;
|
||||
public context: CanvasRenderingContext2D;
|
||||
|
||||
public update() {
|
||||
|
||||
if (this.clear)
|
||||
{
|
||||
// implement dirty rect? could take up more cpu time than it saves. needs benching.
|
||||
this.context.clearRect(0, 0, this.width, this.height);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public renderDebugInfo() {
|
||||
|
||||
this.context.fillStyle = 'rgb(255,255,255)';
|
||||
this.context.fillText(Game.VERSION, 10, 20);
|
||||
this.context.fillText('Game Size: ' + this.width + ' x ' + this.height, 10, 40);
|
||||
this.context.fillText('x: ' + this.x + ' y: ' + this.y, 10, 60);
|
||||
|
||||
}
|
||||
|
||||
private visibilityChange(event) {
|
||||
|
||||
if (event.type == 'blur' && this._game.pause == false && this._game.isBooted == true)
|
||||
{
|
||||
this._game.pause = true;
|
||||
this.drawPauseScreen();
|
||||
}
|
||||
else if (event.type == 'focus')
|
||||
{
|
||||
this._game.pause = false;
|
||||
}
|
||||
|
||||
//if (document['hidden'] === true || document['webkitHidden'] === true)
|
||||
|
||||
}
|
||||
|
||||
public drawInitScreen() {
|
||||
|
||||
this.context.fillStyle = 'rgb(40, 40, 40)';
|
||||
this.context.fillRect(0, 0, this.width, this.height);
|
||||
|
||||
this.context.fillStyle = 'rgb(255,255,255)';
|
||||
this.context.font = 'bold 18px Arial';
|
||||
this.context.textBaseline = 'top';
|
||||
this.context.fillText(Game.VERSION, 54, 32);
|
||||
this.context.fillText('Game Size: ' + this.width + ' x ' + this.height, 32, 64);
|
||||
this.context.fillText('www.photonstorm.com', 32, 96);
|
||||
this.context.font = '16px Arial';
|
||||
this.context.fillText('You are seeing this screen because you didn\'t specify any default', 32, 160);
|
||||
this.context.fillText('functions in the Game constructor, or use Game.loadState()', 32, 184);
|
||||
|
||||
var image = new Image();
|
||||
var that = this;
|
||||
|
||||
image.onload = function() {
|
||||
that.context.drawImage(image, 32, 32);
|
||||
};
|
||||
|
||||
image.src = this._logo;
|
||||
|
||||
}
|
||||
|
||||
private drawPauseScreen() {
|
||||
|
||||
this.context.fillStyle = 'rgba(0, 0, 0, 0.4)';
|
||||
this.context.fillRect(0, 0, this.width, this.height);
|
||||
|
||||
// Draw a 'play' arrow
|
||||
var arrowWidth = Math.round(this.width / 2);
|
||||
var arrowHeight = Math.round(this.height / 2);
|
||||
|
||||
var sx = this.centerX - arrowWidth / 2;
|
||||
var sy = this.centerY - arrowHeight / 2;
|
||||
|
||||
this.context.beginPath();
|
||||
this.context.moveTo(sx, sy);
|
||||
this.context.lineTo(sx, sy + arrowHeight);
|
||||
this.context.lineTo(sx + arrowWidth, this.centerY);
|
||||
this.context.closePath();
|
||||
|
||||
this.context.fillStyle = 'rgba(255, 255, 255, 0.8)';
|
||||
this.context.fill();
|
||||
|
||||
}
|
||||
|
||||
private getOffset(element):Point {
|
||||
|
||||
var box = element.getBoundingClientRect();
|
||||
|
||||
var clientTop = element.clientTop || document.body.clientTop || 0;
|
||||
var clientLeft = element.clientLeft || document.body.clientLeft || 0;
|
||||
var scrollTop = window.pageYOffset || element.scrollTop || document.body.scrollTop;
|
||||
var scrollLeft = window.pageXOffset || element.scrollLeft || document.body.scrollLeft;
|
||||
|
||||
return new Point(box.left + scrollLeft - clientLeft, box.top + scrollTop - clientTop);
|
||||
|
||||
}
|
||||
|
||||
public set backgroundColor(color: string) {
|
||||
this.canvas.style.backgroundColor = color;
|
||||
}
|
||||
|
||||
public get backgroundColor():string {
|
||||
return this._bgColor;
|
||||
}
|
||||
|
||||
public get x(): number {
|
||||
return this.bounds.x;
|
||||
}
|
||||
|
||||
public get y(): number {
|
||||
return this.bounds.y;
|
||||
}
|
||||
|
||||
public get width(): number {
|
||||
return this.bounds.width;
|
||||
}
|
||||
|
||||
public get height(): number {
|
||||
return this.bounds.height;
|
||||
}
|
||||
|
||||
public get centerX(): number {
|
||||
return this.bounds.halfWidth;
|
||||
}
|
||||
|
||||
public get centerY(): number {
|
||||
return this.bounds.halfHeight;
|
||||
}
|
||||
|
||||
public get randomX(): number {
|
||||
return Math.round(Math.random() * this.bounds.width);
|
||||
}
|
||||
|
||||
public get randomY(): number {
|
||||
return Math.round(Math.random() * this.bounds.height);
|
||||
}
|
||||
|
||||
private _logo:string = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAO1JREFUeNpi/P//PwM6YGRkxBQEAqBaRnQxFmwa10d6MAjrMqMofHv5L1we2SBGmAtAktg0ogOQQYHLd8ANYYFpPtTmzUAMAFmwnsEDrAdkCAvMZlIAsiFMMAEYsKvaSrQhIMCELkGsV2AAbIC8gCQYgwKIUABiNYBf9yoYH7n7n6CzN274g2IYEyFbsNmKLIaSkHpP7WSwUfbA0ASzFQRslBlxp0RcAF0TRhggA3zhAJIDpUKU5A9KyshpHDkjFZu5g2nJMFcwXVJSgqIGnBKx5bKenh4w/XzVbgbPtlIUcVgSxuoCUgHIIIAAAwArtXwJBABO6QAAAABJRU5ErkJggg==";
|
||||
|
||||
}
|
71
Phaser/State.ts
Normal file
|
@ -0,0 +1,71 @@
|
|||
/// <reference path="Game.ts" />
|
||||
|
||||
class State {
|
||||
|
||||
constructor(game: Game) {
|
||||
|
||||
this.game = game;
|
||||
|
||||
this.camera = game.camera;
|
||||
this.cache = game.cache;
|
||||
this.input = game.input;
|
||||
this.loader = game.loader;
|
||||
this.sound = game.sound;
|
||||
this.stage = game.stage;
|
||||
this.time = game.time;
|
||||
this.math = game.math;
|
||||
this.world = game.world;
|
||||
|
||||
}
|
||||
|
||||
public game: Game;
|
||||
|
||||
public camera: Camera;
|
||||
public cache: Cache;
|
||||
public input: Input;
|
||||
public loader: Loader;
|
||||
public sound: SoundManager;
|
||||
public stage: Stage;
|
||||
public time: Time;
|
||||
public math: GameMath;
|
||||
public world: World;
|
||||
|
||||
|
||||
// Overload these in your own States
|
||||
public init() {}
|
||||
public create() {}
|
||||
public update() {}
|
||||
public render() {}
|
||||
public paused() {}
|
||||
|
||||
// Handy Proxy methods
|
||||
|
||||
public createCamera(x: number, y: number, width: number, height: number): Camera {
|
||||
return this.game.world.createCamera(x, y, width, height);
|
||||
}
|
||||
|
||||
public createSprite(x: number, y: number, key?: string = ''): Sprite {
|
||||
return this.game.world.createSprite(x, y, key);
|
||||
}
|
||||
|
||||
public createGroup(MaxSize?: number = 0): Group {
|
||||
return this.game.world.createGroup(MaxSize);
|
||||
}
|
||||
|
||||
public createParticle(): Particle {
|
||||
return this.game.world.createParticle();
|
||||
}
|
||||
|
||||
public createEmitter(x?: number = 0, y?: number = 0, size?:number = 0): Emitter {
|
||||
return this.game.world.createEmitter(x, y, size);
|
||||
}
|
||||
|
||||
public createTilemap(key:string, mapData:string, format:number, tileWidth?:number,tileHeight?:number): Tilemap {
|
||||
return this.game.world.createTilemap(key, mapData, format, tileWidth, tileHeight);
|
||||
}
|
||||
|
||||
public collide(ObjectOrGroup1: Basic = null, ObjectOrGroup2: Basic = null, NotifyCallback = null): bool {
|
||||
return this.game.world.overlap(ObjectOrGroup1, ObjectOrGroup2, NotifyCallback, World.separate);
|
||||
}
|
||||
|
||||
}
|
261
Phaser/Tilemap.ts
Normal file
|
@ -0,0 +1,261 @@
|
|||
/// <reference path="Game.ts" />
|
||||
/// <reference path="GameObject.ts" />
|
||||
/// <reference path="Point.ts" />
|
||||
/// <reference path="Rectangle.ts" />
|
||||
/// <reference path="system/TilemapBuffer.ts" />
|
||||
|
||||
class Tilemap extends GameObject {
|
||||
|
||||
constructor(game: Game, key: string, mapData: string, format:number, tileWidth?: number = 0, tileHeight?: number = 0) {
|
||||
|
||||
super(game);
|
||||
|
||||
this._texture = this._game.cache.getImage(key);
|
||||
this._tilemapBuffers = [];
|
||||
|
||||
this.isGroup = false;
|
||||
|
||||
this.tileWidth = tileWidth;
|
||||
this.tileHeight = tileHeight;
|
||||
this.boundsInTiles = new Rectangle();
|
||||
this.mapFormat = format;
|
||||
|
||||
switch (format)
|
||||
{
|
||||
case Tilemap.FORMAT_CSV:
|
||||
this.parseCSV(game.cache.getText(mapData));
|
||||
break;
|
||||
|
||||
case Tilemap.FORMAT_TILED_JSON:
|
||||
this.parseTiledJSON(game.cache.getText(mapData));
|
||||
break;
|
||||
}
|
||||
|
||||
this.parseTileOffsets();
|
||||
this.createTilemapBuffers();
|
||||
|
||||
}
|
||||
|
||||
private _texture;
|
||||
private _tileOffsets;
|
||||
private _tilemapBuffers: TilemapBuffer[];
|
||||
private _dx: number = 0;
|
||||
private _dy: number = 0;
|
||||
|
||||
public static FORMAT_CSV:number = 0;
|
||||
public static FORMAT_TILED_JSON:number = 1;
|
||||
|
||||
public mapData;
|
||||
public mapFormat: number;
|
||||
public boundsInTiles: Rectangle;
|
||||
|
||||
public tileWidth: number;
|
||||
public tileHeight: number;
|
||||
|
||||
public widthInTiles: number = 0;
|
||||
public heightInTiles: number = 0;
|
||||
|
||||
public widthInPixels: number = 0;
|
||||
public heightInPixels: number = 0;
|
||||
|
||||
// How many extra tiles to draw around the edge of the screen (for fast scrolling games, or to optimise mobile performance try increasing this)
|
||||
// The number is the amount of extra tiles PER SIDE, so a value of 10 would be (10 tiles + screen size + 10 tiles)
|
||||
public tileBoundary: number = 10;
|
||||
|
||||
private parseCSV(data: string) {
|
||||
|
||||
//console.log('parseMapData');
|
||||
|
||||
this.mapData = [];
|
||||
|
||||
// Trim any rogue whitespace from the data
|
||||
data = data.trim();
|
||||
|
||||
var rows = data.split("\n");
|
||||
//console.log('rows', rows);
|
||||
|
||||
for (var i = 0; i < rows.length; i++)
|
||||
{
|
||||
var column = rows[i].split(",");
|
||||
//console.log('column', column);
|
||||
var output = [];
|
||||
|
||||
if (column.length > 0)
|
||||
{
|
||||
// Set the width based on the first row
|
||||
if (this.widthInTiles == 0)
|
||||
{
|
||||
// Maybe -1?
|
||||
this.widthInTiles = column.length;
|
||||
}
|
||||
|
||||
// We have a new row of tiles
|
||||
this.heightInTiles++;
|
||||
|
||||
// Parse it
|
||||
for (var c = 0; c < column.length; c++)
|
||||
{
|
||||
output[c] = parseInt(column[c]);
|
||||
}
|
||||
|
||||
this.mapData.push(output);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//console.log('final map array');
|
||||
//console.log(this.mapData);
|
||||
|
||||
if (this.widthInTiles > 0)
|
||||
{
|
||||
this.widthInPixels = this.tileWidth * this.widthInTiles;
|
||||
}
|
||||
|
||||
if (this.heightInTiles > 0)
|
||||
{
|
||||
this.heightInPixels = this.tileHeight * this.heightInTiles;
|
||||
}
|
||||
|
||||
this.boundsInTiles.setTo(0, 0, this.widthInTiles, this.heightInTiles);
|
||||
|
||||
}
|
||||
|
||||
private parseTiledJSON(data: string) {
|
||||
|
||||
console.log('parseTiledJSON');
|
||||
|
||||
this.mapData = [];
|
||||
|
||||
// Trim any rogue whitespace from the data
|
||||
data = data.trim();
|
||||
|
||||
// We ought to change this soon, so we have layer support, but for now let's just get it working
|
||||
var json = JSON.parse(data);
|
||||
|
||||
// Right now we assume no errors at all with the parsing (safe I know)
|
||||
this.tileWidth = json.tilewidth;
|
||||
this.tileHeight = json.tileheight;
|
||||
|
||||
// Parse the first layer only
|
||||
this.widthInTiles = json.layers[0].width;
|
||||
this.heightInTiles = json.layers[0].height;
|
||||
this.widthInPixels = this.widthInTiles * this.tileWidth;
|
||||
this.heightInPixels = this.heightInTiles * this.tileHeight;
|
||||
this.boundsInTiles.setTo(0, 0, this.widthInTiles, this.heightInTiles);
|
||||
|
||||
console.log('width in tiles', this.widthInTiles);
|
||||
console.log('height in tiles', this.heightInTiles);
|
||||
console.log('width in px', this.widthInPixels);
|
||||
console.log('height in px', this.heightInPixels);
|
||||
|
||||
// Now let's get the data
|
||||
|
||||
var c = 0;
|
||||
var row;
|
||||
|
||||
for (var i = 0; i < json.layers[0].data.length; i++)
|
||||
{
|
||||
if (c == 0)
|
||||
{
|
||||
row = [];
|
||||
}
|
||||
|
||||
row.push(json.layers[0].data[i]);
|
||||
|
||||
c++;
|
||||
|
||||
if (c == this.widthInTiles)
|
||||
{
|
||||
this.mapData.push(row);
|
||||
c = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//console.log('mapData');
|
||||
//console.log(this.mapData);
|
||||
|
||||
}
|
||||
|
||||
public getMapSegment(area: Rectangle) {
|
||||
}
|
||||
|
||||
private createTilemapBuffers() {
|
||||
|
||||
var cams = this._game.world.getAllCameras();
|
||||
|
||||
for (var i = 0; i < cams.length; i++)
|
||||
{
|
||||
this._tilemapBuffers[cams[i].ID] = new TilemapBuffer(this._game, cams[i], this, this._texture, this._tileOffsets);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private parseTileOffsets() {
|
||||
|
||||
this._tileOffsets = [];
|
||||
|
||||
var i = 0;
|
||||
|
||||
if (this.mapFormat == Tilemap.FORMAT_TILED_JSON)
|
||||
{
|
||||
// For some reason Tiled counts from 1 not 0
|
||||
this._tileOffsets[0] = null;
|
||||
i = 1;
|
||||
}
|
||||
|
||||
for (var ty = 0; ty < this._texture.height; ty += this.tileHeight)
|
||||
{
|
||||
for (var tx = 0; tx < this._texture.width; tx += this.tileWidth)
|
||||
{
|
||||
this._tileOffsets[i] = { x: tx, y: ty };
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
// Use a Signal?
|
||||
public addTilemapBuffers(camera:Camera) {
|
||||
|
||||
console.log('added new camera to tilemap');
|
||||
this._tilemapBuffers[camera.ID] = new TilemapBuffer(this._game, camera, this, this._texture, this._tileOffsets);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
public update() {
|
||||
|
||||
// Check if any of the cameras have scrolled far enough for us to need to refresh a TilemapBuffer
|
||||
this._tilemapBuffers[0].update();
|
||||
|
||||
}
|
||||
|
||||
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
|
||||
this._tilemapBuffers[0].renderDebugInfo(x, y, color);
|
||||
}
|
||||
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number): bool {
|
||||
|
||||
if (this.visible === false || this.scale.x == 0 || this.scale.y == 0 || this.alpha < 0.1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this._dx = cameraOffsetX + (this.bounds.x - camera.worldView.x);
|
||||
this._dy = cameraOffsetY + (this.bounds.y - camera.worldView.y);
|
||||
|
||||
this._dx = Math.round(this._dx);
|
||||
this._dy = Math.round(this._dy);
|
||||
|
||||
if (this._tilemapBuffers[camera.ID])
|
||||
{
|
||||
//this._tilemapBuffers[camera.ID].render(this._dx, this._dy);
|
||||
this._tilemapBuffers[camera.ID].render(cameraOffsetX, cameraOffsetY);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
128
Phaser/Time.ts
Normal file
|
@ -0,0 +1,128 @@
|
|||
class Time {
|
||||
|
||||
constructor(game: Game) {
|
||||
|
||||
this._started = Date.now();
|
||||
this._timeLastSecond = this._started;
|
||||
this.time = this._started;
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
private _started: number;
|
||||
|
||||
|
||||
public timeScale: number = 1.0;
|
||||
public elapsed: number = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property time
|
||||
* @type Number
|
||||
*/
|
||||
public time: number = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property now
|
||||
* @type Number
|
||||
*/
|
||||
public now: number = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property delta
|
||||
* @type Number
|
||||
*/
|
||||
public delta: number = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
* @method totalElapsedSeconds
|
||||
* @return {Number}
|
||||
*/
|
||||
public get totalElapsedSeconds(): number {
|
||||
|
||||
return (this.now - this._started) * 0.001;
|
||||
|
||||
}
|
||||
|
||||
public fps: number = 0;
|
||||
public fpsMin: number = 1000;
|
||||
public fpsMax: number = 0;
|
||||
public msMin: number = 1000;
|
||||
public msMax: number = 0;
|
||||
public frames: number = 0;
|
||||
|
||||
private _timeLastSecond: number = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
* @method update
|
||||
*/
|
||||
public update() {
|
||||
|
||||
// Can we use performance.now() ?
|
||||
this.now = Date.now(); // mark
|
||||
this.delta = this.now - this.time; // elapsedMS
|
||||
|
||||
this.msMin = Math.min(this.msMin, this.delta);
|
||||
this.msMax = Math.max(this.msMax, this.delta);
|
||||
|
||||
this.frames++;
|
||||
|
||||
if (this.now > this._timeLastSecond + 1000)
|
||||
{
|
||||
this.fps = Math.round((this.frames * 1000) / (this.now - this._timeLastSecond));
|
||||
this.fpsMin = Math.min(this.fpsMin, this.fps);
|
||||
this.fpsMax = Math.max(this.fpsMax, this.fps);
|
||||
|
||||
this._timeLastSecond = this.now;
|
||||
this.frames = 0;
|
||||
}
|
||||
|
||||
this.time = this.now; // _total
|
||||
|
||||
//// Lock the delta at 0.1 to minimise fps tunneling
|
||||
//if (this.delta > 0.1)
|
||||
//{
|
||||
// this.delta = 0.1;
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @method elapsedSince
|
||||
* @param {Number} since
|
||||
* @return {Number}
|
||||
*/
|
||||
public elapsedSince(since: number): number {
|
||||
|
||||
return this.now - since;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @method elapsedSecondsSince
|
||||
* @param {Number} since
|
||||
* @return {Number}
|
||||
*/
|
||||
public elapsedSecondsSince(since: number): number {
|
||||
|
||||
return (this.now - since) * 0.001;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @method reset
|
||||
*/
|
||||
public reset() {
|
||||
|
||||
this._started = this.now;
|
||||
|
||||
}
|
||||
|
||||
}
|
466
Phaser/World.ts
Normal file
|
@ -0,0 +1,466 @@
|
|||
/// <reference path="Cameras.ts" />
|
||||
/// <reference path="Game.ts" />
|
||||
/// <reference path="GameMath.ts" />
|
||||
/// <reference path="Group.ts" />
|
||||
/// <reference path="Rectangle.ts" />
|
||||
/// <reference path="Point.ts" />
|
||||
/// <reference path="Sprite.ts" />
|
||||
/// <reference path="Tilemap.ts" />
|
||||
/// <reference path="system/Camera.ts" />
|
||||
/// <reference path="system/QuadTree.ts" />
|
||||
|
||||
class World {
|
||||
|
||||
constructor(game: Game, width: number, height: number) {
|
||||
|
||||
this._game = game;
|
||||
|
||||
this._cameras = new Cameras(this._game, 0, 0, width, height);
|
||||
|
||||
this._game.camera = this._cameras.current;
|
||||
|
||||
this.group = new Group(this._game, 0);
|
||||
|
||||
this.bounds = new Rectangle(0, 0, width, height);
|
||||
|
||||
this.worldDivisions = 6;
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
private _cameras: Cameras;
|
||||
|
||||
public group: Group;
|
||||
public bounds: Rectangle;
|
||||
public worldDivisions: number;
|
||||
|
||||
public update() {
|
||||
|
||||
this.group.preUpdate();
|
||||
this.group.update();
|
||||
this.group.postUpdate();
|
||||
|
||||
this._cameras.update();
|
||||
|
||||
}
|
||||
|
||||
public render() {
|
||||
|
||||
// Unlike in flixel our render process is camera driven, not group driven
|
||||
this._cameras.render();
|
||||
|
||||
}
|
||||
|
||||
public destroy() {
|
||||
|
||||
this.group.destroy();
|
||||
|
||||
this._cameras.destroy();
|
||||
|
||||
}
|
||||
|
||||
// World methods
|
||||
|
||||
public setSize(width: number, height: number) {
|
||||
|
||||
this.bounds.width = width;
|
||||
this.bounds.height = height;
|
||||
|
||||
}
|
||||
|
||||
public get width(): number {
|
||||
return this.bounds.width;
|
||||
}
|
||||
|
||||
public set width(value: number) {
|
||||
this.bounds.width = value;
|
||||
}
|
||||
|
||||
public get height(): number {
|
||||
return this.bounds.height;
|
||||
}
|
||||
|
||||
public set height(value: number) {
|
||||
this.bounds.height = value;
|
||||
}
|
||||
|
||||
public get centerX(): number {
|
||||
return this.bounds.halfWidth;
|
||||
}
|
||||
|
||||
public get centerY(): number {
|
||||
return this.bounds.halfHeight;
|
||||
}
|
||||
|
||||
public get randomX(): number {
|
||||
return Math.round(Math.random() * this.bounds.width);
|
||||
}
|
||||
|
||||
public get randomY(): number {
|
||||
return Math.round(Math.random() * this.bounds.height);
|
||||
}
|
||||
|
||||
// Cameras
|
||||
|
||||
public addExistingCamera(cam: Camera): Camera {
|
||||
//return this._cameras.addCamera(x, y, width, height);
|
||||
return cam;
|
||||
}
|
||||
|
||||
public createCamera(x: number, y: number, width: number, height: number): Camera {
|
||||
return this._cameras.addCamera(x, y, width, height);
|
||||
}
|
||||
|
||||
public removeCamera(id: number): bool {
|
||||
return this._cameras.removeCamera(id);
|
||||
}
|
||||
|
||||
public getAllCameras(): Camera[] {
|
||||
return this._cameras.getAll();
|
||||
}
|
||||
|
||||
// Sprites
|
||||
|
||||
public addExistingSprite(sprite: Sprite): Sprite {
|
||||
return <Sprite> this.group.add(sprite);
|
||||
}
|
||||
|
||||
public createSprite(x: number, y: number, key?: string = ''): Sprite {
|
||||
return <Sprite> this.group.add(new Sprite(this._game, x, y, key));
|
||||
}
|
||||
|
||||
public createGroup(MaxSize?: number = 0): Group {
|
||||
return <Group> this.group.add(new Group(this._game, MaxSize));
|
||||
}
|
||||
|
||||
// Tilemaps
|
||||
|
||||
public createTilemap(key:string, mapData:string, format:number, tileWidth?:number,tileHeight?:number): Tilemap {
|
||||
return <Tilemap> this.group.add(new Tilemap(this._game, key, mapData, format, tileWidth, tileHeight));
|
||||
}
|
||||
|
||||
// Emitters
|
||||
|
||||
public createParticle(): Particle {
|
||||
return new Particle(this._game);
|
||||
}
|
||||
|
||||
public createEmitter(x?: number = 0, y?: number = 0, size?:number = 0): Emitter {
|
||||
return <Emitter> this.group.add(new Emitter(this._game, x, y, size));
|
||||
}
|
||||
|
||||
// Collision
|
||||
|
||||
/**
|
||||
* Call this function to see if one <code>GameObject</code> overlaps another.
|
||||
* Can be called with one object and one group, or two groups, or two objects,
|
||||
* whatever floats your boat! For maximum performance try bundling a lot of objects
|
||||
* together using a <code>FlxGroup</code> (or even bundling groups together!).
|
||||
*
|
||||
* <p>NOTE: does NOT take objects' scrollfactor into account, all overlaps are checked in world space.</p>
|
||||
*
|
||||
* @param ObjectOrGroup1 The first object or group you want to check.
|
||||
* @param ObjectOrGroup2 The second object or group you want to check. If it is the same as the first, flixel knows to just do a comparison within that group.
|
||||
* @param NotifyCallback A function with two <code>GameObject</code> parameters - e.g. <code>myOverlapFunction(Object1:GameObject,Object2:GameObject)</code> - that is called if those two objects overlap.
|
||||
* @param ProcessCallback A function with two <code>GameObject</code> parameters - e.g. <code>myOverlapFunction(Object1:GameObject,Object2:GameObject)</code> - that is called if those two objects overlap. If a ProcessCallback is provided, then NotifyCallback will only be called if ProcessCallback returns true for those objects!
|
||||
*
|
||||
* @return Whether any overlaps were detected.
|
||||
*/
|
||||
public overlap(ObjectOrGroup1: Basic = null, ObjectOrGroup2: Basic = null, NotifyCallback = null, ProcessCallback = null): bool {
|
||||
|
||||
if (ObjectOrGroup1 == null)
|
||||
{
|
||||
ObjectOrGroup1 = this.group;
|
||||
}
|
||||
|
||||
if (ObjectOrGroup2 == ObjectOrGroup1)
|
||||
{
|
||||
ObjectOrGroup2 = null;
|
||||
}
|
||||
|
||||
QuadTree.divisions = this.worldDivisions;
|
||||
|
||||
var quadTree: QuadTree = new QuadTree(this.bounds.x, this.bounds.y, this.bounds.width, this.bounds.height);
|
||||
|
||||
quadTree.load(ObjectOrGroup1, ObjectOrGroup2, NotifyCallback, ProcessCallback);
|
||||
|
||||
var result: bool = quadTree.execute();
|
||||
|
||||
quadTree.destroy();
|
||||
|
||||
quadTree = null;
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The main collision resolution in flixel.
|
||||
*
|
||||
* @param Object1 Any <code>Sprite</code>.
|
||||
* @param Object2 Any other <code>Sprite</code>.
|
||||
*
|
||||
* @return Whether the objects in fact touched and were separated.
|
||||
*/
|
||||
public static separate(Object1, Object2): bool {
|
||||
|
||||
var separatedX: bool = World.separateX(Object1, Object2);
|
||||
var separatedY: bool = World.separateY(Object1, Object2);
|
||||
|
||||
return separatedX || separatedY;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The X-axis component of the object separation process.
|
||||
*
|
||||
* @param Object1 Any <code>Sprite</code>.
|
||||
* @param Object2 Any other <code>Sprite</code>.
|
||||
*
|
||||
* @return Whether the objects in fact touched and were separated along the X axis.
|
||||
*/
|
||||
public static separateX(Object1, Object2): bool {
|
||||
|
||||
//can't separate two immovable objects
|
||||
var obj1immovable: bool = Object1.immovable;
|
||||
var obj2immovable: bool = Object2.immovable;
|
||||
|
||||
if (obj1immovable && obj2immovable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//If one of the objects is a tilemap, just pass it off.
|
||||
/*
|
||||
if (typeof Object1 === 'FlxTilemap')
|
||||
{
|
||||
return Object1.overlapsWithCallback(Object2, separateX);
|
||||
}
|
||||
|
||||
if (typeof Object2 === 'FlxTilemap')
|
||||
{
|
||||
return Object2.overlapsWithCallback(Object1, separateX, true);
|
||||
}
|
||||
*/
|
||||
|
||||
//First, get the two object deltas
|
||||
var overlap: number = 0;
|
||||
var obj1delta: number = Object1.x - Object1.last.x;
|
||||
var obj2delta: number = Object2.x - Object2.last.x;
|
||||
|
||||
if (obj1delta != obj2delta)
|
||||
{
|
||||
//Check if the X hulls actually overlap
|
||||
var obj1deltaAbs: number = (obj1delta > 0) ? obj1delta : -obj1delta;
|
||||
var obj2deltaAbs: number = (obj2delta > 0) ? obj2delta : -obj2delta;
|
||||
var obj1rect: Rectangle = new Rectangle(Object1.x - ((obj1delta > 0) ? obj1delta : 0), Object1.last.y, Object1.width + ((obj1delta > 0) ? obj1delta : -obj1delta), Object1.height);
|
||||
var obj2rect: Rectangle = new Rectangle(Object2.x - ((obj2delta > 0) ? obj2delta : 0), Object2.last.y, Object2.width + ((obj2delta > 0) ? obj2delta : -obj2delta), Object2.height);
|
||||
|
||||
if ((obj1rect.x + obj1rect.width > obj2rect.x) && (obj1rect.x < obj2rect.x + obj2rect.width) && (obj1rect.y + obj1rect.height > obj2rect.y) && (obj1rect.y < obj2rect.y + obj2rect.height))
|
||||
{
|
||||
var maxOverlap: number = obj1deltaAbs + obj2deltaAbs + GameObject.OVERLAP_BIAS;
|
||||
|
||||
//If they did overlap (and can), figure out by how much and flip the corresponding flags
|
||||
if (obj1delta > obj2delta)
|
||||
{
|
||||
overlap = Object1.x + Object1.width - Object2.x;
|
||||
|
||||
if ((overlap > maxOverlap) || !(Object1.allowCollisions & GameObject.RIGHT) || !(Object2.allowCollisions & GameObject.LEFT))
|
||||
{
|
||||
overlap = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Object1.touching |= GameObject.RIGHT;
|
||||
Object2.touching |= GameObject.LEFT;
|
||||
}
|
||||
}
|
||||
else if (obj1delta < obj2delta)
|
||||
{
|
||||
overlap = Object1.x - Object2.width - Object2.x;
|
||||
|
||||
if ((-overlap > maxOverlap) || !(Object1.allowCollisions & GameObject.LEFT) || !(Object2.allowCollisions & GameObject.RIGHT))
|
||||
{
|
||||
overlap = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Object1.touching |= GameObject.LEFT;
|
||||
Object2.touching |= GameObject.RIGHT;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Then adjust their positions and velocities accordingly (if there was any overlap)
|
||||
if (overlap != 0)
|
||||
{
|
||||
var obj1v: number = Object1.velocity.x;
|
||||
var obj2v: number = Object2.velocity.x;
|
||||
|
||||
if (!obj1immovable && !obj2immovable)
|
||||
{
|
||||
overlap *= 0.5;
|
||||
Object1.x = Object1.x - overlap;
|
||||
Object2.x += overlap;
|
||||
|
||||
var obj1velocity: number = Math.sqrt((obj2v * obj2v * Object2.mass) / Object1.mass) * ((obj2v > 0) ? 1 : -1);
|
||||
var obj2velocity: number = Math.sqrt((obj1v * obj1v * Object1.mass) / Object2.mass) * ((obj1v > 0) ? 1 : -1);
|
||||
var average: number = (obj1velocity + obj2velocity) * 0.5;
|
||||
obj1velocity -= average;
|
||||
obj2velocity -= average;
|
||||
Object1.velocity.x = average + obj1velocity * Object1.elasticity;
|
||||
Object2.velocity.x = average + obj2velocity * Object2.elasticity;
|
||||
}
|
||||
else if (!obj1immovable)
|
||||
{
|
||||
Object1.x = Object1.x - overlap;
|
||||
Object1.velocity.x = obj2v - obj1v * Object1.elasticity;
|
||||
}
|
||||
else if (!obj2immovable)
|
||||
{
|
||||
Object2.x += overlap;
|
||||
Object2.velocity.x = obj1v - obj2v * Object2.elasticity;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The Y-axis component of the object separation process.
|
||||
*
|
||||
* @param Object1 Any <code>Sprite</code>.
|
||||
* @param Object2 Any other <code>Sprite</code>.
|
||||
*
|
||||
* @return Whether the objects in fact touched and were separated along the Y axis.
|
||||
*/
|
||||
public static separateY(Object1, Object2): bool {
|
||||
|
||||
//can't separate two immovable objects
|
||||
|
||||
var obj1immovable: bool = Object1.immovable;
|
||||
var obj2immovable: bool = Object2.immovable;
|
||||
|
||||
if (obj1immovable && obj2immovable)
|
||||
return false;
|
||||
|
||||
//If one of the objects is a tilemap, just pass it off.
|
||||
/*
|
||||
if (typeof Object1 === 'FlxTilemap')
|
||||
{
|
||||
return Object1.overlapsWithCallback(Object2, separateY);
|
||||
}
|
||||
|
||||
if (typeof Object2 === 'FlxTilemap')
|
||||
{
|
||||
return Object2.overlapsWithCallback(Object1, separateY, true);
|
||||
}
|
||||
*/
|
||||
|
||||
//First, get the two object deltas
|
||||
var overlap: number = 0;
|
||||
var obj1delta: number = Object1.y - Object1.last.y;
|
||||
var obj2delta: number = Object2.y - Object2.last.y;
|
||||
|
||||
if (obj1delta != obj2delta)
|
||||
{
|
||||
//Check if the Y hulls actually overlap
|
||||
var obj1deltaAbs: number = (obj1delta > 0) ? obj1delta : -obj1delta;
|
||||
var obj2deltaAbs: number = (obj2delta > 0) ? obj2delta : -obj2delta;
|
||||
var obj1rect: Rectangle = new Rectangle(Object1.x, Object1.y - ((obj1delta > 0) ? obj1delta : 0), Object1.width, Object1.height + obj1deltaAbs);
|
||||
var obj2rect: Rectangle = new Rectangle(Object2.x, Object2.y - ((obj2delta > 0) ? obj2delta : 0), Object2.width, Object2.height + obj2deltaAbs);
|
||||
|
||||
if ((obj1rect.x + obj1rect.width > obj2rect.x) && (obj1rect.x < obj2rect.x + obj2rect.width) && (obj1rect.y + obj1rect.height > obj2rect.y) && (obj1rect.y < obj2rect.y + obj2rect.height))
|
||||
{
|
||||
var maxOverlap: number = obj1deltaAbs + obj2deltaAbs + GameObject.OVERLAP_BIAS;
|
||||
|
||||
//If they did overlap (and can), figure out by how much and flip the corresponding flags
|
||||
if (obj1delta > obj2delta)
|
||||
{
|
||||
overlap = Object1.y + Object1.height - Object2.y;
|
||||
|
||||
if ((overlap > maxOverlap) || !(Object1.allowCollisions & GameObject.DOWN) || !(Object2.allowCollisions & GameObject.UP))
|
||||
{
|
||||
overlap = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Object1.touching |= GameObject.DOWN;
|
||||
Object2.touching |= GameObject.UP;
|
||||
}
|
||||
}
|
||||
else if (obj1delta < obj2delta)
|
||||
{
|
||||
overlap = Object1.y - Object2.height - Object2.y;
|
||||
|
||||
if ((-overlap > maxOverlap) || !(Object1.allowCollisions & GameObject.UP) || !(Object2.allowCollisions & GameObject.DOWN))
|
||||
{
|
||||
overlap = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Object1.touching |= GameObject.UP;
|
||||
Object2.touching |= GameObject.DOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Then adjust their positions and velocities accordingly (if there was any overlap)
|
||||
if (overlap != 0)
|
||||
{
|
||||
var obj1v: number = Object1.velocity.y;
|
||||
var obj2v: number = Object2.velocity.y;
|
||||
|
||||
if (!obj1immovable && !obj2immovable)
|
||||
{
|
||||
overlap *= 0.5;
|
||||
Object1.y = Object1.y - overlap;
|
||||
Object2.y += overlap;
|
||||
|
||||
var obj1velocity: number = Math.sqrt((obj2v * obj2v * Object2.mass) / Object1.mass) * ((obj2v > 0) ? 1 : -1);
|
||||
var obj2velocity: number = Math.sqrt((obj1v * obj1v * Object1.mass) / Object2.mass) * ((obj1v > 0) ? 1 : -1);
|
||||
var average: number = (obj1velocity + obj2velocity) * 0.5;
|
||||
obj1velocity -= average;
|
||||
obj2velocity -= average;
|
||||
Object1.velocity.y = average + obj1velocity * Object1.elasticity;
|
||||
Object2.velocity.y = average + obj2velocity * Object2.elasticity;
|
||||
}
|
||||
else if (!obj1immovable)
|
||||
{
|
||||
Object1.y = Object1.y - overlap;
|
||||
Object1.velocity.y = obj2v - obj1v * Object1.elasticity;
|
||||
//This is special case code that handles cases like horizontal moving platforms you can ride
|
||||
if (Object2.active && Object2.moves && (obj1delta > obj2delta))
|
||||
{
|
||||
Object1.x += Object2.x - Object2.last.x;
|
||||
}
|
||||
}
|
||||
else if (!obj2immovable)
|
||||
{
|
||||
Object2.y += overlap;
|
||||
Object2.velocity.y = obj1v - obj2v * Object2.elasticity;
|
||||
//This is special case code that handles cases like horizontal moving platforms you can ride
|
||||
if (Object1.active && Object1.moves && (obj1delta < obj2delta))
|
||||
{
|
||||
Object2.x += Object1.x - Object1.last.x;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
670
Phaser/system/Camera.ts
Normal file
|
@ -0,0 +1,670 @@
|
|||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../GameMath.ts" />
|
||||
/// <reference path="../Rectangle.ts" />
|
||||
/// <reference path="../Point.ts" />
|
||||
|
||||
class Camera {
|
||||
|
||||
/**
|
||||
* Instantiates a new camera at the specified location, with the specified size and zoom level.
|
||||
*
|
||||
* @param X X location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom.
|
||||
* @param Y Y location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom.
|
||||
* @param Width The width of the camera display in pixels.
|
||||
* @param Height The height of the camera display in pixels.
|
||||
* @param Zoom The initial zoom level of the camera. A zoom level of 2 will make all pixels display at 2x resolution.
|
||||
*/
|
||||
constructor(game: Game, id: number, x: number, y: number, width: number, height: number) {
|
||||
|
||||
this._game = game;
|
||||
|
||||
this.ID = id;
|
||||
this._stageX = x;
|
||||
this._stageY = y;
|
||||
|
||||
// The view into the world canvas we wish to render
|
||||
this.worldView = new Rectangle(0, 0, width, height);
|
||||
|
||||
this.checkClip();
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
|
||||
private _clip: bool = false;
|
||||
private _stageX: number;
|
||||
private _stageY: number;
|
||||
private _rotation: number = 0;
|
||||
private _target: Sprite = null;
|
||||
private _sx: number = 0;
|
||||
private _sy: number = 0;
|
||||
|
||||
private _fxFlashColor: string;
|
||||
private _fxFlashComplete = null;
|
||||
private _fxFlashDuration: number = 0;
|
||||
private _fxFlashAlpha: number = 0;
|
||||
|
||||
private _fxFadeColor: string;
|
||||
private _fxFadeComplete = null;
|
||||
private _fxFadeDuration: number = 0;
|
||||
private _fxFadeAlpha: number = 0;
|
||||
|
||||
private _fxShakeIntensity: number = 0;
|
||||
private _fxShakeDuration: number = 0;
|
||||
private _fxShakeComplete = null;
|
||||
private _fxShakeOffset: Point = new Point(0, 0);
|
||||
private _fxShakeDirection: number = 0;
|
||||
private _fxShakePrevX: number = 0;
|
||||
private _fxShakePrevY: number = 0;
|
||||
|
||||
public static STYLE_LOCKON: number = 0;
|
||||
public static STYLE_PLATFORMER: number = 1;
|
||||
public static STYLE_TOPDOWN: number = 2;
|
||||
public static STYLE_TOPDOWN_TIGHT: number = 3;
|
||||
|
||||
public static SHAKE_BOTH_AXES: number = 0;
|
||||
public static SHAKE_HORIZONTAL_ONLY: number = 1;
|
||||
public static SHAKE_VERTICAL_ONLY: number = 2;
|
||||
|
||||
public ID: number;
|
||||
public worldView: Rectangle;
|
||||
public totalSpritesRendered: number;
|
||||
public scale: Point = new Point(1, 1);
|
||||
public scroll: Point = new Point(0, 0);
|
||||
public bounds: Rectangle = null;
|
||||
public deadzone: Rectangle = null;
|
||||
|
||||
// Camera Border
|
||||
public showBorder: bool = false;
|
||||
public borderColor: string = 'rgb(255,255,255)';
|
||||
|
||||
// Camera Background Color
|
||||
public opaque: bool = true;
|
||||
private _bgColor: string = 'rgb(0,0,0)';
|
||||
private _bgTexture;
|
||||
private _bgTextureRepeat: string = 'repeat';
|
||||
|
||||
// Camera Shadow
|
||||
public showShadow: bool = false;
|
||||
public shadowColor: string = 'rgb(0,0,0)';
|
||||
public shadowBlur: number = 10;
|
||||
public shadowOffset: Point = new Point(4, 4);
|
||||
|
||||
public visible: bool = true;
|
||||
public alpha: number = 1;
|
||||
|
||||
/**
|
||||
* The camera is filled with this color and returns to normal at the given duration.
|
||||
*
|
||||
* @param Color The color you want to use in 0xRRGGBB format, i.e. 0xffffff for white.
|
||||
* @param Duration How long it takes for the flash to fade.
|
||||
* @param OnComplete An optional function you want to run when the flash finishes. Set to null for no callback.
|
||||
* @param Force Force an already running flash effect to reset.
|
||||
*/
|
||||
public flash(color: number = 0xffffff, duration: number = 1, onComplete = null, force: bool = false) {
|
||||
|
||||
if (force === false && this._fxFlashAlpha > 0)
|
||||
{
|
||||
// You can't flash again unless you force it
|
||||
return;
|
||||
}
|
||||
|
||||
if (duration <= 0)
|
||||
{
|
||||
duration = 1;
|
||||
}
|
||||
|
||||
var red = color >> 16 & 0xFF;
|
||||
var green = color >> 8 & 0xFF;
|
||||
var blue = color & 0xFF;
|
||||
|
||||
this._fxFlashColor = 'rgba(' + red + ',' + green + ',' + blue + ',';
|
||||
this._fxFlashDuration = duration;
|
||||
this._fxFlashAlpha = 1;
|
||||
this._fxFlashComplete = onComplete;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The camera is gradually filled with this color.
|
||||
*
|
||||
* @param Color The color you want to use in 0xRRGGBB format, i.e. 0xffffff for white.
|
||||
* @param Duration How long it takes for the flash to fade.
|
||||
* @param OnComplete An optional function you want to run when the flash finishes. Set to null for no callback.
|
||||
* @param Force Force an already running flash effect to reset.
|
||||
*/
|
||||
public fade(color: number = 0x000000, duration: number = 1, onComplete = null, force: bool = false) {
|
||||
|
||||
if (force === false && this._fxFadeAlpha > 0)
|
||||
{
|
||||
// You can't fade again unless you force it
|
||||
return;
|
||||
}
|
||||
|
||||
if (duration <= 0)
|
||||
{
|
||||
duration = 1;
|
||||
}
|
||||
|
||||
var red = color >> 16 & 0xFF;
|
||||
var green = color >> 8 & 0xFF;
|
||||
var blue = color & 0xFF;
|
||||
|
||||
this._fxFadeColor = 'rgba(' + red + ',' + green + ',' + blue + ',';
|
||||
this._fxFadeDuration = duration;
|
||||
this._fxFadeAlpha = 0.01;
|
||||
this._fxFadeComplete = onComplete;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple screen-shake effect.
|
||||
*
|
||||
* @param Intensity Percentage of screen size representing the maximum distance that the screen can move while shaking.
|
||||
* @param Duration The length in seconds that the shaking effect should last.
|
||||
* @param OnComplete A function you want to run when the shake effect finishes.
|
||||
* @param Force Force the effect to reset (default = true, unlike flash() and fade()!).
|
||||
* @param Direction Whether to shake on both axes, just up and down, or just side to side (use class constants SHAKE_BOTH_AXES, SHAKE_VERTICAL_ONLY, or SHAKE_HORIZONTAL_ONLY).
|
||||
*/
|
||||
public shake(intensity: number = 0.05, duration: number = 0.5, onComplete = null, force: bool = true, direction: number = Camera.SHAKE_BOTH_AXES) {
|
||||
|
||||
if (!force && ((this._fxShakeOffset.x != 0) || (this._fxShakeOffset.y != 0)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// If a shake is not already running we need to store the offsets here
|
||||
if (this._fxShakeOffset.x == 0 && this._fxShakeOffset.y == 0)
|
||||
{
|
||||
this._fxShakePrevX = this._stageX;
|
||||
this._fxShakePrevY = this._stageY;
|
||||
}
|
||||
|
||||
this._fxShakeIntensity = intensity;
|
||||
this._fxShakeDuration = duration;
|
||||
this._fxShakeComplete = onComplete;
|
||||
this._fxShakeDirection = direction;
|
||||
this._fxShakeOffset.setTo(0, 0);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Just turns off all the camera effects instantly.
|
||||
*/
|
||||
public stopFX() {
|
||||
|
||||
this._fxFlashAlpha = 0;
|
||||
this._fxFadeAlpha = 0;
|
||||
|
||||
if (this._fxShakeDuration !== 0)
|
||||
{
|
||||
this._fxShakeDuration = 0;
|
||||
this._fxShakeOffset.setTo(0, 0);
|
||||
this._stageX = this._fxShakePrevX;
|
||||
this._stageY = this._fxShakePrevY;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public follow(target: Sprite, style?: number = Camera.STYLE_LOCKON) {
|
||||
|
||||
this._target = target;
|
||||
var helper: number;
|
||||
|
||||
switch (style)
|
||||
{
|
||||
case Camera.STYLE_PLATFORMER:
|
||||
var w: number = this.width / 8;
|
||||
var h: number = this.height / 3;
|
||||
this.deadzone = new Rectangle((this.width - w) / 2, (this.height - h) / 2 - h * 0.25, w, h);
|
||||
break;
|
||||
case Camera.STYLE_TOPDOWN:
|
||||
helper = Math.max(this.width, this.height) / 4;
|
||||
this.deadzone = new Rectangle((this.width - helper) / 2, (this.height - helper) / 2, helper, helper);
|
||||
break;
|
||||
case Camera.STYLE_TOPDOWN_TIGHT:
|
||||
helper = Math.max(this.width, this.height) / 8;
|
||||
this.deadzone = new Rectangle((this.width - helper) / 2, (this.height - helper) / 2, helper, helper);
|
||||
break;
|
||||
case Camera.STYLE_LOCKON:
|
||||
default:
|
||||
this.deadzone = null;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public focusOnXY(x: number, y: number) {
|
||||
|
||||
x += (x > 0) ? 0.0000001 : -0.0000001;
|
||||
y += (y > 0) ? 0.0000001 : -0.0000001;
|
||||
|
||||
this.scroll.x = Math.round(x - this.worldView.halfWidth);
|
||||
this.scroll.y = Math.round(y - this.worldView.halfHeight);
|
||||
|
||||
}
|
||||
|
||||
public focusOn(point: Point) {
|
||||
|
||||
point.x += (point.x > 0) ? 0.0000001 : -0.0000001;
|
||||
point.y += (point.y > 0) ? 0.0000001 : -0.0000001;
|
||||
|
||||
this.scroll.x = Math.round(point.x - this.worldView.halfWidth);
|
||||
this.scroll.y = Math.round(point.y - this.worldView.halfHeight);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the boundaries of the world or where the camera is allowed to move.
|
||||
*
|
||||
* @param X The smallest X value of your world (usually 0).
|
||||
* @param Y The smallest Y value of your world (usually 0).
|
||||
* @param Width The largest X value of your world (usually the world width).
|
||||
* @param Height The largest Y value of your world (usually the world height).
|
||||
* @param UpdateWorld Whether the global quad-tree's dimensions should be updated to match (default: false).
|
||||
*/
|
||||
public setBounds(X: number = 0, Y: number = 0, Width: number = 0, Height: number = 0, UpdateWorld: bool = false) {
|
||||
|
||||
if (this.bounds == null)
|
||||
{
|
||||
this.bounds = new Rectangle();
|
||||
}
|
||||
|
||||
this.bounds.setTo(X, Y, Width, Height);
|
||||
|
||||
//if(UpdateWorld)
|
||||
// FlxG.worldBounds.copyFrom(bounds);
|
||||
|
||||
this.update();
|
||||
}
|
||||
|
||||
public update() {
|
||||
|
||||
if (this._target !== null)
|
||||
{
|
||||
if (this.deadzone == null)
|
||||
{
|
||||
this.focusOnXY(this._target.x + this._target.origin.x, this._target.y + this._target.origin.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
var edge: number;
|
||||
var targetX: number = this._target.x + ((this._target.x > 0) ? 0.0000001 : -0.0000001);
|
||||
var targetY: number = this._target.y + ((this._target.y > 0) ? 0.0000001 : -0.0000001);
|
||||
|
||||
edge = targetX - this.deadzone.x;
|
||||
|
||||
if (this.scroll.x > edge)
|
||||
{
|
||||
this.scroll.x = edge;
|
||||
}
|
||||
|
||||
edge = targetX + this._target.width - this.deadzone.x - this.deadzone.width;
|
||||
|
||||
if (this.scroll.x < edge)
|
||||
{
|
||||
this.scroll.x = edge;
|
||||
}
|
||||
|
||||
edge = targetY - this.deadzone.y;
|
||||
|
||||
if (this.scroll.y > edge)
|
||||
{
|
||||
this.scroll.y = edge;
|
||||
}
|
||||
|
||||
edge = targetY + this._target.height - this.deadzone.y - this.deadzone.height;
|
||||
|
||||
if (this.scroll.y < edge)
|
||||
{
|
||||
this.scroll.y = edge;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Make sure we didn't go outside the camera's bounds
|
||||
if (this.bounds !== null)
|
||||
{
|
||||
if (this.scroll.x < this.bounds.left)
|
||||
{
|
||||
this.scroll.x = this.bounds.left;
|
||||
}
|
||||
|
||||
if (this.scroll.x > this.bounds.right - this.width)
|
||||
{
|
||||
this.scroll.x = this.bounds.right - this.width;
|
||||
}
|
||||
|
||||
if (this.scroll.y < this.bounds.top)
|
||||
{
|
||||
this.scroll.y = this.bounds.top;
|
||||
}
|
||||
|
||||
if (this.scroll.y > this.bounds.bottom - this.height)
|
||||
{
|
||||
this.scroll.y = this.bounds.bottom - this.height;
|
||||
}
|
||||
}
|
||||
|
||||
this.worldView.x = this.scroll.x;
|
||||
this.worldView.y = this.scroll.y;
|
||||
|
||||
// Update the Flash effect
|
||||
if (this._fxFlashAlpha > 0)
|
||||
{
|
||||
this._fxFlashAlpha -= this._game.time.elapsed / this._fxFlashDuration;
|
||||
this._fxFlashAlpha = this._game.math.roundTo(this._fxFlashAlpha, -2);
|
||||
|
||||
if (this._fxFlashAlpha <= 0)
|
||||
{
|
||||
this._fxFlashAlpha = 0;
|
||||
|
||||
if (this._fxFlashComplete !== null)
|
||||
{
|
||||
this._fxFlashComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update the Fade effect
|
||||
if (this._fxFadeAlpha > 0)
|
||||
{
|
||||
this._fxFadeAlpha += this._game.time.elapsed / this._fxFadeDuration;
|
||||
this._fxFadeAlpha = this._game.math.roundTo(this._fxFadeAlpha, -2);
|
||||
|
||||
if (this._fxFadeAlpha >= 1)
|
||||
{
|
||||
this._fxFadeAlpha = 1;
|
||||
|
||||
if (this._fxFadeComplete !== null)
|
||||
{
|
||||
this._fxFadeComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update the "shake" special effect
|
||||
if (this._fxShakeDuration > 0)
|
||||
{
|
||||
this._fxShakeDuration -= this._game.time.elapsed;
|
||||
this._fxShakeDuration = this._game.math.roundTo(this._fxShakeDuration, -2);
|
||||
|
||||
if (this._fxShakeDuration <= 0)
|
||||
{
|
||||
this._fxShakeDuration = 0;
|
||||
this._fxShakeOffset.setTo(0, 0);
|
||||
this._stageX = this._fxShakePrevX;
|
||||
this._stageY = this._fxShakePrevY;
|
||||
|
||||
if (this._fxShakeComplete != null)
|
||||
{
|
||||
this._fxShakeComplete();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((this._fxShakeDirection == Camera.SHAKE_BOTH_AXES) || (this._fxShakeDirection == Camera.SHAKE_HORIZONTAL_ONLY))
|
||||
{
|
||||
//this._fxShakeOffset.x = ((this._game.math.random() * this._fxShakeIntensity * this.worldView.width * 2 - this._fxShakeIntensity * this.worldView.width) * this._zoom;
|
||||
this._fxShakeOffset.x = (this._game.math.random() * this._fxShakeIntensity * this.worldView.width * 2 - this._fxShakeIntensity * this.worldView.width);
|
||||
}
|
||||
|
||||
if ((this._fxShakeDirection == Camera.SHAKE_BOTH_AXES) || (this._fxShakeDirection == Camera.SHAKE_VERTICAL_ONLY))
|
||||
{
|
||||
//this._fxShakeOffset.y = (this._game.math.random() * this._fxShakeIntensity * this.worldView.height * 2 - this._fxShakeIntensity * this.worldView.height) * this._zoom;
|
||||
this._fxShakeOffset.y = (this._game.math.random() * this._fxShakeIntensity * this.worldView.height * 2 - this._fxShakeIntensity * this.worldView.height);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public render() {
|
||||
|
||||
if (this.visible === false && this.alpha < 0.1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((this._fxShakeOffset.x != 0) || (this._fxShakeOffset.y != 0))
|
||||
{
|
||||
//this._stageX = this._fxShakePrevX + (this.worldView.halfWidth * this._zoom) + this._fxShakeOffset.x;
|
||||
//this._stageY = this._fxShakePrevY + (this.worldView.halfHeight * this._zoom) + this._fxShakeOffset.y;
|
||||
this._stageX = this._fxShakePrevX + (this.worldView.halfWidth) + this._fxShakeOffset.x;
|
||||
this._stageY = this._fxShakePrevY + (this.worldView.halfHeight) + this._fxShakeOffset.y;
|
||||
//console.log('shake', this._fxShakeDuration, this._fxShakeIntensity, this._fxShakeOffset.x, this._fxShakeOffset.y);
|
||||
}
|
||||
|
||||
//if (this._rotation !== 0 || this._clip || this.scale.x !== 1 || this.scale.y !== 1)
|
||||
//{
|
||||
//this._game.stage.context.save();
|
||||
//}
|
||||
|
||||
// It may be safe/quicker to just save the context every frame regardless
|
||||
this._game.stage.context.save();
|
||||
|
||||
if (this.alpha !== 1)
|
||||
{
|
||||
this._game.stage.context.globalAlpha = this.alpha;
|
||||
}
|
||||
|
||||
this._sx = this._stageX;
|
||||
this._sy = this._stageY;
|
||||
|
||||
// Shadow
|
||||
if (this.showShadow)
|
||||
{
|
||||
this._game.stage.context.shadowColor = this.shadowColor;
|
||||
this._game.stage.context.shadowBlur = this.shadowBlur;
|
||||
this._game.stage.context.shadowOffsetX = this.shadowOffset.x;
|
||||
this._game.stage.context.shadowOffsetY = this.shadowOffset.y;
|
||||
}
|
||||
|
||||
// Scale on
|
||||
if (this.scale.x !== 1 || this.scale.y !== 1)
|
||||
{
|
||||
this._game.stage.context.scale(this.scale.x, this.scale.y);
|
||||
this._sx = this._sx / this.scale.x;
|
||||
this._sy = this._sy / this.scale.y;
|
||||
}
|
||||
|
||||
// Rotation - translate to the mid-point of the camera
|
||||
if (this._rotation !== 0)
|
||||
{
|
||||
this._game.stage.context.translate(this._sx + this.worldView.halfWidth, this._sy + this.worldView.halfHeight);
|
||||
this._game.stage.context.rotate(this._rotation * (Math.PI / 180));
|
||||
|
||||
// now shift back to where that should actually render
|
||||
this._game.stage.context.translate(-(this._sx + this.worldView.halfWidth), -(this._sy + this.worldView.halfHeight));
|
||||
}
|
||||
|
||||
|
||||
// Background
|
||||
if (this.opaque == true)
|
||||
{
|
||||
if (this._bgTexture)
|
||||
{
|
||||
this._game.stage.context.fillStyle = this._bgTexture;
|
||||
this._game.stage.context.fillRect(this._sx, this._sy, this.worldView.width, this.worldView.height);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._game.stage.context.fillStyle = this._bgColor;
|
||||
this._game.stage.context.fillRect(this._sx, this._sy, this.worldView.width, this.worldView.height);
|
||||
}
|
||||
}
|
||||
|
||||
// Shadow off
|
||||
if (this.showShadow)
|
||||
{
|
||||
this._game.stage.context.shadowBlur = 0;
|
||||
this._game.stage.context.shadowOffsetX = 0;
|
||||
this._game.stage.context.shadowOffsetY = 0;
|
||||
}
|
||||
|
||||
// Clip the camera so we don't get sprites appearing outside the edges
|
||||
if (this._clip)
|
||||
{
|
||||
this._game.stage.context.beginPath();
|
||||
this._game.stage.context.rect(this._sx, this._sy, this.worldView.width, this.worldView.height);
|
||||
this._game.stage.context.closePath();
|
||||
this._game.stage.context.clip();
|
||||
}
|
||||
|
||||
//this.totalSpritesRendered = this._game.world.renderSpritesInCamera(this.worldView, sx, sy);
|
||||
//this._game.world.group.render(this.worldView, this.worldView.x, this.worldView.y, sx, sy);
|
||||
this._game.world.group.render(this, this._sx, this._sy);
|
||||
|
||||
if (this.showBorder)
|
||||
{
|
||||
this._game.stage.context.strokeStyle = this.borderColor;
|
||||
this._game.stage.context.lineWidth = 1;
|
||||
this._game.stage.context.rect(this._sx, this._sy, this.worldView.width, this.worldView.height);
|
||||
this._game.stage.context.stroke();
|
||||
}
|
||||
|
||||
// "Flash" FX
|
||||
if (this._fxFlashAlpha > 0)
|
||||
{
|
||||
this._game.stage.context.fillStyle = this._fxFlashColor + this._fxFlashAlpha + ')';
|
||||
this._game.stage.context.fillRect(this._sx, this._sy, this.worldView.width, this.worldView.height);
|
||||
}
|
||||
|
||||
// "Fade" FX
|
||||
if (this._fxFadeAlpha > 0)
|
||||
{
|
||||
this._game.stage.context.fillStyle = this._fxFadeColor + this._fxFadeAlpha + ')';
|
||||
this._game.stage.context.fillRect(this._sx, this._sy, this.worldView.width, this.worldView.height);
|
||||
}
|
||||
|
||||
// Scale off
|
||||
if (this.scale.x !== 1 || this.scale.y !== 1)
|
||||
{
|
||||
this._game.stage.context.scale(1, 1);
|
||||
}
|
||||
|
||||
if (this._rotation !== 0 || this._clip)
|
||||
{
|
||||
this._game.stage.context.translate(0, 0);
|
||||
//this._game.stage.context.restore();
|
||||
}
|
||||
|
||||
// maybe just do this every frame regardless?
|
||||
this._game.stage.context.restore();
|
||||
|
||||
if (this.alpha !== 1)
|
||||
{
|
||||
this._game.stage.context.globalAlpha = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public set backgroundColor(color: string) {
|
||||
|
||||
this._bgColor = color;
|
||||
|
||||
}
|
||||
|
||||
public get backgroundColor(): string {
|
||||
return this._bgColor;
|
||||
}
|
||||
|
||||
public setTexture(key:string, repeat?: string = 'repeat') {
|
||||
|
||||
this._bgTexture = this._game.stage.context.createPattern(this._game.cache.getImage(key), repeat);
|
||||
this._bgTextureRepeat = repeat;
|
||||
|
||||
}
|
||||
|
||||
public setPosition(x: number, y: number) {
|
||||
|
||||
this._stageX = x;
|
||||
this._stageY = y;
|
||||
|
||||
this.checkClip();
|
||||
|
||||
}
|
||||
|
||||
public setSize(width: number, height: number) {
|
||||
|
||||
this.worldView.width = width;
|
||||
this.worldView.height = height;
|
||||
|
||||
this.checkClip();
|
||||
|
||||
}
|
||||
|
||||
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
|
||||
|
||||
this._game.stage.context.fillStyle = color;
|
||||
this._game.stage.context.fillText('Camera ID: ' + this.ID + ' (' + this.worldView.width + ' x ' + this.worldView.height + ')', x, y);
|
||||
this._game.stage.context.fillText('X: ' + this._stageX + ' Y: ' + this._stageY + ' Rotation: ' + this._rotation, x, y + 14);
|
||||
this._game.stage.context.fillText('World X: ' + this.scroll.x.toFixed(1) + ' World Y: ' + this.scroll.y.toFixed(1), x, y + 28);
|
||||
|
||||
if (this.bounds)
|
||||
{
|
||||
this._game.stage.context.fillText('Bounds: ' + this.bounds.width + ' x ' + this.bounds.height, x, y + 56);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public get x(): number {
|
||||
return this._stageX;
|
||||
}
|
||||
|
||||
public set x(value: number) {
|
||||
this._stageX = value;
|
||||
this.checkClip();
|
||||
}
|
||||
|
||||
public get y(): number {
|
||||
return this._stageY;
|
||||
}
|
||||
|
||||
public set y(value: number) {
|
||||
this._stageY = value;
|
||||
this.checkClip();
|
||||
}
|
||||
|
||||
public get width(): number {
|
||||
return this.worldView.width;
|
||||
}
|
||||
|
||||
public set width(value: number) {
|
||||
this.worldView.width = value;
|
||||
this.checkClip();
|
||||
}
|
||||
|
||||
public get height(): number {
|
||||
return this.worldView.height;
|
||||
}
|
||||
|
||||
public set height(value: number) {
|
||||
this.worldView.height = value;
|
||||
this.checkClip();
|
||||
}
|
||||
|
||||
public get rotation(): number {
|
||||
return this._rotation;
|
||||
}
|
||||
|
||||
public set rotation(value: number) {
|
||||
this._rotation = this._game.math.wrap(value, 360, 0);
|
||||
}
|
||||
|
||||
private checkClip() {
|
||||
|
||||
if (this._stageX !== 0 || this._stageY !== 0 || this.worldView.width < this._game.stage.width || this.worldView.height < this._game.stage.height)
|
||||
{
|
||||
this._clip = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._clip = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
45
Phaser/system/LinkedList.ts
Normal file
|
@ -0,0 +1,45 @@
|
|||
/// <reference path="../Basic.ts" />
|
||||
|
||||
/**
|
||||
* A miniature linked list class.
|
||||
* Useful for optimizing time-critical or highly repetitive tasks!
|
||||
* See <code>QuadTree</code> for how to use it, IF YOU DARE.
|
||||
*/
|
||||
class LinkedList {
|
||||
|
||||
/**
|
||||
* Creates a new link, and sets <code>object</code> and <code>next</code> to <code>null</code>.
|
||||
*/
|
||||
constructor() {
|
||||
|
||||
this.object = null;
|
||||
this.next = null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores a reference to an <code>Basic</code>.
|
||||
*/
|
||||
public object: Basic;
|
||||
|
||||
/**
|
||||
* Stores a reference to the next link in the list.
|
||||
*/
|
||||
public next: LinkedList;
|
||||
|
||||
/**
|
||||
* Clean up memory.
|
||||
*/
|
||||
public destroy() {
|
||||
|
||||
this.object = null;
|
||||
|
||||
if (this.next != null)
|
||||
{
|
||||
this.next.destroy();
|
||||
}
|
||||
|
||||
this.next = null;
|
||||
|
||||
}
|
||||
}
|
768
Phaser/system/QuadTree.ts
Normal file
|
@ -0,0 +1,768 @@
|
|||
/// <reference path="../Rectangle.ts" />
|
||||
/// <reference path="../Basic.ts" />
|
||||
/// <reference path="LinkedList.ts" />
|
||||
|
||||
/**
|
||||
* A fairly generic quad tree structure for rapid overlap checks.
|
||||
* QuadTree is also configured for single or dual list operation.
|
||||
* You can add items either to its A list or its B list.
|
||||
* When you do an overlap check, you can compare the A list to itself,
|
||||
* or the A list against the B list. Handy for different things!
|
||||
*/
|
||||
class QuadTree extends Rectangle {
|
||||
|
||||
/**
|
||||
* Instantiate a new Quad Tree node.
|
||||
*
|
||||
* @param X The X-coordinate of the point in space.
|
||||
* @param Y The Y-coordinate of the point in space.
|
||||
* @param Width Desired width of this node.
|
||||
* @param Height Desired height of this node.
|
||||
* @param Parent The parent branch or node. Pass null to create a root.
|
||||
*/
|
||||
constructor(X: number, Y: number, Width: number, Height: number, Parent: QuadTree = null) {
|
||||
|
||||
super(X, Y, Width, Height);
|
||||
|
||||
//console.log('-------- QuadTree',X,Y,Width,Height);
|
||||
|
||||
this._headA = this._tailA = new LinkedList();
|
||||
this._headB = this._tailB = new LinkedList();
|
||||
|
||||
//Copy the parent's children (if there are any)
|
||||
if (Parent != null)
|
||||
{
|
||||
//console.log('Parent not null');
|
||||
var iterator: LinkedList;
|
||||
var ot: LinkedList;
|
||||
|
||||
if (Parent._headA.object != null)
|
||||
{
|
||||
iterator = Parent._headA;
|
||||
//console.log('iterator set to parent headA');
|
||||
|
||||
while (iterator != null)
|
||||
{
|
||||
if (this._tailA.object != null)
|
||||
{
|
||||
ot = this._tailA;
|
||||
this._tailA = new LinkedList();
|
||||
ot.next = this._tailA;
|
||||
}
|
||||
|
||||
this._tailA.object = iterator.object;
|
||||
iterator = iterator.next;
|
||||
}
|
||||
}
|
||||
|
||||
if (Parent._headB.object != null)
|
||||
{
|
||||
iterator = Parent._headB;
|
||||
//console.log('iterator set to parent headB');
|
||||
|
||||
while (iterator != null)
|
||||
{
|
||||
if (this._tailB.object != null)
|
||||
{
|
||||
ot = this._tailB;
|
||||
this._tailB = new LinkedList();
|
||||
ot.next = this._tailB;
|
||||
}
|
||||
|
||||
this._tailB.object = iterator.object;
|
||||
iterator = iterator.next;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QuadTree._min = (this.width + this.height) / (2 * QuadTree.divisions);
|
||||
}
|
||||
|
||||
this._canSubdivide = (this.width > QuadTree._min) || (this.height > QuadTree._min);
|
||||
|
||||
//console.log('canSubdivided', this._canSubdivide);
|
||||
|
||||
//Set up comparison/sort helpers
|
||||
this._northWestTree = null;
|
||||
this._northEastTree = null;
|
||||
this._southEastTree = null;
|
||||
this._southWestTree = null;
|
||||
this._leftEdge = this.x;
|
||||
this._rightEdge = this.x + this.width;
|
||||
this._halfWidth = this.width / 2;
|
||||
this._midpointX = this._leftEdge + this._halfWidth;
|
||||
this._topEdge = this.y;
|
||||
this._bottomEdge = this.y + this.height;
|
||||
this._halfHeight = this.height / 2;
|
||||
this._midpointY = this._topEdge + this._halfHeight;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Flag for specifying that you want to add an object to the A list.
|
||||
*/
|
||||
public static A_LIST: number = 0;
|
||||
|
||||
/**
|
||||
* Flag for specifying that you want to add an object to the B list.
|
||||
*/
|
||||
public static B_LIST: number = 1;
|
||||
|
||||
/**
|
||||
* Controls the granularity of the quad tree. Default is 6 (decent performance on large and small worlds).
|
||||
*/
|
||||
public static divisions: number;
|
||||
|
||||
/**
|
||||
* Whether this branch of the tree can be subdivided or not.
|
||||
*/
|
||||
private _canSubdivide: bool;
|
||||
|
||||
/**
|
||||
* Refers to the internal A and B linked lists,
|
||||
* which are used to store objects in the leaves.
|
||||
*/
|
||||
private _headA: LinkedList;
|
||||
|
||||
/**
|
||||
* Refers to the internal A and B linked lists,
|
||||
* which are used to store objects in the leaves.
|
||||
*/
|
||||
private _tailA: LinkedList;
|
||||
|
||||
/**
|
||||
* Refers to the internal A and B linked lists,
|
||||
* which are used to store objects in the leaves.
|
||||
*/
|
||||
private _headB: LinkedList;
|
||||
|
||||
/**
|
||||
* Refers to the internal A and B linked lists,
|
||||
* which are used to store objects in the leaves.
|
||||
*/
|
||||
private _tailB: LinkedList;
|
||||
|
||||
/**
|
||||
* Internal, governs and assists with the formation of the tree.
|
||||
*/
|
||||
private static _min: number;
|
||||
|
||||
/**
|
||||
* Internal, governs and assists with the formation of the tree.
|
||||
*/
|
||||
private _northWestTree: QuadTree;
|
||||
|
||||
/**
|
||||
* Internal, governs and assists with the formation of the tree.
|
||||
*/
|
||||
private _northEastTree: QuadTree;
|
||||
|
||||
/**
|
||||
* Internal, governs and assists with the formation of the tree.
|
||||
*/
|
||||
private _southEastTree: QuadTree;
|
||||
|
||||
/**
|
||||
* Internal, governs and assists with the formation of the tree.
|
||||
*/
|
||||
private _southWestTree: QuadTree;
|
||||
|
||||
/**
|
||||
* Internal, governs and assists with the formation of the tree.
|
||||
*/
|
||||
private _leftEdge: number;
|
||||
|
||||
/**
|
||||
* Internal, governs and assists with the formation of the tree.
|
||||
*/
|
||||
private _rightEdge: number;
|
||||
|
||||
/**
|
||||
* Internal, governs and assists with the formation of the tree.
|
||||
*/
|
||||
private _topEdge: number;
|
||||
|
||||
/**
|
||||
* Internal, governs and assists with the formation of the tree.
|
||||
*/
|
||||
private _bottomEdge: number;
|
||||
|
||||
/**
|
||||
* Internal, governs and assists with the formation of the tree.
|
||||
*/
|
||||
private _halfWidth: number;
|
||||
|
||||
/**
|
||||
* Internal, governs and assists with the formation of the tree.
|
||||
*/
|
||||
private _halfHeight: number;
|
||||
|
||||
/**
|
||||
* Internal, governs and assists with the formation of the tree.
|
||||
*/
|
||||
private _midpointX: number;
|
||||
|
||||
/**
|
||||
* Internal, governs and assists with the formation of the tree.
|
||||
*/
|
||||
private _midpointY: number;
|
||||
|
||||
/**
|
||||
* Internal, used to reduce recursive method parameters during object placement and tree formation.
|
||||
*/
|
||||
private static _object;
|
||||
|
||||
/**
|
||||
* Internal, used to reduce recursive method parameters during object placement and tree formation.
|
||||
*/
|
||||
private static _objectLeftEdge: number;
|
||||
|
||||
/**
|
||||
* Internal, used to reduce recursive method parameters during object placement and tree formation.
|
||||
*/
|
||||
private static _objectTopEdge: number;
|
||||
|
||||
/**
|
||||
* Internal, used to reduce recursive method parameters during object placement and tree formation.
|
||||
*/
|
||||
private static _objectRightEdge: number;
|
||||
|
||||
/**
|
||||
* Internal, used to reduce recursive method parameters during object placement and tree formation.
|
||||
*/
|
||||
private static _objectBottomEdge: number;
|
||||
|
||||
/**
|
||||
* Internal, used during tree processing and overlap checks.
|
||||
*/
|
||||
private static _list: number;
|
||||
|
||||
/**
|
||||
* Internal, used during tree processing and overlap checks.
|
||||
*/
|
||||
private static _useBothLists: bool;
|
||||
|
||||
/**
|
||||
* Internal, used during tree processing and overlap checks.
|
||||
*/
|
||||
private static _processingCallback;
|
||||
|
||||
/**
|
||||
* Internal, used during tree processing and overlap checks.
|
||||
*/
|
||||
private static _notifyCallback;
|
||||
|
||||
/**
|
||||
* Internal, used during tree processing and overlap checks.
|
||||
*/
|
||||
private static _iterator: LinkedList;
|
||||
|
||||
/**
|
||||
* Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.
|
||||
*/
|
||||
private static _objectHullX: number;
|
||||
|
||||
/**
|
||||
* Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.
|
||||
*/
|
||||
private static _objectHullY: number;
|
||||
|
||||
/**
|
||||
* Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.
|
||||
*/
|
||||
private static _objectHullWidth: number;
|
||||
|
||||
/**
|
||||
* Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.
|
||||
*/
|
||||
private static _objectHullHeight: number;
|
||||
|
||||
/**
|
||||
* Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.
|
||||
*/
|
||||
private static _checkObjectHullX: number;
|
||||
|
||||
/**
|
||||
* Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.
|
||||
*/
|
||||
private static _checkObjectHullY: number;
|
||||
|
||||
/**
|
||||
* Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.
|
||||
*/
|
||||
private static _checkObjectHullWidth: number;
|
||||
|
||||
/**
|
||||
* Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.
|
||||
*/
|
||||
private static _checkObjectHullHeight: number;
|
||||
|
||||
/**
|
||||
* Clean up memory.
|
||||
*/
|
||||
public destroy() {
|
||||
|
||||
this._tailA.destroy();
|
||||
this._tailB.destroy();
|
||||
this._headA.destroy();
|
||||
this._headB.destroy();
|
||||
|
||||
this._tailA = null;
|
||||
this._tailB = null;
|
||||
this._headA = null;
|
||||
this._headB = null;
|
||||
|
||||
if (this._northWestTree != null)
|
||||
{
|
||||
this._northWestTree.destroy();
|
||||
}
|
||||
|
||||
if (this._northEastTree != null)
|
||||
{
|
||||
this._northEastTree.destroy();
|
||||
}
|
||||
|
||||
if (this._southEastTree != null)
|
||||
{
|
||||
this._southEastTree.destroy();
|
||||
}
|
||||
|
||||
if (this._southWestTree != null)
|
||||
{
|
||||
this._southWestTree.destroy();
|
||||
}
|
||||
|
||||
this._northWestTree = null;
|
||||
this._northEastTree = null;
|
||||
this._southEastTree = null;
|
||||
this._southWestTree = null;
|
||||
|
||||
QuadTree._object = null;
|
||||
QuadTree._processingCallback = null;
|
||||
QuadTree._notifyCallback = null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Load objects and/or groups into the quad tree, and register notify and processing callbacks.
|
||||
*
|
||||
* @param ObjectOrGroup1 Any object that is or extends GameObject or Group.
|
||||
* @param ObjectOrGroup2 Any object that is or extends GameObject or Group. If null, the first parameter will be checked against itself.
|
||||
* @param NotifyCallback A function with the form <code>myFunction(Object1:GameObject,Object2:GameObject)</code> that is called whenever two objects are found to overlap in world space, and either no ProcessCallback is specified, or the ProcessCallback returns true.
|
||||
* @param ProcessCallback A function with the form <code>myFunction(Object1:GameObject,Object2:GameObject):bool</code> that is called whenever two objects are found to overlap in world space. The NotifyCallback is only called if this function returns true. See GameObject.separate().
|
||||
*/
|
||||
public load(ObjectOrGroup1: Basic, ObjectOrGroup2: Basic = null, NotifyCallback = null, ProcessCallback = null) {
|
||||
|
||||
//console.log('quadtree load', QuadTree.divisions, ObjectOrGroup1, ObjectOrGroup2);
|
||||
|
||||
this.add(ObjectOrGroup1, QuadTree.A_LIST);
|
||||
|
||||
if (ObjectOrGroup2 != null)
|
||||
{
|
||||
this.add(ObjectOrGroup2, QuadTree.B_LIST);
|
||||
QuadTree._useBothLists = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
QuadTree._useBothLists = false;
|
||||
}
|
||||
|
||||
QuadTree._notifyCallback = NotifyCallback;
|
||||
QuadTree._processingCallback = ProcessCallback;
|
||||
|
||||
//console.log('use both', QuadTree._useBothLists);
|
||||
//console.log('------------ end of load');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this function to add an object to the root of the tree.
|
||||
* This function will recursively add all group members, but
|
||||
* not the groups themselves.
|
||||
*
|
||||
* @param ObjectOrGroup GameObjects are just added, Groups are recursed and their applicable members added accordingly.
|
||||
* @param List A <code>uint</code> flag indicating the list to which you want to add the objects. Options are <code>QuadTree.A_LIST</code> and <code>QuadTree.B_LIST</code>.
|
||||
*/
|
||||
public add(ObjectOrGroup: Basic, List: number) {
|
||||
|
||||
QuadTree._list = List;
|
||||
|
||||
if (ObjectOrGroup.isGroup == true)
|
||||
{
|
||||
var i: number = 0;
|
||||
var basic: Basic;
|
||||
var members = <Group> ObjectOrGroup['members'];
|
||||
var l: number = ObjectOrGroup['length'];
|
||||
|
||||
while (i < l)
|
||||
{
|
||||
basic = members[i++];
|
||||
|
||||
if ((basic != null) && basic.exists)
|
||||
{
|
||||
if (basic.isGroup)
|
||||
{
|
||||
this.add(basic, List);
|
||||
}
|
||||
else
|
||||
{
|
||||
QuadTree._object = basic;
|
||||
|
||||
if (QuadTree._object.exists && QuadTree._object.allowCollisions)
|
||||
{
|
||||
QuadTree._objectLeftEdge = QuadTree._object.x;
|
||||
QuadTree._objectTopEdge = QuadTree._object.y;
|
||||
QuadTree._objectRightEdge = QuadTree._object.x + QuadTree._object.width;
|
||||
QuadTree._objectBottomEdge = QuadTree._object.y + QuadTree._object.height;
|
||||
this.addObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QuadTree._object = ObjectOrGroup;
|
||||
|
||||
//console.log('add - not group:', ObjectOrGroup.name);
|
||||
|
||||
if (QuadTree._object.exists && QuadTree._object.allowCollisions)
|
||||
{
|
||||
QuadTree._objectLeftEdge = QuadTree._object.x;
|
||||
QuadTree._objectTopEdge = QuadTree._object.y;
|
||||
QuadTree._objectRightEdge = QuadTree._object.x + QuadTree._object.width;
|
||||
QuadTree._objectBottomEdge = QuadTree._object.y + QuadTree._object.height;
|
||||
//console.log('object properties', QuadTree._objectLeftEdge, QuadTree._objectTopEdge, QuadTree._objectRightEdge, QuadTree._objectBottomEdge);
|
||||
this.addObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal function for recursively navigating and creating the tree
|
||||
* while adding objects to the appropriate nodes.
|
||||
*/
|
||||
private addObject() {
|
||||
|
||||
//console.log('addObject');
|
||||
|
||||
//If this quad (not its children) lies entirely inside this object, add it here
|
||||
if (!this._canSubdivide || ((this._leftEdge >= QuadTree._objectLeftEdge) && (this._rightEdge <= QuadTree._objectRightEdge) && (this._topEdge >= QuadTree._objectTopEdge) && (this._bottomEdge <= QuadTree._objectBottomEdge)))
|
||||
{
|
||||
//console.log('add To List');
|
||||
this.addToList();
|
||||
return;
|
||||
}
|
||||
|
||||
//See if the selected object fits completely inside any of the quadrants
|
||||
if ((QuadTree._objectLeftEdge > this._leftEdge) && (QuadTree._objectRightEdge < this._midpointX))
|
||||
{
|
||||
if ((QuadTree._objectTopEdge > this._topEdge) && (QuadTree._objectBottomEdge < this._midpointY))
|
||||
{
|
||||
//console.log('Adding NW tree');
|
||||
|
||||
if (this._northWestTree == null)
|
||||
{
|
||||
this._northWestTree = new QuadTree(this._leftEdge, this._topEdge, this._halfWidth, this._halfHeight, this);
|
||||
}
|
||||
|
||||
this._northWestTree.addObject();
|
||||
return;
|
||||
}
|
||||
|
||||
if ((QuadTree._objectTopEdge > this._midpointY) && (QuadTree._objectBottomEdge < this._bottomEdge))
|
||||
{
|
||||
//console.log('Adding SW tree');
|
||||
|
||||
if (this._southWestTree == null)
|
||||
{
|
||||
this._southWestTree = new QuadTree(this._leftEdge, this._midpointY, this._halfWidth, this._halfHeight, this);
|
||||
}
|
||||
|
||||
this._southWestTree.addObject();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ((QuadTree._objectLeftEdge > this._midpointX) && (QuadTree._objectRightEdge < this._rightEdge))
|
||||
{
|
||||
if ((QuadTree._objectTopEdge > this._topEdge) && (QuadTree._objectBottomEdge < this._midpointY))
|
||||
{
|
||||
//console.log('Adding NE tree');
|
||||
|
||||
if (this._northEastTree == null)
|
||||
{
|
||||
this._northEastTree = new QuadTree(this._midpointX, this._topEdge, this._halfWidth, this._halfHeight, this);
|
||||
}
|
||||
|
||||
this._northEastTree.addObject();
|
||||
return;
|
||||
}
|
||||
|
||||
if ((QuadTree._objectTopEdge > this._midpointY) && (QuadTree._objectBottomEdge < this._bottomEdge))
|
||||
{
|
||||
//console.log('Adding SE tree');
|
||||
|
||||
if (this._southEastTree == null)
|
||||
{
|
||||
this._southEastTree = new QuadTree(this._midpointX, this._midpointY, this._halfWidth, this._halfHeight, this);
|
||||
}
|
||||
|
||||
this._southEastTree.addObject();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//If it wasn't completely contained we have to check out the partial overlaps
|
||||
if ((QuadTree._objectRightEdge > this._leftEdge) && (QuadTree._objectLeftEdge < this._midpointX) && (QuadTree._objectBottomEdge > this._topEdge) && (QuadTree._objectTopEdge < this._midpointY))
|
||||
{
|
||||
if (this._northWestTree == null)
|
||||
{
|
||||
this._northWestTree = new QuadTree(this._leftEdge, this._topEdge, this._halfWidth, this._halfHeight, this);
|
||||
}
|
||||
|
||||
//console.log('added to north west partial tree');
|
||||
this._northWestTree.addObject();
|
||||
}
|
||||
|
||||
if ((QuadTree._objectRightEdge > this._midpointX) && (QuadTree._objectLeftEdge < this._rightEdge) && (QuadTree._objectBottomEdge > this._topEdge) && (QuadTree._objectTopEdge < this._midpointY))
|
||||
{
|
||||
if (this._northEastTree == null)
|
||||
{
|
||||
this._northEastTree = new QuadTree(this._midpointX, this._topEdge, this._halfWidth, this._halfHeight, this);
|
||||
}
|
||||
|
||||
//console.log('added to north east partial tree');
|
||||
this._northEastTree.addObject();
|
||||
}
|
||||
|
||||
if ((QuadTree._objectRightEdge > this._midpointX) && (QuadTree._objectLeftEdge < this._rightEdge) && (QuadTree._objectBottomEdge > this._midpointY) && (QuadTree._objectTopEdge < this._bottomEdge))
|
||||
{
|
||||
if (this._southEastTree == null)
|
||||
{
|
||||
this._southEastTree = new QuadTree(this._midpointX, this._midpointY, this._halfWidth, this._halfHeight, this);
|
||||
}
|
||||
|
||||
//console.log('added to south east partial tree');
|
||||
this._southEastTree.addObject();
|
||||
}
|
||||
|
||||
if ((QuadTree._objectRightEdge > this._leftEdge) && (QuadTree._objectLeftEdge < this._midpointX) && (QuadTree._objectBottomEdge > this._midpointY) && (QuadTree._objectTopEdge < this._bottomEdge))
|
||||
{
|
||||
if (this._southWestTree == null)
|
||||
{
|
||||
this._southWestTree = new QuadTree(this._leftEdge, this._midpointY, this._halfWidth, this._halfHeight, this);
|
||||
}
|
||||
|
||||
//console.log('added to south west partial tree');
|
||||
this._southWestTree.addObject();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal function for recursively adding objects to leaf lists.
|
||||
*/
|
||||
private addToList() {
|
||||
|
||||
//console.log('Adding to List');
|
||||
|
||||
var ot: LinkedList;
|
||||
|
||||
if (QuadTree._list == QuadTree.A_LIST)
|
||||
{
|
||||
//console.log('A LIST');
|
||||
if (this._tailA.object != null)
|
||||
{
|
||||
ot = this._tailA;
|
||||
this._tailA = new LinkedList();
|
||||
ot.next = this._tailA;
|
||||
}
|
||||
|
||||
this._tailA.object = QuadTree._object;
|
||||
}
|
||||
else
|
||||
{
|
||||
//console.log('B LIST');
|
||||
if (this._tailB.object != null)
|
||||
{
|
||||
ot = this._tailB;
|
||||
this._tailB = new LinkedList();
|
||||
ot.next = this._tailB;
|
||||
}
|
||||
|
||||
this._tailB.object = QuadTree._object;
|
||||
}
|
||||
|
||||
if (!this._canSubdivide)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._northWestTree != null)
|
||||
{
|
||||
this._northWestTree.addToList();
|
||||
}
|
||||
|
||||
if (this._northEastTree != null)
|
||||
{
|
||||
this._northEastTree.addToList();
|
||||
}
|
||||
|
||||
if (this._southEastTree != null)
|
||||
{
|
||||
this._southEastTree.addToList();
|
||||
}
|
||||
|
||||
if (this._southWestTree != null)
|
||||
{
|
||||
this._southWestTree.addToList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* <code>QuadTree</code>'s other main function. Call this after adding objects
|
||||
* using <code>QuadTree.load()</code> to compare the objects that you loaded.
|
||||
*
|
||||
* @return Whether or not any overlaps were found.
|
||||
*/
|
||||
public execute(): bool {
|
||||
|
||||
//console.log('quadtree execute');
|
||||
|
||||
var overlapProcessed: bool = false;
|
||||
var iterator: LinkedList;
|
||||
|
||||
if (this._headA.object != null)
|
||||
{
|
||||
//console.log('---------------------------------------------------');
|
||||
//console.log('headA iterator');
|
||||
|
||||
iterator = this._headA;
|
||||
|
||||
while (iterator != null)
|
||||
{
|
||||
QuadTree._object = iterator.object;
|
||||
|
||||
if (QuadTree._useBothLists)
|
||||
{
|
||||
QuadTree._iterator = this._headB;
|
||||
}
|
||||
else
|
||||
{
|
||||
QuadTree._iterator = iterator.next;
|
||||
}
|
||||
|
||||
if (QuadTree._object.exists && (QuadTree._object.allowCollisions > 0) && (QuadTree._iterator != null) && (QuadTree._iterator.object != null) && QuadTree._iterator.object.exists && this.overlapNode())
|
||||
{
|
||||
//console.log('headA iterator overlapped true');
|
||||
overlapProcessed = true;
|
||||
}
|
||||
|
||||
iterator = iterator.next;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Advance through the tree by calling overlap on each child
|
||||
if ((this._northWestTree != null) && this._northWestTree.execute())
|
||||
{
|
||||
//console.log('NW quadtree execute');
|
||||
overlapProcessed = true;
|
||||
}
|
||||
|
||||
if ((this._northEastTree != null) && this._northEastTree.execute())
|
||||
{
|
||||
//console.log('NE quadtree execute');
|
||||
overlapProcessed = true;
|
||||
}
|
||||
|
||||
if ((this._southEastTree != null) && this._southEastTree.execute())
|
||||
{
|
||||
//console.log('SE quadtree execute');
|
||||
overlapProcessed = true;
|
||||
}
|
||||
|
||||
if ((this._southWestTree != null) && this._southWestTree.execute())
|
||||
{
|
||||
//console.log('SW quadtree execute');
|
||||
overlapProcessed = true;
|
||||
}
|
||||
|
||||
return overlapProcessed;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* An private for comparing an object against the contents of a node.
|
||||
*
|
||||
* @return Whether or not any overlaps were found.
|
||||
*/
|
||||
private overlapNode(): bool {
|
||||
|
||||
//console.log('overlapNode');
|
||||
|
||||
//Walk the list and check for overlaps
|
||||
var overlapProcessed: bool = false;
|
||||
var checkObject;
|
||||
|
||||
while (QuadTree._iterator != null)
|
||||
{
|
||||
if (!QuadTree._object.exists || (QuadTree._object.allowCollisions <= 0))
|
||||
{
|
||||
//console.log('break 1');
|
||||
break;
|
||||
}
|
||||
|
||||
checkObject = QuadTree._iterator.object;
|
||||
|
||||
if ((QuadTree._object === checkObject) || !checkObject.exists || (checkObject.allowCollisions <= 0))
|
||||
{
|
||||
//console.log('break 2');
|
||||
QuadTree._iterator = QuadTree._iterator.next;
|
||||
continue;
|
||||
}
|
||||
|
||||
//calculate bulk hull for QuadTree._object
|
||||
QuadTree._objectHullX = (QuadTree._object.x < QuadTree._object.last.x) ? QuadTree._object.x : QuadTree._object.last.x;
|
||||
QuadTree._objectHullY = (QuadTree._object.y < QuadTree._object.last.y) ? QuadTree._object.y : QuadTree._object.last.y;
|
||||
QuadTree._objectHullWidth = QuadTree._object.x - QuadTree._object.last.x;
|
||||
QuadTree._objectHullWidth = QuadTree._object.width + ((QuadTree._objectHullWidth > 0) ? QuadTree._objectHullWidth : -QuadTree._objectHullWidth);
|
||||
QuadTree._objectHullHeight = QuadTree._object.y - QuadTree._object.last.y;
|
||||
QuadTree._objectHullHeight = QuadTree._object.height + ((QuadTree._objectHullHeight > 0) ? QuadTree._objectHullHeight : -QuadTree._objectHullHeight);
|
||||
|
||||
//calculate bulk hull for checkObject
|
||||
QuadTree._checkObjectHullX = (checkObject.x < checkObject.last.x) ? checkObject.x : checkObject.last.x;
|
||||
QuadTree._checkObjectHullY = (checkObject.y < checkObject.last.y) ? checkObject.y : checkObject.last.y;
|
||||
QuadTree._checkObjectHullWidth = checkObject.x - checkObject.last.x;
|
||||
QuadTree._checkObjectHullWidth = checkObject.width + ((QuadTree._checkObjectHullWidth > 0) ? QuadTree._checkObjectHullWidth : -QuadTree._checkObjectHullWidth);
|
||||
QuadTree._checkObjectHullHeight = checkObject.y - checkObject.last.y;
|
||||
QuadTree._checkObjectHullHeight = checkObject.height + ((QuadTree._checkObjectHullHeight > 0) ? QuadTree._checkObjectHullHeight : -QuadTree._checkObjectHullHeight);
|
||||
|
||||
//check for intersection of the two hulls
|
||||
if ((QuadTree._objectHullX + QuadTree._objectHullWidth > QuadTree._checkObjectHullX) && (QuadTree._objectHullX < QuadTree._checkObjectHullX + QuadTree._checkObjectHullWidth) && (QuadTree._objectHullY + QuadTree._objectHullHeight > QuadTree._checkObjectHullY) && (QuadTree._objectHullY < QuadTree._checkObjectHullY + QuadTree._checkObjectHullHeight))
|
||||
{
|
||||
//console.log('intersection!');
|
||||
|
||||
//Execute callback functions if they exist
|
||||
if ((QuadTree._processingCallback == null) || QuadTree._processingCallback(QuadTree._object, checkObject))
|
||||
{
|
||||
overlapProcessed = true;
|
||||
}
|
||||
|
||||
if (overlapProcessed && (QuadTree._notifyCallback != null))
|
||||
{
|
||||
QuadTree._notifyCallback(QuadTree._object, checkObject);
|
||||
}
|
||||
}
|
||||
|
||||
QuadTree._iterator = QuadTree._iterator.next;
|
||||
|
||||
}
|
||||
|
||||
return overlapProcessed;
|
||||
|
||||
}
|
||||
}
|
205
Phaser/system/RequestAnimationFrame.ts
Normal file
|
@ -0,0 +1,205 @@
|
|||
/**
|
||||
* RequestAnimationFrame
|
||||
*
|
||||
* @desc Abstracts away the use of RAF or setTimeOut for the core game update loop. The callback can be re-mapped on the fly.
|
||||
*
|
||||
* @version 0.3 - 15th October 2012
|
||||
* @author Richard Davey
|
||||
*/
|
||||
|
||||
class RequestAnimationFrame {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param {Any} callback
|
||||
* @return {RequestAnimationFrame} This object.
|
||||
*/
|
||||
constructor(callback, callbackContext) {
|
||||
|
||||
this._callback = callback;
|
||||
this._callbackContext = callbackContext;
|
||||
|
||||
var vendors = ['ms', 'moz', 'webkit', 'o'];
|
||||
|
||||
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; x++)
|
||||
{
|
||||
window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
|
||||
window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'];
|
||||
}
|
||||
|
||||
this.start();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @property _callback
|
||||
* @type Any
|
||||
* @private
|
||||
**/
|
||||
private _callback;
|
||||
private _callbackContext;
|
||||
|
||||
/**
|
||||
*
|
||||
* @method callback
|
||||
* @param {Any} callback
|
||||
**/
|
||||
public setCallback(callback) {
|
||||
|
||||
this._callback = callback;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @property _timeOutID
|
||||
* @type Any
|
||||
* @private
|
||||
**/
|
||||
private _timeOutID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property _isSetTimeOut
|
||||
* @type Boolean
|
||||
* @private
|
||||
**/
|
||||
private _isSetTimeOut: bool = false;
|
||||
|
||||
/**
|
||||
*
|
||||
* @method usingSetTimeOut
|
||||
* @return Boolean
|
||||
**/
|
||||
public isUsingSetTimeOut(): bool {
|
||||
|
||||
return this._isSetTimeOut;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @method usingRAF
|
||||
* @return Boolean
|
||||
**/
|
||||
public isUsingRAF(): bool {
|
||||
|
||||
if (this._isSetTimeOut === true)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @property lastTime
|
||||
* @type Number
|
||||
**/
|
||||
public lastTime: number = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property currentTime
|
||||
* @type Number
|
||||
**/
|
||||
public currentTime: number = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property isRunning
|
||||
* @type Boolean
|
||||
**/
|
||||
public isRunning: bool = false;
|
||||
|
||||
/**
|
||||
*
|
||||
* @method start
|
||||
* @param {Any} [callback]
|
||||
**/
|
||||
public start(callback? = null) {
|
||||
|
||||
if (callback)
|
||||
{
|
||||
this._callback = callback;
|
||||
}
|
||||
|
||||
if (!window.requestAnimationFrame)
|
||||
{
|
||||
this._isSetTimeOut = true;
|
||||
this._timeOutID = window.setTimeout(() => this.SetTimeoutUpdate(), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._isSetTimeOut = false;
|
||||
window.requestAnimationFrame(() => this.RAFUpdate());
|
||||
}
|
||||
|
||||
this.isRunning = true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @method stop
|
||||
**/
|
||||
public stop() {
|
||||
|
||||
if (this._isSetTimeOut)
|
||||
{
|
||||
clearTimeout(this._timeOutID);
|
||||
}
|
||||
else
|
||||
{
|
||||
window.cancelAnimationFrame;
|
||||
}
|
||||
|
||||
this.isRunning = false;
|
||||
|
||||
}
|
||||
|
||||
public RAFUpdate() {
|
||||
|
||||
// Not in IE8 (but neither is RAF) also doesn't use a high performance timer (window.performance.now)
|
||||
this.currentTime = Date.now();
|
||||
|
||||
if (this._callback)
|
||||
{
|
||||
this._callback.call(this._callbackContext);
|
||||
}
|
||||
|
||||
var timeToCall: number = Math.max(0, 16 - (this.currentTime - this.lastTime));
|
||||
|
||||
window.requestAnimationFrame(() => this.RAFUpdate());
|
||||
|
||||
this.lastTime = this.currentTime + timeToCall;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @method SetTimeoutUpdate
|
||||
**/
|
||||
public SetTimeoutUpdate() {
|
||||
|
||||
// Not in IE8
|
||||
this.currentTime = Date.now();
|
||||
|
||||
if (this._callback)
|
||||
{
|
||||
this._callback.call(this._callbackContext);
|
||||
}
|
||||
|
||||
var timeToCall: number = Math.max(0, 16 - (this.currentTime - this.lastTime));
|
||||
|
||||
this._timeOutID = window.setTimeout(() => this.SetTimeoutUpdate(), timeToCall);
|
||||
|
||||
this.lastTime = this.currentTime + timeToCall;
|
||||
|
||||
}
|
||||
|
||||
}
|
87
Phaser/system/Tile.ts
Normal file
|
@ -0,0 +1,87 @@
|
|||
/// <reference path="../GameObject.ts" />
|
||||
/// <reference path="../Tilemap.ts" />
|
||||
|
||||
/**
|
||||
* A simple helper object for <code>Tilemap</code> that helps expand collision opportunities and control.
|
||||
* You can use <code>Tilemap.setTileProperties()</code> to alter the collision properties and
|
||||
* callback functions and filters for this object to do things like one-way tiles or whatever.
|
||||
*
|
||||
* @author Adam Atomic
|
||||
* @author Richard Davey
|
||||
*/
|
||||
class Tile extends GameObject {
|
||||
|
||||
/**
|
||||
* Instantiate this new tile object. This is usually called from <code>FlxTilemap.loadMap()</code>.
|
||||
*
|
||||
* @param Tilemap A reference to the tilemap object creating the tile.
|
||||
* @param Index The actual core map data index for this tile type.
|
||||
* @param Width The width of the tile.
|
||||
* @param Height The height of the tile.
|
||||
* @param Visible Whether the tile is visible or not.
|
||||
* @param AllowCollisions The collision flags for the object. By default this value is ANY or NONE depending on the parameters sent to loadMap().
|
||||
*/
|
||||
constructor(game: Game, Tilemap: Tilemap, Index: number, Width: number, Height: number, Visible: bool, AllowCollisions: number) {
|
||||
|
||||
super(game, 0, 0, Width, Height);
|
||||
|
||||
this.immovable = true;
|
||||
this.moves = false;
|
||||
this.callback = null;
|
||||
this.filter = null;
|
||||
|
||||
this.tilemap = Tilemap;
|
||||
this.index = Index;
|
||||
this.visible = Visible;
|
||||
this.allowCollisions = AllowCollisions;
|
||||
|
||||
this.mapIndex = 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called whenever an object hits a tile of this type.
|
||||
* This function should take the form <code>myFunction(Tile:FlxTile,Object:FlxObject)</code>.
|
||||
* Defaults to null, set through <code>FlxTilemap.setTileProperties()</code>.
|
||||
*/
|
||||
public callback;
|
||||
|
||||
/**
|
||||
* Each tile can store its own filter class for their callback functions.
|
||||
* That is, the callback will only be triggered if an object with a class
|
||||
* type matching the filter touched it.
|
||||
* Defaults to null, set through <code>FlxTilemap.setTileProperties()</code>.
|
||||
*/
|
||||
public filter;
|
||||
|
||||
/**
|
||||
* A reference to the tilemap this tile object belongs to.
|
||||
*/
|
||||
public tilemap: Tilemap;
|
||||
|
||||
/**
|
||||
* The index of this tile type in the core map data.
|
||||
* For example, if your map only has 16 kinds of tiles in it,
|
||||
* this number is usually between 0 and 15.
|
||||
*/
|
||||
public index: number;
|
||||
|
||||
/**
|
||||
* The current map index of this tile object at this moment.
|
||||
* You can think of tile objects as moving around the tilemap helping with collisions.
|
||||
* This value is only reliable and useful if used from the callback function.
|
||||
*/
|
||||
public mapIndex: number;
|
||||
|
||||
/**
|
||||
* Clean up memory.
|
||||
*/
|
||||
public destroy() {
|
||||
|
||||
super.destroy();
|
||||
this.callback = null;
|
||||
this.tilemap = null;
|
||||
|
||||
}
|
||||
|
||||
}
|
172
Phaser/system/TilemapBuffer.ts
Normal file
|
@ -0,0 +1,172 @@
|
|||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../GameObject.ts" />
|
||||
/// <reference path="../Tilemap.ts" />
|
||||
/// <reference path="../Rectangle.ts" />
|
||||
/// <reference path="Camera.ts" />
|
||||
|
||||
/**
|
||||
* A Tilemap Buffer
|
||||
*
|
||||
* @author Richard Davey
|
||||
*/
|
||||
class TilemapBuffer {
|
||||
|
||||
constructor(game: Game, camera:Camera, tilemap:Tilemap, texture, tileOffsets) {
|
||||
|
||||
//console.log('New TilemapBuffer created for Camera ' + camera.ID);
|
||||
|
||||
this._game = game;
|
||||
this.camera = camera;
|
||||
this._tilemap = tilemap;
|
||||
this._texture = texture;
|
||||
this._tileOffsets = tileOffsets;
|
||||
|
||||
//this.createCanvas();
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
private _tilemap: Tilemap;
|
||||
private _texture;
|
||||
private _tileOffsets;
|
||||
|
||||
private _startX: number = 0;
|
||||
private _maxX: number = 0;
|
||||
private _startY: number = 0;
|
||||
private _maxY: number = 0;
|
||||
private _tx: number = 0;
|
||||
private _ty: number = 0;
|
||||
private _dx: number = 0;
|
||||
private _dy: number = 0;
|
||||
private _oldCameraX: number = 0;
|
||||
private _oldCameraY: number = 0;
|
||||
private _dirty: bool = true;
|
||||
private _columnData;
|
||||
|
||||
public camera: Camera;
|
||||
public canvas: HTMLCanvasElement;
|
||||
public context: CanvasRenderingContext2D;
|
||||
|
||||
private createCanvas() {
|
||||
|
||||
this.canvas = <HTMLCanvasElement> document.createElement('canvas');
|
||||
this.canvas.width = this._game.stage.width;
|
||||
this.canvas.height = this._game.stage.height;
|
||||
this.context = this.canvas.getContext('2d');
|
||||
|
||||
}
|
||||
|
||||
public update() {
|
||||
|
||||
/*
|
||||
if (this.camera.worldView.x !== this._oldCameraX || this.camera.worldView.y !== this._oldCameraY)
|
||||
{
|
||||
this._dirty = true;
|
||||
}
|
||||
|
||||
this._oldCameraX = this.camera.worldView.x;
|
||||
this._oldCameraY = this.camera.worldView.y;
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
|
||||
|
||||
this._game.stage.context.fillStyle = color;
|
||||
this._game.stage.context.fillText('TilemapBuffer', x, y);
|
||||
this._game.stage.context.fillText('startX: ' + this._startX + ' endX: ' + this._maxX, x, y + 14);
|
||||
this._game.stage.context.fillText('startY: ' + this._startY + ' endY: ' + this._maxY, x, y + 28);
|
||||
this._game.stage.context.fillText('dx: ' + this._dx + ' dy: ' + this._dy, x, y + 42);
|
||||
this._game.stage.context.fillText('Dirty: ' + this._dirty, x, y + 56);
|
||||
|
||||
}
|
||||
|
||||
public render(dx, dy): bool {
|
||||
|
||||
/*
|
||||
if (this._dirty == false)
|
||||
{
|
||||
this._game.stage.context.drawImage(this.canvas, 0, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
// Work out how many tiles we can fit into our camera and round it up for the edges
|
||||
this._maxX = this._game.math.ceil(this.camera.width / this._tilemap.tileWidth) + 1;
|
||||
this._maxY = this._game.math.ceil(this.camera.height / this._tilemap.tileHeight) + 1;
|
||||
|
||||
// And now work out where in the tilemap the camera actually is
|
||||
this._startX = this._game.math.floor(this.camera.worldView.x / this._tilemap.tileWidth);
|
||||
this._startY = this._game.math.floor(this.camera.worldView.y / this._tilemap.tileHeight);
|
||||
|
||||
// Tilemap bounds check
|
||||
if (this._startX < 0)
|
||||
{
|
||||
this._startX = 0;
|
||||
}
|
||||
|
||||
if (this._startY < 0)
|
||||
{
|
||||
this._startY = 0;
|
||||
}
|
||||
|
||||
if (this._startX + this._maxX > this._tilemap.widthInTiles)
|
||||
{
|
||||
this._startX = this._tilemap.widthInTiles - this._maxX;
|
||||
}
|
||||
|
||||
if (this._startY + this._maxY > this._tilemap.heightInTiles)
|
||||
{
|
||||
this._startY = this._tilemap.heightInTiles - this._maxY;
|
||||
}
|
||||
|
||||
// Finally get the offset to avoid the blocky movement
|
||||
this._dx = dx;
|
||||
this._dy = dy;
|
||||
|
||||
this._dx += -(this.camera.worldView.x - (this._startX * this._tilemap.tileWidth));
|
||||
this._dy += -(this.camera.worldView.y - (this._startY * this._tilemap.tileHeight));
|
||||
|
||||
this._tx = this._dx;
|
||||
this._ty = this._dy;
|
||||
|
||||
for (var row = this._startY; row < this._startY + this._maxY; row++)
|
||||
{
|
||||
this._columnData = this._tilemap.mapData[row];
|
||||
|
||||
for (var tile = this._startX; tile < this._startX + this._maxX; tile++)
|
||||
{
|
||||
if (this._tileOffsets[this._columnData[tile]])
|
||||
{
|
||||
//this.context.drawImage(
|
||||
this._game.stage.context.drawImage(
|
||||
this._texture, // Source Image
|
||||
this._tileOffsets[this._columnData[tile]].x, // Source X (location within the source image)
|
||||
this._tileOffsets[this._columnData[tile]].y, // Source Y
|
||||
this._tilemap.tileWidth, // Source Width
|
||||
this._tilemap.tileHeight, // Source Height
|
||||
this._tx, // Destination X (where on the canvas it'll be drawn)
|
||||
this._ty, // Destination Y
|
||||
this._tilemap.tileWidth, // Destination Width (always same as Source Width unless scaled)
|
||||
this._tilemap.tileHeight // Destination Height (always same as Source Height unless scaled)
|
||||
);
|
||||
|
||||
this._tx += this._tilemap.tileWidth;
|
||||
}
|
||||
}
|
||||
|
||||
this._tx = this._dx;
|
||||
this._ty += this._tilemap.tileHeight;
|
||||
|
||||
}
|
||||
|
||||
//this._game.stage.context.drawImage(this.canvas, 0, 0);
|
||||
//console.log('dirty cleaned');
|
||||
//this._dirty = false;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
154
Phaser/system/animation/Animation.ts
Normal file
|
@ -0,0 +1,154 @@
|
|||
/// <reference path="../../Game.ts" />
|
||||
/// <reference path="../../Sprite.ts" />
|
||||
/// <reference path="AnimationLoader.ts" />
|
||||
/// <reference path="Frame.ts" />
|
||||
/// <reference path="FrameData.ts" />
|
||||
|
||||
/**
|
||||
* Animation
|
||||
*
|
||||
* @desc Loads Sprite Sheets and Texture Atlas formats into a unified FrameData object
|
||||
*
|
||||
* @version 1.0 - 22nd March 2013
|
||||
* @author Richard Davey
|
||||
*/
|
||||
|
||||
class Animation {
|
||||
|
||||
constructor(game: Game, parent: Sprite, frameData: FrameData, name, frames, delay, looped) {
|
||||
|
||||
this._game = game;
|
||||
this._parent = parent;
|
||||
this._frames = frames;
|
||||
this._frameData = frameData;
|
||||
|
||||
this.name = name;
|
||||
this.delay = 1000 / delay;
|
||||
this.looped = looped;
|
||||
|
||||
this.isFinished = false;
|
||||
this.isPlaying = false;
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
private _parent: Sprite;
|
||||
private _frames: number[];
|
||||
private _frameData: FrameData;
|
||||
private _frameIndex: number;
|
||||
|
||||
private _timeLastFrame: number;
|
||||
private _timeNextFrame: number;
|
||||
|
||||
public name: string;
|
||||
public currentFrame: Frame;
|
||||
|
||||
public isFinished: bool;
|
||||
public isPlaying: bool;
|
||||
public looped: bool;
|
||||
public delay: number;
|
||||
|
||||
public get frameTotal(): number {
|
||||
return this._frames.length;
|
||||
}
|
||||
|
||||
public get frame(): number {
|
||||
return this._frameIndex;
|
||||
}
|
||||
|
||||
public set frame(value: number) {
|
||||
|
||||
this.currentFrame = this._frameData.getFrame(value);
|
||||
|
||||
if (this.currentFrame !== null)
|
||||
{
|
||||
this._parent.bounds.width = this.currentFrame.width;
|
||||
this._parent.bounds.height = this.currentFrame.height;
|
||||
this._frameIndex = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public play(frameRate?: number = null, loop?: bool) {
|
||||
|
||||
if (frameRate !== null)
|
||||
{
|
||||
this.delay = 1000 / frameRate;
|
||||
}
|
||||
|
||||
if (loop !== undefined)
|
||||
{
|
||||
this.looped = loop;
|
||||
}
|
||||
|
||||
this.isPlaying = true;
|
||||
this.isFinished = false;
|
||||
|
||||
this._timeLastFrame = this._game.time.now;
|
||||
this._timeNextFrame = this._game.time.now + this.delay;
|
||||
|
||||
this._frameIndex = 0;
|
||||
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
|
||||
|
||||
}
|
||||
|
||||
private onComplete() {
|
||||
|
||||
this.isPlaying = false;
|
||||
this.isFinished = true;
|
||||
// callback
|
||||
|
||||
}
|
||||
|
||||
public stop() {
|
||||
|
||||
this.isPlaying = false;
|
||||
this.isFinished = true;
|
||||
|
||||
}
|
||||
|
||||
public update():bool {
|
||||
|
||||
if (this.isPlaying == true && this._game.time.now >= this._timeNextFrame)
|
||||
{
|
||||
this._frameIndex++;
|
||||
|
||||
if (this._frameIndex == this._frames.length)
|
||||
{
|
||||
if (this.looped)
|
||||
{
|
||||
this._frameIndex = 0;
|
||||
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.onComplete();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
|
||||
}
|
||||
|
||||
this._timeLastFrame = this._game.time.now;
|
||||
this._timeNextFrame = this._game.time.now + this.delay;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public destroy() {
|
||||
|
||||
this._game = null;
|
||||
this._parent = null;
|
||||
this._frames = null;
|
||||
this._frameData = null;
|
||||
this.currentFrame = null;
|
||||
this.isPlaying = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
93
Phaser/system/animation/AnimationLoader.ts
Normal file
|
@ -0,0 +1,93 @@
|
|||
/// <reference path="../../Game.ts" />
|
||||
/// <reference path="../../Sprite.ts" />
|
||||
/// <reference path="Animation.ts" />
|
||||
/// <reference path="Frame.ts" />
|
||||
/// <reference path="FrameData.ts" />
|
||||
|
||||
class AnimationLoader {
|
||||
|
||||
public static parseSpriteSheet(game: Game, key: string, frameWidth: number, frameHeight: number, frameMax:number): FrameData {
|
||||
|
||||
// How big is our image?
|
||||
|
||||
var img = game.cache.getImage(key);
|
||||
|
||||
if (img == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var width = img.width;
|
||||
var height = img.height;
|
||||
|
||||
var row = Math.round(width / frameWidth);
|
||||
var column = Math.round(height / frameHeight);
|
||||
var total = row * column;
|
||||
|
||||
if (frameMax !== -1)
|
||||
{
|
||||
total = frameMax;
|
||||
}
|
||||
|
||||
// Zero or smaller than frame sizes?
|
||||
if (width == 0 || height == 0 || width < frameWidth || height < frameHeight || total === 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Let's create some frames then
|
||||
var data: FrameData = new FrameData();
|
||||
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
|
||||
//console.log('\n\nSpriteSheet Data');
|
||||
//console.log('Image Size:', width, 'x', height);
|
||||
//console.log('Frame Size:', frameWidth, 'x', frameHeight);
|
||||
//console.log('Start X/Y:', x, 'x', y);
|
||||
//console.log('Frames (Total: ' + total + ')');
|
||||
//console.log('-------------');
|
||||
|
||||
for (var i = 0; i < total; i++)
|
||||
{
|
||||
data.addFrame(new Frame(x, y, frameWidth, frameHeight));
|
||||
|
||||
//console.log('Frame', i, '=', x, y);
|
||||
|
||||
x += frameWidth;
|
||||
|
||||
if (x === width)
|
||||
{
|
||||
x = 0;
|
||||
y += frameHeight;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
public static parseJSONData(game: Game, json): FrameData {
|
||||
|
||||
// Let's create some frames then
|
||||
var data: FrameData = new FrameData();
|
||||
|
||||
// By this stage frames is a fully parsed array
|
||||
var frames = json;
|
||||
|
||||
var newFrame:Frame;
|
||||
|
||||
for (var i = 0; i < frames.length; i++)
|
||||
{
|
||||
newFrame = data.addFrame(new Frame(frames[i].frame.x, frames[i].frame.y, frames[i].frame.w, frames[i].frame.h));
|
||||
newFrame.setTrim(frames[i].trimmed, frames[i].sourceSize.w, frames[i].sourceSize.h, frames[i].spriteSourceSize.x, frames[i].spriteSourceSize.y, frames[i].spriteSourceSize.w, frames[i].spriteSourceSize.h);
|
||||
newFrame.filename = frames[i].filename;
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
64
Phaser/system/animation/Frame.ts
Normal file
|
@ -0,0 +1,64 @@
|
|||
/// <reference path="../../Game.ts" />
|
||||
/// <reference path="../../Sprite.ts" />
|
||||
/// <reference path="Animation.ts" />
|
||||
/// <reference path="AnimationLoader.ts" />
|
||||
/// <reference path="FrameData.ts" />
|
||||
|
||||
class Frame {
|
||||
|
||||
constructor(x: number, y: number, width: number, height: number) {
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
this.rotated = false;
|
||||
this.trimmed = false;
|
||||
|
||||
}
|
||||
|
||||
// Position within the image to cut from
|
||||
public x: number;
|
||||
public y: number;
|
||||
public width: number;
|
||||
public height: number;
|
||||
|
||||
// Useful for Texture Atlas files
|
||||
public filename: string;
|
||||
|
||||
// Rotated? (not yet implemented)
|
||||
public rotated: bool = false;
|
||||
|
||||
// Either cw or ccw, rotation is always 90 degrees
|
||||
public rotationDirection: string = 'cw';
|
||||
|
||||
// Was it trimmed when packed?
|
||||
public trimmed: bool;
|
||||
|
||||
// The coordinates of the trimmed sprite inside the original sprite
|
||||
public sourceSizeW: number;
|
||||
public sourceSizeH: number;
|
||||
public spriteSourceSizeX: number;
|
||||
public spriteSourceSizeY: number;
|
||||
public spriteSourceSizeW: number;
|
||||
public spriteSourceSizeH: number;
|
||||
|
||||
public setRotation(rotated: bool, rotationDirection: string) {
|
||||
// Not yet supported
|
||||
}
|
||||
|
||||
public setTrim(trimmed: bool, actualWidth, actualHeight, destX, destY, destWidth, destHeight, ) {
|
||||
|
||||
this.trimmed = trimmed;
|
||||
|
||||
this.sourceSizeW = actualWidth;
|
||||
this.sourceSizeH = actualHeight;
|
||||
this.spriteSourceSizeX = destX;
|
||||
this.spriteSourceSizeY = destY;
|
||||
this.spriteSourceSizeW = destWidth;
|
||||
this.spriteSourceSizeH = destHeight;
|
||||
|
||||
}
|
||||
|
||||
}
|
81
Phaser/system/animation/FrameData.ts
Normal file
|
@ -0,0 +1,81 @@
|
|||
/// <reference path="../../Game.ts" />
|
||||
/// <reference path="../../Sprite.ts" />
|
||||
/// <reference path="Animation.ts" />
|
||||
/// <reference path="AnimationLoader.ts" />
|
||||
/// <reference path="Frame.ts" />
|
||||
|
||||
class FrameData {
|
||||
|
||||
constructor() {
|
||||
|
||||
this._frames = [];
|
||||
|
||||
}
|
||||
|
||||
private _frames: Frame[];
|
||||
|
||||
public get total(): number {
|
||||
return this._frames.length;
|
||||
}
|
||||
|
||||
public addFrame(frame: Frame):Frame {
|
||||
|
||||
this._frames.push(frame);
|
||||
|
||||
return frame;
|
||||
|
||||
}
|
||||
|
||||
public getFrame(frame: number):Frame {
|
||||
|
||||
if (this._frames[frame])
|
||||
{
|
||||
return this._frames[frame];
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public getFrameRange(start: number, end: number, output?:Frame[] = []):Frame[] {
|
||||
|
||||
for (var i = start; i <= end; i++)
|
||||
{
|
||||
output.push(this._frames[i]);
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
public getFrameIndexes(output?:number[] = []):number[] {
|
||||
|
||||
output.length = 0;
|
||||
|
||||
for (var i = 0; i < this._frames.length; i++)
|
||||
{
|
||||
output.push(i);
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
public getAllFrames():Frame[] {
|
||||
return this._frames;
|
||||
}
|
||||
|
||||
public getFrames(range: number[]) {
|
||||
|
||||
var output: Frame[] = [];
|
||||
|
||||
for (var i = 0; i < range.length; i++)
|
||||
{
|
||||
output.push(this._frames[i]);
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
}
|
49
Phaser/system/input/Input.ts
Normal file
|
@ -0,0 +1,49 @@
|
|||
/// <reference path="../../Game.ts" />
|
||||
/// <reference path="Mouse.ts" />
|
||||
/// <reference path="Keyboard.ts" />
|
||||
|
||||
class Input {
|
||||
|
||||
constructor(game: Game) {
|
||||
|
||||
this._game = game;
|
||||
|
||||
this.mouse = new Mouse(this._game);
|
||||
this.keyboard = new Keyboard(this._game);
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
|
||||
public mouse: Mouse;
|
||||
public keyboard: Keyboard;
|
||||
|
||||
public x: number;
|
||||
public y: number;
|
||||
|
||||
public update() {
|
||||
|
||||
this.mouse.update();
|
||||
|
||||
}
|
||||
|
||||
public reset() {
|
||||
|
||||
this.mouse.reset();
|
||||
this.keyboard.reset();
|
||||
|
||||
}
|
||||
|
||||
public getWorldX(camera: Camera): number {
|
||||
|
||||
return this.x;
|
||||
|
||||
}
|
||||
|
||||
public getWorldY(camera: Camera): number {
|
||||
|
||||
return this.y;
|
||||
|
||||
}
|
||||
|
||||
}
|
210
Phaser/system/input/Keyboard.ts
Normal file
|
@ -0,0 +1,210 @@
|
|||
/// <reference path="../../Game.ts" />
|
||||
/// <reference path="Input.ts" />
|
||||
|
||||
class Keyboard {
|
||||
|
||||
constructor(game: Game) {
|
||||
|
||||
this._game = game;
|
||||
this.start();
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
|
||||
private _keys = {};
|
||||
|
||||
public start() {
|
||||
|
||||
document.body.addEventListener('keydown', (event: KeyboardEvent) => this.onKeyDown(event), false);
|
||||
document.body.addEventListener('keyup', (event: KeyboardEvent) => this.onKeyUp(event), false);
|
||||
|
||||
}
|
||||
|
||||
public onKeyDown(event: KeyboardEvent) {
|
||||
|
||||
if (!this._keys[event.keyCode])
|
||||
{
|
||||
this._keys[event.keyCode] = { isDown: true, timeDown: this._game.time.now, timeUp: 0 };
|
||||
}
|
||||
else
|
||||
{
|
||||
this._keys[event.keyCode].isDown = true;
|
||||
this._keys[event.keyCode].timeDown = this._game.time.now;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public onKeyUp(event: KeyboardEvent) {
|
||||
|
||||
if (!this._keys[event.keyCode])
|
||||
{
|
||||
this._keys[event.keyCode] = { isDown: false, timeDown: 0, timeUp: this._game.time.now };
|
||||
}
|
||||
else
|
||||
{
|
||||
this._keys[event.keyCode].isDown = false;
|
||||
this._keys[event.keyCode].timeUp = this._game.time.now;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public reset() {
|
||||
|
||||
for (var key in this._keys)
|
||||
{
|
||||
this._keys[key].isDown = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public justPressed(keycode: number, duration?: number = 250): bool {
|
||||
|
||||
if (this._keys[keycode] && this._keys[keycode].isDown === true && (this._game.time.now - this._keys[keycode].timeDown < duration))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public justReleased(keycode: number, duration?: number = 250): bool {
|
||||
|
||||
if (this._keys[keycode] && this._keys[keycode].isDown === false && (this._game.time.now - this._keys[keycode].timeUp < duration))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public isDown(keycode: number): bool {
|
||||
|
||||
if (this._keys[keycode])
|
||||
{
|
||||
return this._keys[keycode].isDown;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Letters
|
||||
public static A: number = "A".charCodeAt(0);
|
||||
public static B: number = "B".charCodeAt(0);
|
||||
public static C: number = "C".charCodeAt(0);
|
||||
public static D: number = "D".charCodeAt(0);
|
||||
public static E: number = "E".charCodeAt(0);
|
||||
public static F: number = "F".charCodeAt(0);
|
||||
public static G: number = "G".charCodeAt(0);
|
||||
public static H: number = "H".charCodeAt(0);
|
||||
public static I: number = "I".charCodeAt(0);
|
||||
public static J: number = "J".charCodeAt(0);
|
||||
public static K: number = "K".charCodeAt(0);
|
||||
public static L: number = "L".charCodeAt(0);
|
||||
public static M: number = "M".charCodeAt(0);
|
||||
public static N: number = "N".charCodeAt(0);
|
||||
public static O: number = "O".charCodeAt(0);
|
||||
public static P: number = "P".charCodeAt(0);
|
||||
public static Q: number = "Q".charCodeAt(0);
|
||||
public static R: number = "R".charCodeAt(0);
|
||||
public static S: number = "S".charCodeAt(0);
|
||||
public static T: number = "T".charCodeAt(0);
|
||||
public static U: number = "U".charCodeAt(0);
|
||||
public static V: number = "V".charCodeAt(0);
|
||||
public static W: number = "W".charCodeAt(0);
|
||||
public static X: number = "X".charCodeAt(0);
|
||||
public static Y: number = "Y".charCodeAt(0);
|
||||
public static Z: number = "Z".charCodeAt(0);
|
||||
|
||||
// Numbers
|
||||
public static ZERO: number = "0".charCodeAt(0);
|
||||
public static ONE: number = "1".charCodeAt(0);
|
||||
public static TWO: number = "2".charCodeAt(0);
|
||||
public static THREE: number = "3".charCodeAt(0);
|
||||
public static FOUR: number = "4".charCodeAt(0);
|
||||
public static FIVE: number = "5".charCodeAt(0);
|
||||
public static SIX: number = "6".charCodeAt(0);
|
||||
public static SEVEN: number = "7".charCodeAt(0);
|
||||
public static EIGHT: number = "8".charCodeAt(0);
|
||||
public static NINE: number = "9".charCodeAt(0);
|
||||
|
||||
// Numpad
|
||||
public static NUMPAD_0: number = 96;
|
||||
public static NUMPAD_1: number = 97;
|
||||
public static NUMPAD_2: number = 98;
|
||||
public static NUMPAD_3: number = 99;
|
||||
public static NUMPAD_4: number = 100;
|
||||
public static NUMPAD_5: number = 101;
|
||||
public static NUMPAD_6: number = 102;
|
||||
public static NUMPAD_7: number = 103;
|
||||
public static NUMPAD_8: number = 104;
|
||||
public static NUMPAD_9: number = 105;
|
||||
public static NUMPAD_MULTIPLY: number = 106;
|
||||
public static NUMPAD_ADD: number = 107;
|
||||
public static NUMPAD_ENTER: number = 108;
|
||||
public static NUMPAD_SUBTRACT: number = 109;
|
||||
public static NUMPAD_DECIMAL: number = 110;
|
||||
public static NUMPAD_DIVIDE: number = 111;
|
||||
|
||||
// Function Keys
|
||||
public static F1: number = 112;
|
||||
public static F2: number = 113;
|
||||
public static F3: number = 114;
|
||||
public static F4: number = 115;
|
||||
public static F5: number = 116;
|
||||
public static F6: number = 117;
|
||||
public static F7: number = 118;
|
||||
public static F8: number = 119;
|
||||
public static F9: number = 120;
|
||||
public static F10: number = 121;
|
||||
public static F11: number = 122;
|
||||
public static F12: number = 123;
|
||||
public static F13: number = 124;
|
||||
public static F14: number = 125;
|
||||
public static F15: number = 126;
|
||||
|
||||
// Symbol Keys
|
||||
public static COLON: number = 186;
|
||||
public static EQUALS: number = 187;
|
||||
public static UNDERSCORE: number = 189;
|
||||
public static QUESTION_MARK: number = 191;
|
||||
public static TILDE: number = 192;
|
||||
public static OPEN_BRACKET: number = 219;
|
||||
public static BACKWARD_SLASH: number = 220;
|
||||
public static CLOSED_BRACKET: number = 221;
|
||||
public static QUOTES: number = 222;
|
||||
|
||||
// Other Keys
|
||||
public static BACKSPACE: number = 8;
|
||||
public static TAB: number = 9;
|
||||
public static CLEAR: number = 12;
|
||||
public static ENTER: number = 13;
|
||||
public static SHIFT: number = 16;
|
||||
public static CONTROL: number = 17;
|
||||
public static ALT: number = 18;
|
||||
public static CAPS_LOCK: number = 20;
|
||||
public static ESC: number = 27;
|
||||
public static SPACEBAR: number = 32;
|
||||
public static PAGE_UP: number = 33;
|
||||
public static PAGE_DOWN: number = 34;
|
||||
public static END: number = 35;
|
||||
public static HOME: number = 36;
|
||||
public static LEFT: number = 37;
|
||||
public static UP: number = 38;
|
||||
public static RIGHT: number = 39;
|
||||
public static DOWN: number = 40;
|
||||
public static INSERT: number = 45;
|
||||
public static DELETE: number = 46;
|
||||
public static HELP: number = 47;
|
||||
public static NUM_LOCK: number = 144;
|
||||
|
||||
}
|
92
Phaser/system/input/Mouse.ts
Normal file
|
@ -0,0 +1,92 @@
|
|||
/// <reference path="../../Game.ts" />
|
||||
/// <reference path="Input.ts" />
|
||||
|
||||
class Mouse {
|
||||
|
||||
constructor(game: Game) {
|
||||
|
||||
this._game = game;
|
||||
this.start();
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
|
||||
private _x: number = 0;
|
||||
private _y: number = 0;
|
||||
|
||||
public button: number;
|
||||
|
||||
public static LEFT_BUTTON: number = 0;
|
||||
public static MIDDLE_BUTTON: number = 1;
|
||||
public static RIGHT_BUTTON: number = 2;
|
||||
|
||||
public isDown: bool = false;
|
||||
public isUp: bool = true;
|
||||
public timeDown: number = 0;
|
||||
public duration: number = 0;
|
||||
public timeUp: number = 0;
|
||||
|
||||
public start() {
|
||||
|
||||
this._game.stage.canvas.addEventListener('mousedown', (event: MouseEvent) => this.onMouseDown(event), true);
|
||||
this._game.stage.canvas.addEventListener('mousemove', (event: MouseEvent) => this.onMouseMove(event), true);
|
||||
this._game.stage.canvas.addEventListener('mouseup', (event: MouseEvent) => this.onMouseUp(event), true);
|
||||
|
||||
}
|
||||
|
||||
public reset() {
|
||||
|
||||
this.isDown = false;
|
||||
this.isUp = true;
|
||||
|
||||
}
|
||||
|
||||
public onMouseDown(event: MouseEvent) {
|
||||
|
||||
this.button = event.button;
|
||||
|
||||
this._x = event.clientX - this._game.stage.x;
|
||||
this._y = event.clientY - this._game.stage.y;
|
||||
|
||||
this.isDown = true;
|
||||
this.isUp = false;
|
||||
this.timeDown = this._game.time.now;
|
||||
|
||||
}
|
||||
|
||||
public update() {
|
||||
|
||||
this._game.input.x = this._x;
|
||||
this._game.input.y = this._y;
|
||||
|
||||
if (this.isDown)
|
||||
{
|
||||
this.duration = this._game.time.now - this.timeDown;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public onMouseMove(event: MouseEvent) {
|
||||
|
||||
this.button = event.button;
|
||||
|
||||
this._x = event.clientX - this._game.stage.x;
|
||||
this._y = event.clientY - this._game.stage.y;
|
||||
|
||||
}
|
||||
|
||||
public onMouseUp(event: MouseEvent) {
|
||||
|
||||
this.button = event.button;
|
||||
this.isDown = false;
|
||||
this.isUp = true;
|
||||
this.timeUp = this._game.time.now;
|
||||
this.duration = this.timeUp - this.timeDown;
|
||||
|
||||
this._x = event.clientX - this._game.stage.x;
|
||||
this._y = event.clientY - this._game.stage.y;
|
||||
|
||||
}
|
||||
|
||||
}
|
146
README.md
|
@ -1,4 +1,146 @@
|
|||
phaser
|
||||
Phaser
|
||||
======
|
||||
|
||||
Phaser is a light-weight 2D game framework for making HTML5 games for desktop and mobile browsers
|
||||
Version 0.5
|
||||
|
||||
12th April 2013
|
||||
|
||||
By Richard Davey, [Photon Storm](http://www.photonstorm.com)
|
||||
|
||||
Phaser is a 2D JavaScript/TypeScript HTML5 Game Framework based heavily on [Flixel](http://www.flixel.org).
|
||||
|
||||
Follow us on [twitter](https://twitter.com/photonstorm) and our [blog](http://www.photonstorm.com) for development updates.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
Games created with Phaser require a modern web browser that supports the canvas tag. This includes Internet Explorer 9+, Firefox, Chrome, Safari and Opera. It also works on mobile web browsers including stock Android 2.x browser and above and iOS5 Mobile Safari and above.
|
||||
|
||||
For developing with Phaser you can use either a plain-vanilla JavaScript approach or [TypeScript](https://typescript.codeplex.com/). We made no assumptions about how you like to code your games, and were careful not to impose any form of class/inheritance/structure upon you. See the Getting Started section for examples.
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
Phaser was born from a cross-polination of the AS3 Flixel game library and our own internal HTML5 game framework. The objective was to allow you to make games _really_ quickly and remove some of the speed barriers HTML5 puts in your way.
|
||||
|
||||
Phaser fully or partially supports the following features. This list is growing constantly and we are aware there are still a number of essential features missing:
|
||||
|
||||
* Asset Loading
|
||||
Images, Sprite Sheets, Texture Packer Data, JSON, Text Files, Audio File.
|
||||
|
||||
* Cameras
|
||||
Multiple world cameras, camera scale, zoom, rotation, deadzones and Sprite following.
|
||||
|
||||
* Sprites
|
||||
All sprites have physics properties including velocity, acceleration, bounce and drag.
|
||||
ScrollFactor allows them to re-act to cameras at different rates.
|
||||
|
||||
* Groups
|
||||
Group sprites together for collision checks, visibility toggling and function iteration.
|
||||
|
||||
* Animation
|
||||
Sprites can be animated by a sprite sheet or Texture Atlas (JSON Array format supported).
|
||||
Animation playback controls, looping, fps based timer and custom frames.
|
||||
|
||||
* Collision
|
||||
A QuadTree based Sprite to Sprite, Sprite to Group or Group to Group collision system.
|
||||
|
||||
* Particles
|
||||
An Emitter can emit Sprites in a burst or at a constant rate, setting physics properties.
|
||||
|
||||
* Input
|
||||
Keyboard and Mouse handling supported (Touch coming asap)
|
||||
|
||||
* Stage
|
||||
Easily change properties about your game via the stage, such as background color, position and size.
|
||||
|
||||
* World
|
||||
The game world can be any size and Sprites and collision happens within it.
|
||||
|
||||
* Sound (partial support)
|
||||
Currently uses WebAudio for playback. A lot more work needs to be done in this area.
|
||||
|
||||
* State Management
|
||||
For larger games it's useful to break your game down into States, i.e. MainMenu, Level1, GameOver, etc.
|
||||
The state manager makes swapping states easy, but the use of a state is completely optional.
|
||||
|
||||
* Cache
|
||||
All loaded resources are stored in an easy to access cache, which can be cleared between State changes
|
||||
or persist through-out the whole game.
|
||||
|
||||
* Tilemaps
|
||||
Support for CSV and Tiled JSON format tile maps is implemented but currently limited.
|
||||
|
||||
Work in Progress
|
||||
----------------
|
||||
|
||||
We've a number of features that we know Phaser is lacking, here is our current priority list:
|
||||
|
||||
* Tilemap collision and layers
|
||||
* Better sound controls
|
||||
* Touch and MSPointer support
|
||||
* Game scaling on mobile
|
||||
* Text Rendering
|
||||
* Buttons
|
||||
|
||||
Beyond this there are lots of other things we plan to add such as WebGL support, Spline animation format support, sloped collision tiles, path finding and support for custom plugins. But the list above are more priority items and is by no means exhaustive either! However we do feel that the core structure of Phaser is now pretty locked down, so safe to use for small scale production games.
|
||||
|
||||
Test Suite
|
||||
----------
|
||||
|
||||
Phase comes with an ever growing Test Suite. Personally we learn better by looking at small refined code examples, so we create lots of them to test each new feature we add. Inside the Tests folder you'll find the current set. If you write a particuarly good test then please send it to us.
|
||||
|
||||
The tests need running through a local web server (to avoid file access permission errors from your browser).
|
||||
|
||||
Make sure you can browse to the Tests folder via your web server. If you've got php installed then launch:
|
||||
|
||||
Tests/index.php
|
||||
|
||||
Right now the Test Suite requires PHP, but we will remove this requirement soon.
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
Phaser is in early stages and although we've still got a lot to add to it, we wanted to just get it out there and share it with the world.
|
||||
|
||||
If you find a bug (highly likely!) then please report it on github.
|
||||
|
||||
If you have a feature request, or have written a small game or demo that shows Phaser in use, then please get in touch. We'd love to hear from you.
|
||||
|
||||
You can do this on the Phaser board at the [HTML5 Game Devs forum]() or email: rich@photonstorm.com
|
||||
|
||||
Bugs?
|
||||
-----
|
||||
|
||||
Please add them to the [Issue Tracker][1] with as much info as possible.
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Copyright 2013 Richard Davey, Photon Storm Ltd. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are
|
||||
permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
of conditions and the following disclaimer in the documentation and/or other materials
|
||||
provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY RICHARD DAVEY ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RICHARD DAVEY OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those of the
|
||||
authors and should not be interpreted as representing official policies, either expressed
|
||||
|
||||
[1]: https://github.com/photonstorm/phaser/issues
|
||||
[phaser]: https://github.com/photonstorm/phaser
|
||||
|
|
37
Tests/.gitignore
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
|
||||
#ignore thumbnails created by windows
|
||||
Thumbs.db
|
||||
#Ignore files build by Visual Studio
|
||||
*.obj
|
||||
*.exe
|
||||
*.pdb
|
||||
*.user
|
||||
*.aps
|
||||
*.pch
|
||||
*.vspscc
|
||||
*_i.c
|
||||
*_p.c
|
||||
*.ncb
|
||||
*.suo
|
||||
*.sln
|
||||
*.tlb
|
||||
*.tlh
|
||||
*.bak
|
||||
*.cache
|
||||
*.ilk
|
||||
*.log
|
||||
*.map
|
||||
*.orig
|
||||
*.map
|
||||
*.config
|
||||
*.sublime-workspace
|
||||
launcher.html
|
||||
tests.html
|
||||
[Bb]in
|
||||
[Dd]ebug*/
|
||||
*.lib
|
||||
*.sbr
|
||||
obj/
|
||||
[Rr]elease*/
|
||||
_ReSharper*/
|
||||
[Tt]est[Rr]esult*
|
8
Tests/Phaser Tests.sublime-project
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"folders":
|
||||
[
|
||||
{
|
||||
"path": "/D/wamp/www/phaser/Tests"
|
||||
}
|
||||
]
|
||||
}
|
93
Tests/Tests.csproj
Normal file
|
@ -0,0 +1,93 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<ProjectGuid>{DC8A0795-0F9C-4216-A95D-6C3346EA7E26}</ProjectGuid>
|
||||
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<OutputPath>bin</OutputPath>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<DebugType>full</DebugType>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<UseIISExpress>true</UseIISExpress>
|
||||
<IISExpressSSLPort />
|
||||
<IISExpressAnonymousAuthentication />
|
||||
<IISExpressWindowsAuthentication />
|
||||
<IISExpressUseClassicPipelineMode />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<RootNamespace>Tests</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
||||
<WebProjectProperties>
|
||||
<UseIIS>True</UseIIS>
|
||||
<AutoAssignPort>True</AutoAssignPort>
|
||||
<DevelopmentServerPort>0</DevelopmentServerPort>
|
||||
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||
<IISUrl>http://localhost:51901/</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
<UseCustomServer>False</UseCustomServer>
|
||||
<CustomServerUrl>
|
||||
</CustomServerUrl>
|
||||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||
</WebProjectProperties>
|
||||
</FlavorProperties>
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
|
||||
<TypeScriptTarget>ES5</TypeScriptTarget>
|
||||
<TypeScriptIncludeComments>true</TypeScriptIncludeComments>
|
||||
<TypeScriptSourceMap>false</TypeScriptSourceMap>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
|
||||
<TypeScriptTarget>ES5</TypeScriptTarget>
|
||||
<TypeScriptIncludeComments>true</TypeScriptIncludeComments>
|
||||
<TypeScriptSourceMap>false</TypeScriptSourceMap>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<TypeScriptCompile Include="cameras\camera alpha.ts" />
|
||||
<TypeScriptCompile Include="cameras\camera bounds.ts" />
|
||||
<TypeScriptCompile Include="cameras\camera position.ts" />
|
||||
<TypeScriptCompile Include="cameras\camera rotation.ts" />
|
||||
<TypeScriptCompile Include="cameras\camera scale.ts" />
|
||||
<TypeScriptCompile Include="cameras\camera shadow.ts" />
|
||||
<TypeScriptCompile Include="cameras\camera texture.ts" />
|
||||
<TypeScriptCompile Include="cameras\fade fx.ts" />
|
||||
<TypeScriptCompile Include="cameras\flash fx.ts" />
|
||||
<TypeScriptCompile Include="cameras\focus on.ts" />
|
||||
<TypeScriptCompile Include="cameras\follow deadzone.ts" />
|
||||
<TypeScriptCompile Include="cameras\follow sprite.ts" />
|
||||
<TypeScriptCompile Include="cameras\follow topdown.ts" />
|
||||
<TypeScriptCompile Include="cameras\multicam1.ts" />
|
||||
<TypeScriptCompile Include="cameras\scroll factor.ts" />
|
||||
<TypeScriptCompile Include="cameras\shake fx.ts" />
|
||||
<TypeScriptCompile Include="collision\collide sprites.ts" />
|
||||
<TypeScriptCompile Include="collision\falling balls.ts" />
|
||||
<TypeScriptCompile Include="groups\basic group.ts" />
|
||||
<TypeScriptCompile Include="input\mouse scale.ts" />
|
||||
<TypeScriptCompile Include="mini games\formula 1.ts" />
|
||||
<TypeScriptCompile Include="misc\multi game.ts" />
|
||||
<TypeScriptCompile Include="particles\basic emitter.ts" />
|
||||
<TypeScriptCompile Include="particles\graphic emitter.ts" />
|
||||
<TypeScriptCompile Include="particles\multiple streams.ts" />
|
||||
<TypeScriptCompile Include="particles\sprite emitter.ts" />
|
||||
<TypeScriptCompile Include="particles\when particles collide.ts" />
|
||||
<TypeScriptCompile Include="sprites\animation 1.ts" />
|
||||
<TypeScriptCompile Include="sprites\mark of the bunny.ts" />
|
||||
<TypeScriptCompile Include="sprites\texture atlas 2.ts" />
|
||||
<TypeScriptCompile Include="sprites\texture atlas 3.ts" />
|
||||
<TypeScriptCompile Include="sprites\texture atlas 4.ts" />
|
||||
<TypeScriptCompile Include="sprites\texture atlas.ts" />
|
||||
<TypeScriptCompile Include="sprites\velocity.ts" />
|
||||
<TypeScriptCompile Include="tilemap\basic tilemap.ts" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\TypeScript\Microsoft.TypeScript.targets" />
|
||||
</Project>
|
BIN
Tests/assets/fonts/032.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
Tests/assets/fonts/036.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
Tests/assets/fonts/047.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
Tests/assets/fonts/070.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
Tests/assets/fonts/072.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
Tests/assets/fonts/087.png
Normal file
After Width: | Height: | Size: 5 KiB |
BIN
Tests/assets/fonts/110.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
Tests/assets/fonts/141.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
Tests/assets/fonts/165.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
Tests/assets/fonts/16x16-blue-metal.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
Tests/assets/fonts/16x16-cool-metal.png
Normal file
After Width: | Height: | Size: 5.9 KiB |
BIN
Tests/assets/fonts/171.png
Normal file
After Width: | Height: | Size: 7.8 KiB |
BIN
Tests/assets/fonts/1984-nocooper-tebirod_logo.png
Normal file
After Width: | Height: | Size: 9.1 KiB |
BIN
Tests/assets/fonts/225.png
Normal file
After Width: | Height: | Size: 4.5 KiB |
BIN
Tests/assets/fonts/231.png
Normal file
After Width: | Height: | Size: 7.9 KiB |
BIN
Tests/assets/fonts/260.png
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
Tests/assets/fonts/283.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
Tests/assets/fonts/284.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
Tests/assets/fonts/297.png
Normal file
After Width: | Height: | Size: 5.5 KiB |
BIN
Tests/assets/fonts/313.png
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
Tests/assets/fonts/8x9_golden.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
Tests/assets/fonts/ACFRESET.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
Tests/assets/fonts/FONT3.png
Normal file
After Width: | Height: | Size: 7.5 KiB |
BIN
Tests/assets/fonts/KNIGHT3.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
Tests/assets/fonts/MEGADETH.GIF
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
Tests/assets/fonts/MEGAMINI.GIF
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
Tests/assets/fonts/PICKPILE.png
Normal file
After Width: | Height: | Size: 7.8 KiB |
BIN
Tests/assets/fonts/STEEL.png
Normal file
After Width: | Height: | Size: 9.6 KiB |
BIN
Tests/assets/fonts/ST_ADM.GIF
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
Tests/assets/fonts/WAYNE_3D.png
Normal file
After Width: | Height: | Size: 7 KiB |
BIN
Tests/assets/fonts/bluepink_font.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
Tests/assets/fonts/bubbles_font.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
Tests/assets/fonts/deltaforce_font.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
Tests/assets/fonts/digits_font_ilkke.png
Normal file
After Width: | Height: | Size: 268 B |
BIN
Tests/assets/fonts/gold_font.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
Tests/assets/fonts/grid_legend_font_aliased.png
Normal file
After Width: | Height: | Size: 263 B |
BIN
Tests/assets/fonts/grid_legend_font_solid.png
Normal file
After Width: | Height: | Size: 318 B |
BIN
Tests/assets/fonts/knighthawks_font.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
Tests/assets/fonts/naos_font.png
Normal file
After Width: | Height: | Size: 8.7 KiB |
BIN
Tests/assets/fonts/robocop_font.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
Tests/assets/fonts/spaz_font.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
Tests/assets/fonts/steelpp_font.png
Normal file
After Width: | Height: | Size: 9.3 KiB |
BIN
Tests/assets/fonts/tbj_font.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
Tests/assets/fonts/tsk_font.png
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
Tests/assets/games/f1/car1.png
Normal file
After Width: | Height: | Size: 274 B |
BIN
Tests/assets/games/f1/track.png
Normal file
After Width: | Height: | Size: 8.9 KiB |
70
Tests/assets/maps/catastrophi_level1.csv
Normal file
|
@ -0,0 +1,70 @@
|
|||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,59,64,63,57,25,25,41,41,25,25,59,59,57,59
|
||||
0,0,3,0,0,0,0,0,0,0,3,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,59,59,57,57,25,25,25,25,25,25,59,66,65,59
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,59,66,65,57,25,25,25,25,25,25,59,64,63,59
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,3,0,0,3,0,0,0,0,0,0,0,0,59,64,63,57,25,25,41,41,25,25,59,59,57,59
|
||||
0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,59,59,57,57,25,25,25,25,25,25,59,66,65,59
|
||||
0,0,0,3,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,3,0,59,66,65,57,25,25,25,25,25,25,59,64,63,59
|
||||
0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,54,55,55,55,69,55,55,69,55,55,55,55,55,55,55,69,55,55,56,0,0,0,0,59,64,63,57,25,25,41,41,25,25,59,66,65,66
|
||||
0,0,54,55,69,55,55,55,69,55,55,56,0,0,0,0,2,0,0,3,0,0,0,0,0,0,0,57,25,25,25,25,25,25,25,25,25,25,25,58,25,25,25,25,25,66,55,56,0,3,59,59,57,57,25,29,25,25,25,25,59,64,61,61
|
||||
3,0,57,25,25,25,25,25,25,25,25,59,0,3,0,0,0,0,0,0,0,0,0,0,3,0,0,57,25,25,90,26,26,25,25,25,25,25,25,58,25,25,71,25,25,25,25,59,0,0,59,66,65,57,25,25,25,25,25,25,59,59,64,61
|
||||
0,0,67,25,25,25,25,25,25,25,25,66,55,55,69,55,55,55,55,55,55,69,55,55,55,56,0,67,25,25,90,26,26,25,25,25,25,25,25,53,25,25,79,77,77,73,25,68,0,0,59,64,63,57,25,25,41,41,25,25,59,59,59,64
|
||||
0,0,57,25,37,25,38,25,25,25,25,25,42,25,25,25,25,25,25,25,25,25,25,25,25,68,0,57,25,25,90,26,26,25,25,25,25,25,25,58,25,25,25,25,25,78,44,59,0,0,59,59,57,57,25,25,25,25,25,25,59,59,59,59
|
||||
0,0,57,25,25,25,25,25,25,25,25,64,61,61,61,61,61,61,70,61,61,61,61,63,25,59,0,57,25,25,25,25,25,25,25,25,25,25,25,58,25,25,25,25,25,64,61,62,0,0,59,66,65,57,25,25,25,25,25,30,59,59,59,66
|
||||
0,3,67,25,25,25,25,25,25,25,25,59,0,0,0,0,0,0,0,0,0,0,0,57,40,59,0,60,61,70,61,70,61,70,61,61,61,63,36,64,61,61,70,61,61,62,0,0,0,0,59,64,63,57,25,25,41,41,25,25,59,59,66,55
|
||||
0,0,57,25,25,25,25,25,25,25,25,59,0,0,3,0,0,2,0,0,0,3,0,67,25,59,0,0,0,0,0,0,0,0,0,0,0,57,36,59,0,0,0,0,0,0,0,0,0,0,59,59,57,57,25,25,25,25,25,25,59,66,55,55
|
||||
0,0,60,61,70,61,61,61,70,61,61,62,0,0,0,0,0,0,0,0,0,0,0,57,25,59,0,0,0,0,0,0,0,2,0,0,0,57,36,59,0,0,3,0,0,0,0,0,3,0,59,66,65,57,28,25,25,25,25,25,59,64,61,61
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,57,25,68,0,2,0,0,3,0,0,0,0,1,0,57,86,59,0,0,0,0,0,0,0,0,0,0,59,64,63,57,25,25,41,41,25,25,59,59,64,61
|
||||
0,1,0,0,3,54,55,69,55,55,55,69,55,55,55,69,55,55,56,0,0,0,0,57,40,59,0,0,0,0,0,0,0,0,0,0,0,57,36,59,0,0,0,0,0,2,0,0,0,0,59,59,57,57,25,25,25,25,25,25,59,59,59,58
|
||||
0,0,0,0,0,57,74,81,75,77,74,71,75,77,74,27,75,77,59,0,0,3,0,67,25,59,0,54,55,69,55,69,55,69,55,55,55,65,36,66,55,55,56,0,0,0,0,3,0,0,59,66,65,57,25,25,25,25,25,25,59,59,66,55
|
||||
0,0,3,0,0,57,25,25,25,25,25,25,25,25,25,25,25,25,68,0,0,0,0,57,25,59,0,57,25,25,25,25,25,25,25,59,25,25,25,25,25,25,66,55,56,0,0,0,0,0,59,64,63,57,25,25,41,41,25,25,59,66,55,55
|
||||
0,54,55,69,55,65,25,25,25,25,25,25,25,25,25,25,25,25,59,0,0,0,0,57,25,59,0,67,25,25,25,25,25,108,25,59,25,108,25,25,25,25,25,25,59,0,0,0,1,0,59,59,57,57,25,25,25,25,25,25,66,55,55,55
|
||||
0,57,43,43,43,43,25,25,25,25,25,25,25,25,25,25,25,25,66,55,55,55,55,65,25,68,0,57,25,42,25,25,25,59,25,59,25,59,25,25,25,25,25,25,68,0,0,0,0,0,59,66,65,57,25,25,25,25,25,92,79,76,77,77
|
||||
0,67,43,43,43,43,25,25,25,25,25,25,25,25,25,25,39,25,25,25,51,87,25,25,25,59,0,57,25,42,25,25,25,114,25,114,25,114,25,25,25,25,25,25,68,0,0,3,0,0,59,64,63,57,25,25,25,25,25,92,79,75,77,77
|
||||
0,67,90,43,43,43,25,25,25,64,61,61,61,61,63,25,25,25,64,61,61,61,61,63,25,59,0,67,25,25,25,25,25,59,25,110,25,59,25,25,25,25,25,25,59,0,0,0,0,0,59,59,57,57,25,25,25,25,25,25,78,76,77,77
|
||||
0,57,90,43,43,43,25,25,25,59,64,70,70,63,57,46,25,25,59,0,0,0,0,57,25,59,0,57,25,25,25,25,25,59,25,25,25,59,25,25,25,25,64,61,62,0,0,0,3,2,59,66,65,57,25,25,25,25,25,28,78,75,77,77
|
||||
0,60,61,70,61,63,25,25,25,59,68,64,63,67,57,73,25,25,59,0,3,0,0,57,42,59,0,60,61,61,63,25,64,61,61,70,61,61,61,70,61,61,62,0,0,0,0,0,0,0,66,55,55,65,28,25,41,41,25,25,75,77,77,77
|
||||
0,0,0,0,0,67,27,25,25,59,68,66,65,67,57,75,77,77,59,0,0,0,0,57,42,59,0,0,0,0,57,25,59,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,54,55,69,69,55,55,56,25,25,25,25,76,77,77,77
|
||||
0,0,0,0,0,67,71,25,25,59,66,69,69,65,57,77,77,77,59,0,0,3,0,60,70,62,0,0,0,0,57,86,59,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,57,74,25,25,25,75,66,55,105,25,76,74,76,77,77
|
||||
0,54,55,69,55,65,25,25,25,66,55,55,55,55,65,25,25,25,59,0,0,0,0,0,0,0,0,0,0,0,57,25,59,0,3,0,0,0,0,3,0,0,0,0,0,3,0,0,0,67,25,27,25,27,25,89,25,25,25,75,73,75,77,77
|
||||
0,57,44,26,47,26,25,25,25,25,25,25,25,25,25,25,81,25,68,0,0,0,0,0,0,0,0,0,0,0,57,25,59,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,67,25,27,27,27,25,64,63,29,25,30,78,76,77,77
|
||||
0,67,26,50,26,26,25,25,25,25,25,25,25,25,25,25,25,25,59,0,0,0,54,55,55,69,55,55,55,55,65,25,66,55,55,69,55,55,55,69,55,69,55,69,55,56,0,0,0,57,73,25,25,25,76,59,57,77,77,77,74,75,77,77
|
||||
0,57,51,26,44,26,25,25,25,25,25,25,25,25,25,25,25,76,59,0,3,0,57,74,25,25,75,77,77,74,25,37,25,75,77,77,77,74,25,25,25,25,25,25,75,59,0,0,0,60,61,63,36,64,61,62,60,61,61,61,61,61,61,61
|
||||
0,57,26,47,26,26,25,25,25,25,25,25,25,25,25,25,94,78,59,0,0,0,67,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,68,0,3,0,0,0,57,36,59,0,0,0,3,2,0,0,0,3,0
|
||||
0,67,50,26,51,64,61,61,70,61,63,25,64,70,61,61,61,61,62,2,0,0,57,25,104,55,105,25,25,104,55,55,55,105,25,25,25,104,55,55,55,55,55,105,25,59,0,0,0,0,0,57,36,59,0,0,0,0,0,0,0,0,0,0
|
||||
0,57,26,44,26,59,0,0,0,0,57,85,59,0,0,0,0,0,0,0,0,0,57,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,59,0,0,54,55,55,65,86,66,55,69,55,55,69,55,55,55,56,0
|
||||
0,60,61,70,61,62,0,0,0,0,57,25,59,0,0,0,0,0,0,0,0,0,67,25,104,55,105,25,104,55,55,105,25,104,55,55,55,55,105,25,104,105,25,25,25,68,0,0,57,25,25,25,25,25,25,25,78,25,25,25,25,25,59,0
|
||||
0,0,0,0,0,0,0,3,0,0,57,25,59,0,0,1,0,0,0,3,0,0,57,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,59,0,0,57,25,48,25,25,25,25,25,78,25,71,25,71,25,59,0
|
||||
0,0,0,0,0,0,0,0,0,0,57,25,59,0,0,0,0,0,0,0,0,0,57,25,104,55,55,55,55,105,25,104,55,105,25,104,105,25,64,70,61,70,61,70,61,62,0,0,67,25,25,25,76,77,77,77,74,25,25,25,25,25,59,0
|
||||
0,0,0,0,0,0,0,0,0,0,103,43,102,0,0,0,0,3,0,0,0,0,67,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,59,0,0,0,0,0,0,0,0,0,57,25,25,81,74,25,25,25,25,25,25,25,25,25,68,0
|
||||
0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,57,25,104,105,25,104,55,55,55,105,25,104,55,105,25,25,68,0,54,55,55,55,55,56,0,0,57,25,25,25,25,25,25,25,25,25,25,25,25,25,59,0
|
||||
0,0,3,0,2,0,0,0,1,0,0,4,0,0,3,0,0,0,0,0,0,0,57,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,59,0,57,74,25,25,28,59,0,0,57,47,26,47,26,47,26,47,26,47,26,47,26,47,59,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,67,25,104,55,55,105,25,25,25,25,104,105,25,25,25,25,68,0,57,25,81,47,25,59,0,0,57,26,47,26,47,26,47,26,47,26,47,26,47,26,59,0
|
||||
0,0,0,3,0,0,0,0,0,0,101,43,100,0,0,0,0,0,0,0,0,0,57,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,59,0,57,28,25,25,30,59,0,0,57,47,26,47,26,47,26,47,26,47,26,47,26,47,59,0
|
||||
0,0,0,0,0,0,0,3,0,0,57,25,59,0,0,3,0,0,0,0,0,0,60,61,70,61,61,70,61,61,63,25,64,61,61,70,61,61,62,0,60,61,61,61,61,62,3,0,67,25,25,25,25,25,25,25,25,25,25,25,25,25,59,0
|
||||
0,0,0,0,0,0,0,0,0,0,57,25,59,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,57,25,59,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,57,25,25,25,25,25,25,25,25,25,25,25,25,25,68,0
|
||||
0,2,0,0,54,55,69,55,69,55,65,25,66,55,69,55,55,55,55,55,55,69,55,55,56,0,0,0,0,0,57,25,59,0,0,0,0,0,3,0,0,0,0,0,3,0,0,0,57,27,26,27,26,27,26,27,26,27,26,27,26,27,59,0
|
||||
3,0,0,0,57,75,73,78,25,25,25,25,25,25,25,25,95,27,27,27,25,42,25,81,59,0,0,0,0,0,57,25,59,0,0,3,0,0,0,0,0,1,0,0,0,0,0,54,65,25,25,25,25,25,25,25,25,25,25,25,25,25,59,0
|
||||
0,0,0,54,65,73,78,78,25,25,25,25,25,25,25,25,90,27,27,27,76,77,77,77,59,0,0,2,0,0,67,25,59,0,0,0,0,0,2,0,0,0,0,0,3,0,0,57,25,25,25,25,25,25,25,25,25,25,25,25,25,25,59,0
|
||||
0,0,0,57,46,78,75,74,25,25,25,40,25,25,25,25,94,27,27,27,78,25,25,72,59,0,0,0,0,0,57,25,59,0,0,3,0,0,0,0,0,3,0,0,0,0,0,57,25,64,61,61,61,70,61,61,61,61,70,61,61,61,62,0
|
||||
0,0,54,65,25,75,77,73,25,25,25,25,25,25,76,77,79,77,77,77,74,25,25,25,59,0,0,0,0,0,57,25,59,0,0,0,0,0,0,0,0,0,0,0,0,2,0,57,25,59,0,0,0,0,0,0,0,0,0,0,3,0,0,0
|
||||
0,0,60,63,25,25,25,78,25,25,25,25,25,25,78,25,78,26,26,25,25,25,25,25,59,54,55,69,55,55,65,86,66,55,55,69,55,55,55,69,55,56,0,0,0,0,0,57,36,59,0,0,0,0,0,0,0,0,0,0,0,0,0,1
|
||||
0,0,0,57,25,25,25,75,77,77,77,25,77,77,74,25,78,26,26,25,25,25,25,25,66,65,25,25,25,42,25,41,25,42,25,25,25,25,25,25,25,59,0,0,0,3,0,67,36,68,0,0,0,0,0,0,3,0,0,0,0,0,0,0
|
||||
0,0,54,65,25,25,25,90,25,25,25,25,25,25,25,25,75,77,77,93,25,25,25,37,89,25,25,25,25,42,25,25,25,42,25,25,25,25,25,25,25,59,0,0,0,0,0,57,36,59,0,0,0,0,0,0,0,0,3,0,0,0,0,0
|
||||
0,3,60,63,25,25,25,78,25,25,25,25,25,25,25,25,25,90,25,25,25,25,25,25,64,61,61,70,61,61,61,70,61,61,61,70,61,61,61,70,61,62,0,0,0,0,0,67,25,68,0,0,3,0,0,0,3,0,0,0,0,0,0,0
|
||||
0,0,0,57,44,50,51,78,25,25,25,25,25,25,25,25,76,77,77,93,25,25,25,25,59,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,2,0,57,25,59,0,0,0,0,1,0,0,0,0,0,2,0,3,0
|
||||
0,0,1,57,94,94,94,78,25,25,25,25,25,25,25,25,78,25,25,25,25,25,25,30,59,0,0,2,0,0,0,0,3,0,0,0,0,0,3,0,0,0,0,0,0,0,0,57,25,59,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,60,61,61,61,63,25,25,25,25,25,25,64,61,61,63,37,64,61,61,70,61,62,0,0,0,0,0,3,0,0,0,0,54,55,55,69,55,55,55,69,55,55,55,55,65,86,66,55,55,55,69,55,55,55,55,69,55,55,55,56,0
|
||||
0,0,0,3,0,0,0,60,61,70,61,61,70,61,62,0,0,57,85,59,0,0,0,0,0,0,4,0,0,0,0,0,1,0,0,57,43,25,43,25,43,25,43,25,43,25,43,25,37,25,43,25,43,25,43,25,43,25,43,25,43,25,59,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,57,25,59,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,57,25,43,25,43,25,43,25,43,25,43,25,43,25,43,25,43,25,43,25,43,25,43,25,43,25,43,59,0
|
||||
0,54,55,69,55,55,55,69,55,56,0,0,0,0,0,3,0,57,25,59,0,0,3,0,54,55,69,55,55,55,55,69,55,55,55,65,43,25,43,25,43,25,43,25,43,25,43,94,43,25,43,25,43,25,43,25,81,71,83,25,43,25,68,0
|
||||
0,67,25,25,42,25,42,25,25,59,0,0,2,0,0,0,0,57,25,59,0,0,0,0,67,25,25,25,25,25,25,25,25,25,25,90,25,43,25,43,25,43,25,43,25,43,25,78,25,76,77,73,25,43,25,43,75,73,25,43,25,43,59,0
|
||||
0,57,25,25,25,26,25,25,25,59,0,0,0,0,0,1,0,57,25,59,0,0,0,0,57,25,90,90,26,90,90,26,90,90,25,90,43,25,43,25,43,25,76,77,73,25,43,78,43,78,43,78,76,77,77,77,77,74,43,25,43,25,59,0
|
||||
0,60,61,63,26,25,26,64,61,62,0,0,0,0,0,0,0,57,25,59,0,3,0,0,67,25,90,90,26,90,90,26,90,90,25,90,25,43,25,43,25,43,78,43,78,43,25,78,47,78,25,78,78,43,25,43,25,43,25,43,25,43,59,0
|
||||
0,2,0,57,93,90,92,59,0,0,0,0,0,3,0,0,0,57,25,59,0,0,0,0,57,25,25,25,25,25,25,25,25,25,25,90,43,25,43,25,43,25,78,25,78,76,77,79,77,74,43,78,78,25,43,25,43,25,43,25,43,25,68,0
|
||||
0,0,0,57,25,25,25,59,0,0,0,0,0,0,0,0,0,57,25,59,0,0,0,0,60,61,70,61,61,61,61,70,61,63,90,90,25,43,25,43,25,43,78,43,78,78,25,43,25,43,25,78,78,43,90,90,90,43,25,90,90,43,59,0
|
||||
0,0,3,57,93,90,92,66,55,56,0,1,0,0,0,3,0,57,25,59,0,0,1,0,0,0,0,0,0,0,0,0,0,57,90,90,43,25,43,25,43,25,78,25,75,74,43,25,43,25,43,78,78,25,90,90,90,25,43,90,90,25,59,0
|
||||
0,54,55,65,25,25,25,25,75,59,0,0,0,0,0,0,0,57,25,59,0,0,0,0,0,0,3,0,0,0,0,3,0,57,90,90,25,43,25,43,25,43,78,43,25,43,25,43,25,43,25,90,90,43,25,43,25,43,25,43,25,43,59,0
|
||||
0,67,47,25,25,25,94,25,25,66,55,55,55,55,55,55,55,65,25,66,55,55,55,55,55,55,55,55,55,55,55,55,55,65,90,64,61,61,61,70,61,61,61,61,70,61,61,61,61,70,61,61,61,61,61,61,70,61,61,61,70,61,62,0
|
||||
0,57,46,25,25,25,78,25,25,89,25,25,25,25,25,39,25,39,25,38,25,38,25,25,25,25,25,25,25,90,90,90,90,90,90,59,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0
|
||||
0,60,61,70,61,61,61,70,61,61,61,61,61,70,61,61,61,61,70,61,61,61,61,70,61,61,61,61,61,61,61,61,61,61,61,62,3,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,3,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
|
70
Tests/assets/maps/catastrophi_level2.csv
Normal file
|
@ -0,0 +1,70 @@
|
|||
0,57,25,41,41,25,59,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,5,5,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,57,25,25,25,25,59,0,0,9,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,6,5,6,6,5,5,6,5,6,0,5,5,5,5,0,5,5,6,0,6,6,5,0,0,0,0,0,0,0,0,5,0
|
||||
0,57,25,41,41,25,59,0,10,9,9,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,54,55,55,55,55,55,55,55,55,55,55,55,55,55,55,56,0,5,5,6,5,0,1,0,0,5,5,0,0,5,0,6,5,5,5,0,6,0,0,5,5,0,6,0,0,5,0,0,0,6,0,0,0,0
|
||||
0,57,25,25,25,25,59,0,9,8,9,0,8,0,5,5,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,5,0,0,5,0,0,0,7,5,0,0,0,57,25,25,25,25,25,25,25,25,25,25,25,25,25,25,59,0,6,6,7,0,0,0,5,0,54,55,55,55,55,55,55,55,55,55,55,118,55,55,124,55,56,0,6,6,5,6,6,0,6,5,6,0,0
|
||||
0,57,25,41,41,25,59,0,9,0,8,0,5,5,0,0,0,5,0,5,0,0,0,5,6,0,0,6,0,6,7,6,5,0,0,5,0,5,5,5,5,7,5,0,5,0,5,5,5,0,5,5,7,0,5,0,5,5,11,5,0,0,0,0,0,0,57,25,25,25,25,25,25,25,25,25,25,25,25,25,25,59,0,0,0,6,5,0,0,5,0,57,95,78,75,74,78,95,78,25,25,25,25,25,95,125,75,59,0,0,6,0,0,0,5,0,7,0,0,0
|
||||
0,57,25,25,25,25,59,0,8,5,6,7,6,5,7,6,5,7,5,5,5,6,7,0,6,7,5,5,6,0,5,6,5,6,7,5,6,5,7,5,6,0,6,0,0,5,5,0,6,7,5,5,0,6,5,5,0,6,5,5,5,0,5,0,0,0,60,61,61,61,61,61,61,61,61,61,61,63,25,25,25,66,56,0,6,0,6,5,5,5,54,65,25,78,76,77,74,46,78,25,25,25,25,25,25,25,76,66,56,0,5,0,7,5,0,0,0,6,0,0
|
||||
0,57,25,41,41,25,59,0,6,0,6,0,5,6,6,6,5,5,0,6,6,0,5,6,6,0,6,0,6,6,0,0,0,0,6,5,6,5,5,6,6,6,0,7,5,0,5,6,5,5,0,5,5,5,0,7,5,0,0,6,5,5,6,5,0,10,0,64,61,61,61,61,61,61,61,61,63,57,25,25,25,25,59,0,5,0,0,0,6,0,57,74,25,75,74,25,25,25,95,25,25,25,25,25,25,25,75,77,59,0,5,6,5,0,4,6,6,0,0,0
|
||||
0,57,25,25,25,25,59,5,0,54,55,55,69,55,55,55,55,55,69,55,55,55,55,55,69,55,55,55,55,56,4,4,4,54,55,55,55,55,69,55,55,55,55,55,69,55,55,55,55,55,69,55,55,55,55,55,69,55,55,55,55,56,5,0,0,9,5,66,55,55,55,55,55,55,55,55,65,57,25,25,25,25,59,0,0,6,5,0,0,0,57,77,73,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,59,0,7,5,0,5,0,5,6,0,7,0
|
||||
0,57,25,41,41,25,59,6,0,57,73,95,78,46,25,95,25,25,25,25,25,25,25,25,25,25,25,25,25,59,4,0,4,57,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,25,43,25,43,25,66,56,5,10,9,54,55,55,55,55,55,55,55,55,55,55,65,25,25,25,25,59,0,0,0,0,7,0,0,57,76,74,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,59,0,0,0,5,5,0,0,5,5,0,0
|
||||
0,57,25,25,25,25,59,7,6,57,78,58,58,58,25,25,25,25,64,61,61,70,61,61,61,61,61,63,86,59,4,4,4,60,61,63,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,43,25,43,25,43,25,59,5,8,9,57,75,74,78,95,78,25,75,59,74,78,57,25,25,25,25,59,0,0,0,5,0,6,0,57,74,25,25,43,43,43,25,25,25,25,64,119,61,61,61,63,85,66,55,55,55,55,55,55,55,56,6,5,0
|
||||
0,57,25,41,41,25,59,5,6,57,75,58,58,58,77,93,25,25,59,5,0,0,0,6,5,6,6,57,37,59,0,0,0,0,0,60,61,61,61,61,61,61,70,61,61,61,61,70,61,61,61,61,70,61,61,63,25,43,25,43,25,43,59,6,6,8,57,76,77,74,25,78,25,25,59,25,75,57,25,25,25,25,59,0,0,0,0,6,0,0,57,25,25,43,43,25,25,43,25,25,25,59,0,0,0,0,57,26,26,26,26,26,26,26,26,26,59,0,5,6
|
||||
0,57,25,25,25,25,59,5,6,57,25,58,25,58,25,25,25,25,59,6,6,7,6,6,6,5,5,57,85,59,5,7,5,0,0,0,0,6,5,0,5,0,0,0,0,7,0,5,0,6,0,5,0,5,6,57,43,25,43,25,43,25,59,7,5,0,57,74,25,25,25,95,25,25,110,25,25,111,25,25,25,25,59,5,0,0,10,5,4,0,57,25,43,43,43,43,43,43,43,25,25,59,0,6,0,0,57,26,26,26,26,26,26,26,26,26,66,56,0,0
|
||||
0,57,25,41,41,25,59,6,6,57,25,25,25,25,25,25,92,77,59,6,6,6,0,5,6,5,6,57,25,59,0,0,0,0,0,0,0,6,0,6,7,6,0,6,0,0,6,0,0,0,0,6,6,0,5,57,25,43,25,43,25,43,66,55,55,55,65,25,25,25,25,25,25,25,25,25,25,25,25,25,25,76,59,7,6,0,9,6,0,0,57,25,43,25,43,43,43,25,43,25,25,59,6,0,5,0,57,26,26,25,25,25,25,25,26,26,78,59,0,5
|
||||
0,57,25,25,25,25,59,6,7,57,73,25,25,25,25,25,25,76,59,5,5,5,5,54,55,55,55,65,84,66,55,55,56,0,0,0,0,54,55,55,55,69,55,55,55,55,69,55,55,55,56,6,6,6,5,57,43,25,43,25,43,25,42,25,37,89,25,25,25,25,25,25,25,25,108,25,25,54,55,55,55,55,55,55,55,56,9,10,5,0,57,25,43,25,43,43,43,25,43,25,25,59,0,6,7,0,57,26,26,25,25,25,25,76,77,77,74,59,5,0
|
||||
0,57,25,41,41,25,59,5,0,60,61,61,70,61,61,63,25,75,66,55,55,56,5,57,74,25,25,25,25,25,25,75,66,56,0,0,0,57,74,25,25,25,25,25,25,25,25,25,25,25,59,5,0,6,0,60,63,43,25,43,25,64,61,61,61,61,63,25,25,25,25,25,25,25,59,25,25,57,25,25,25,37,25,25,25,59,9,8,5,6,57,73,25,25,43,25,43,25,25,25,25,59,6,6,0,5,57,26,26,25,25,25,51,75,73,76,73,59,0,6
|
||||
0,57,25,25,25,25,59,5,5,0,5,6,5,5,6,57,43,43,43,43,43,59,6,57,25,49,42,49,42,49,42,25,75,59,0,0,0,57,25,25,26,26,26,26,26,26,26,26,25,25,66,55,55,55,56,0,60,61,61,61,61,62,0,5,0,0,57,93,46,25,25,25,38,25,114,25,25,115,25,25,64,61,63,25,25,59,8,0,0,5,57,75,73,25,43,25,43,25,25,25,25,59,5,0,6,0,57,26,26,25,25,76,77,77,74,95,75,59,5,5
|
||||
0,57,25,25,25,25,59,0,0,7,5,6,6,5,5,57,43,43,43,43,43,59,5,57,25,42,49,42,49,42,49,25,25,66,97,4,96,65,25,25,26,26,26,26,26,26,26,26,25,25,25,25,25,75,59,5,6,6,5,5,0,0,5,6,10,5,57,25,25,25,25,25,25,25,59,25,25,57,25,25,59,0,57,25,25,66,55,55,55,55,65,73,78,43,43,25,43,43,25,25,64,62,0,5,6,0,57,26,26,25,25,78,44,76,77,77,77,59,6,6
|
||||
0,57,25,25,25,25,59,5,6,0,5,0,5,0,0,57,43,43,43,43,43,59,0,57,25,49,42,49,42,49,42,25,25,43,0,0,0,43,37,25,26,26,26,26,26,26,26,26,25,25,25,26,26,25,66,55,55,55,56,6,6,5,0,0,8,10,57,93,46,25,25,25,38,25,114,25,25,115,25,25,59,0,57,25,25,25,25,25,25,75,73,78,78,25,25,25,25,25,25,25,59,0,0,10,5,54,65,26,26,25,25,71,25,75,77,77,73,59,5,5
|
||||
0,57,25,25,25,25,66,55,55,55,55,69,55,56,0,60,61,61,61,61,61,62,5,57,25,42,49,42,49,42,49,25,76,64,99,0,98,63,25,25,26,26,26,26,26,26,26,26,25,25,25,26,26,25,25,25,25,25,59,0,5,6,5,0,0,6,57,25,25,25,25,25,25,25,59,25,25,57,25,25,59,0,57,25,25,25,25,25,25,25,75,74,75,77,77,73,64,61,61,61,62,0,6,8,0,60,63,26,26,25,25,78,25,25,76,73,78,59,6,0
|
||||
0,57,28,25,25,25,25,25,25,89,25,25,75,59,0,5,5,5,0,5,5,5,0,57,25,25,25,25,25,25,25,76,64,62,0,5,0,60,63,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,59,0,5,0,0,54,55,55,65,93,46,25,25,25,38,25,114,25,25,115,25,25,59,0,57,25,25,25,25,25,25,25,25,25,25,25,25,75,59,0,0,0,0,5,12,6,0,0,57,26,26,25,76,74,25,76,74,75,74,59,5,0
|
||||
5,60,61,70,70,61,61,61,61,63,25,26,25,66,55,56,5,6,6,5,5,5,5,57,25,104,55,64,61,61,61,61,62,0,5,6,6,6,60,61,61,61,61,63,85,64,61,61,61,61,61,61,61,61,63,25,64,61,62,5,6,6,0,60,61,61,63,25,25,25,25,25,25,25,59,25,25,57,25,25,59,0,57,25,25,25,25,25,25,25,25,25,25,25,25,92,59,0,6,1,5,6,6,0,0,0,57,26,26,25,78,94,25,75,77,77,73,59,6,0
|
||||
5,10,6,5,6,10,5,6,5,57,73,25,25,25,25,59,5,5,6,5,6,6,5,57,25,25,25,59,5,0,5,5,6,5,7,5,10,0,6,6,6,5,0,57,25,59,0,0,6,5,5,0,5,5,57,25,59,0,0,0,5,6,6,0,6,0,57,93,46,25,25,25,38,25,114,25,25,115,25,25,59,0,57,25,25,25,25,25,25,25,25,25,25,25,25,25,59,0,0,0,0,5,0,54,55,55,65,26,26,25,58,58,58,25,26,81,78,59,5,5
|
||||
0,8,2,5,10,9,6,6,5,60,61,70,61,63,25,59,0,5,5,5,10,5,5,57,55,105,25,59,5,6,6,12,5,6,6,10,9,6,6,7,6,5,0,57,25,59,0,5,7,6,0,6,6,0,57,42,59,5,5,5,0,0,0,6,6,6,57,25,25,25,25,25,25,25,59,25,25,57,25,25,59,0,57,25,25,25,25,25,25,25,25,25,25,25,25,25,66,55,55,56,0,6,0,60,61,61,63,26,26,25,58,58,58,25,26,26,75,59,0,0
|
||||
0,0,0,5,8,9,6,0,6,6,5,5,0,57,25,66,55,55,55,56,8,10,6,57,25,25,25,59,0,7,6,6,5,5,5,9,9,10,5,6,5,6,0,57,25,59,5,6,5,6,5,0,5,0,57,25,59,0,5,7,0,0,6,6,6,5,60,63,25,25,25,25,25,25,59,25,25,111,25,25,59,0,57,25,25,25,25,25,25,25,25,25,25,25,25,25,64,61,61,62,5,0,6,0,0,0,57,26,26,25,58,25,58,25,26,26,92,59,5,0
|
||||
0,0,6,6,0,8,0,6,0,10,0,6,5,57,25,25,25,25,75,59,6,9,5,57,25,104,55,59,5,6,6,10,5,5,11,8,8,8,5,0,5,0,5,57,25,59,0,5,6,0,6,7,5,6,57,25,59,5,6,0,0,5,6,0,5,0,0,57,73,25,25,25,25,25,59,25,25,25,25,25,59,0,57,25,25,25,25,25,25,25,25,25,25,25,25,25,59,0,0,0,5,5,6,0,54,55,65,26,26,25,25,37,46,25,26,26,64,62,5,6
|
||||
0,0,0,6,0,0,6,0,0,8,0,0,6,60,61,63,25,26,25,59,5,8,6,57,25,25,25,59,6,6,10,9,6,5,6,6,5,5,0,54,55,55,55,65,25,66,55,55,55,56,6,0,5,0,57,25,59,0,5,5,0,6,5,0,5,6,5,60,61,61,61,61,61,61,61,61,61,61,61,61,62,0,57,25,25,25,25,25,25,25,25,25,25,25,25,25,59,0,10,6,6,0,0,0,60,61,63,26,26,25,25,25,25,25,26,26,59,0,0,6
|
||||
0,6,0,6,7,0,0,6,6,5,0,7,0,6,6,57,73,25,25,66,56,5,0,57,55,105,25,59,5,7,8,9,5,5,7,6,6,6,6,57,74,25,25,25,25,25,25,25,75,59,0,6,6,5,57,25,59,0,0,0,0,0,0,0,0,0,6,0,5,6,6,6,5,5,0,0,0,0,0,0,0,0,57,25,25,25,25,25,25,25,25,25,25,25,25,25,59,0,9,5,0,7,0,0,0,0,60,63,26,26,26,26,26,26,26,26,59,0,5,5
|
||||
0,6,0,0,0,0,6,0,0,6,0,0,0,10,5,60,61,63,25,25,59,0,7,57,25,25,25,59,0,0,5,8,5,0,5,5,5,0,5,57,93,25,25,25,25,25,25,25,25,59,0,5,10,5,57,25,59,5,10,0,5,0,0,0,5,0,6,5,0,6,0,6,6,0,5,0,0,0,0,0,0,0,60,63,26,26,26,26,26,26,26,26,26,26,26,64,62,6,8,10,0,0,6,0,6,0,0,57,26,26,26,26,26,26,26,26,59,0,6,0
|
||||
0,0,6,6,0,0,0,0,6,5,5,0,0,9,10,5,6,60,63,25,59,6,5,57,25,104,55,66,55,55,55,55,55,55,55,55,55,56,6,57,77,73,25,25,25,25,25,25,25,59,6,6,8,5,57,42,59,6,9,0,0,0,7,0,6,0,0,0,6,0,0,6,0,0,6,6,0,0,0,0,0,0,0,57,26,26,26,26,26,26,26,26,26,26,26,59,0,5,0,8,6,6,0,0,0,6,0,60,61,61,61,61,61,61,61,61,62,0,5,5
|
||||
0,6,0,5,0,6,6,6,6,5,6,0,5,9,9,0,0,5,57,25,59,0,6,57,25,25,25,25,26,26,26,26,26,26,26,26,26,59,5,57,25,78,25,25,25,25,25,25,25,59,6,0,6,0,57,25,59,5,8,5,0,0,0,0,0,0,5,0,5,5,0,0,7,0,0,6,0,0,0,0,0,0,0,60,61,61,61,61,61,61,61,61,61,61,61,62,0,5,5,6,5,6,5,0,0,5,0,0,0,6,0,0,6,0,0,6,0,0,0,0
|
||||
0,0,6,6,0,2,0,5,0,5,5,5,0,9,9,7,0,6,57,25,59,0,6,57,55,55,55,105,26,26,26,26,26,26,26,26,26,59,6,57,25,78,26,25,25,25,25,25,25,66,55,69,55,55,65,25,59,5,0,0,5,5,0,54,55,55,55,56,0,0,5,0,0,0,5,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,6,6,6,0,0,0,5,6,0,0,0,0,0,0,0,0,5,0,4,0,0
|
||||
6,0,6,6,0,7,0,5,6,6,5,0,7,9,8,0,5,5,57,25,59,0,5,57,25,25,25,25,108,26,26,26,26,26,26,26,26,59,5,57,77,74,25,25,25,25,25,25,25,25,29,25,25,25,88,25,59,6,0,0,0,6,0,57,25,25,25,59,0,0,0,0,0,10,0,0,0,0,0,5,7,0,0,0,7,0,0,5,0,0,0,7,0,0,0,6,0,0,0,5,0,0,5,0,6,6,0,5,5,6,0,0,5,5,5,5,0,0,0,0
|
||||
0,0,6,0,0,6,0,0,0,5,0,5,0,8,0,6,10,0,57,25,59,5,5,57,25,26,46,25,59,26,26,26,26,26,26,26,26,59,6,57,25,25,25,25,25,25,25,25,25,64,61,61,61,61,63,25,59,5,7,0,0,0,0,57,25,25,25,59,0,0,0,0,10,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,5,0,0,0,0,0,0,0,0,6,0,0,0,6,0,6,6,7,6,6,6,6,5,0,0,0,0,0
|
||||
0,6,0,6,6,0,54,55,55,55,55,69,55,55,56,0,9,5,57,25,59,0,0,57,25,25,25,25,59,26,26,26,26,26,26,26,26,59,6,57,73,25,25,25,25,25,25,25,76,59,0,0,0,5,57,25,59,5,0,0,6,54,55,65,25,25,25,66,55,56,0,0,9,8,10,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0,0,0,5,5,0,0,0,7,0,0,0,5,0,0,0,0,0,0,6,5,0,6,6,6,6,0,0,0,0,0
|
||||
6,6,6,5,0,0,57,42,42,25,25,25,95,78,66,56,8,6,57,25,59,5,5,60,61,61,61,61,61,61,61,61,70,61,61,61,61,62,5,60,61,61,61,63,86,64,61,61,61,62,0,5,0,0,60,61,62,6,5,0,0,57,25,25,25,25,25,25,25,59,0,5,8,0,8,0,0,0,0,0,0,5,0,0,0,5,6,6,5,5,0,0,5,0,5,0,0,0,0,0,6,0,0,5,0,0,0,0,0,6,10,6,0,6,0,6,0,0,0,0
|
||||
0,6,6,0,10,6,57,42,42,25,25,25,25,75,74,59,5,6,57,25,59,0,6,5,0,5,6,5,5,6,5,6,6,5,6,6,5,5,6,5,6,5,0,57,37,59,0,0,0,0,5,5,5,0,0,0,5,5,0,54,55,65,25,108,25,64,61,63,25,59,0,0,0,0,0,54,55,97,0,5,0,6,0,0,96,55,55,55,55,55,55,55,56,0,5,0,6,5,0,0,0,0,6,0,7,0,0,6,6,0,6,6,6,6,0,6,0,0,0,0
|
||||
0,0,0,0,8,0,57,42,42,25,25,25,25,25,25,66,55,55,65,25,66,55,55,69,55,55,55,55,55,55,55,55,55,55,69,55,55,55,55,55,55,55,55,65,25,66,55,55,55,69,55,55,55,55,55,69,55,55,55,65,25,25,25,110,25,66,55,65,25,66,55,55,55,55,55,65,25,43,0,6,0,0,0,0,43,25,25,25,25,25,25,42,59,0,0,5,5,6,5,0,5,0,6,0,0,6,0,6,0,6,0,0,6,0,0,6,0,0,0,0
|
||||
0,7,0,6,0,0,57,42,42,25,25,25,25,25,37,88,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,37,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,43,0,5,5,5,0,0,43,25,25,25,26,25,25,42,59,0,0,6,10,5,6,6,0,0,0,0,6,0,6,0,6,6,0,0,6,0,6,0,6,0,0,0
|
||||
0,6,0,0,5,0,57,42,42,54,55,55,56,25,25,64,61,61,61,70,61,61,61,61,61,61,61,70,61,70,61,61,61,61,61,61,61,61,61,61,70,61,61,61,61,63,64,61,61,70,61,70,61,61,63,86,64,61,61,61,61,61,61,63,25,106,61,61,107,25,108,25,64,61,61,63,25,43,0,0,5,5,0,0,43,25,25,25,25,25,25,71,59,0,0,0,0,0,0,0,0,0,0,0,6,0,0,6,6,0,0,0,6,0,7,6,0,0,0,0
|
||||
0,0,6,6,6,6,57,58,58,57,5,6,59,25,25,59,5,10,0,5,6,6,0,5,6,5,0,5,0,6,5,5,6,6,5,5,0,5,6,6,5,6,7,5,6,57,59,64,61,61,70,61,61,63,57,25,59,5,6,5,5,0,0,57,25,25,25,25,25,25,59,61,62,0,0,60,61,99,0,0,6,5,0,0,98,61,61,61,61,61,61,61,62,0,0,0,0,0,0,6,0,0,6,0,6,6,6,0,0,0,0,0,6,6,0,6,6,0,0,0
|
||||
0,6,6,0,0,0,57,42,42,57,6,5,59,25,25,59,10,8,5,6,0,5,0,7,0,6,0,54,55,55,55,69,55,55,55,55,69,55,55,55,69,55,55,55,69,65,59,59,64,61,61,61,63,57,57,25,59,5,5,0,0,0,0,60,61,61,61,61,61,61,62,0,0,0,0,0,0,0,5,5,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,5,0,0,7,0,0,6,6,0,0,0,10,6,6,0,0,0,6,6,6,0,0,0,6,0
|
||||
0,5,6,6,7,0,57,58,58,57,10,5,59,25,25,59,8,6,7,5,0,6,11,0,5,0,10,57,76,77,77,77,77,74,78,75,73,78,78,78,25,47,71,47,25,75,59,59,59,64,70,63,57,57,67,25,59,5,5,7,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,9,10,0,0,0,6,5,0,0,0,0,6,5,0,6,6,6,6,0,0,0,0,0,6,0,0,0,0,0,6,6,0,0,0,6,0,0
|
||||
0,6,0,0,6,0,57,42,42,57,8,6,59,25,25,59,54,55,55,55,55,56,6,0,6,0,8,57,78,50,51,25,25,25,95,25,75,74,78,95,25,25,25,25,25,25,59,68,59,59,58,57,57,57,57,25,59,6,0,5,0,0,0,0,0,6,6,0,0,0,0,0,0,0,5,0,0,7,0,5,5,0,10,9,8,0,0,0,0,0,0,0,0,5,0,0,0,6,6,6,0,0,0,0,0,6,6,6,6,0,6,6,0,0,0,0,6,10,0,0
|
||||
6,0,96,55,55,55,65,42,42,60,61,61,62,25,25,66,65,25,25,25,25,59,0,6,0,0,0,57,78,51,44,25,25,25,25,25,76,77,74,25,25,25,25,25,25,25,59,59,68,59,58,57,67,57,57,25,68,5,5,0,7,5,6,6,6,6,0,0,0,5,5,5,0,0,5,5,0,5,0,0,0,0,8,9,7,0,0,6,6,0,0,5,0,6,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,6,6,6,6,6,6,6,0,0,0,0
|
||||
0,101,29,25,25,25,25,42,42,25,25,25,25,25,25,25,49,25,25,25,25,59,6,0,0,7,0,57,78,25,25,25,25,25,25,25,78,45,25,25,25,25,25,25,25,25,59,68,59,59,58,57,57,57,57,25,59,6,10,5,0,0,6,0,6,0,6,5,5,5,0,0,0,5,5,6,6,0,5,5,5,5,0,8,0,0,5,6,6,5,6,5,6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,6,7,6,6,0,0,0,0,0,0
|
||||
0,60,63,25,25,25,25,42,42,25,25,25,25,25,25,106,61,61,61,61,61,62,0,5,0,6,0,57,75,77,77,77,77,77,77,77,74,25,25,25,25,25,25,25,25,25,59,59,59,66,69,65,57,57,67,25,59,5,9,0,0,0,0,6,6,5,5,0,0,0,5,5,7,0,0,6,5,5,6,5,0,0,0,0,6,5,5,6,5,5,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,0,0,6,0,6,0,0,6,0,0,0,0,0,0
|
||||
7,0,60,61,61,61,61,61,61,61,63,25,25,25,38,25,43,0,5,0,5,6,0,0,4,0,6,116,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,117,59,66,55,55,55,65,57,57,25,59,10,8,5,5,5,5,5,5,0,0,5,5,6,5,0,0,5,0,5,6,6,5,0,0,0,0,0,0,0,0,0,0,0,25,64,63,25,25,25,64,63,25,64,61,61,61,61,63,25,0,0,6,0,6,0,0,6,6,0,0,0,0,0
|
||||
0,6,6,0,10,6,5,6,5,0,57,25,25,25,25,104,55,55,55,55,55,56,5,6,6,0,0,57,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,59,66,55,55,69,55,55,65,57,25,59,8,7,5,0,0,6,0,6,6,5,6,5,5,0,0,0,0,0,6,0,0,0,0,0,0,0,5,7,0,5,0,0,0,25,59,57,25,25,25,59,57,25,66,55,56,54,55,65,25,0,0,0,6,6,6,6,0,0,6,6,0,0,0
|
||||
6,6,5,6,8,5,6,0,7,5,57,25,25,25,25,25,25,25,25,25,25,59,7,6,6,5,0,67,25,25,25,25,25,25,25,25,25,25,25,25,76,77,77,77,73,25,66,55,55,69,55,69,55,55,65,25,59,7,7,5,6,6,6,6,0,5,5,5,6,0,5,0,0,0,0,0,6,5,0,0,0,0,5,0,0,0,0,0,7,0,25,59,60,61,61,61,62,57,25,25,25,59,57,25,25,25,0,0,0,10,0,6,0,6,0,0,0,6,6,0
|
||||
5,54,55,55,55,55,69,55,55,55,65,84,64,61,61,61,63,25,25,25,25,66,55,56,0,6,0,57,25,25,25,25,25,25,25,25,25,25,25,25,78,43,25,43,78,25,25,37,88,25,25,25,25,25,25,25,59,5,7,7,0,6,0,6,5,5,5,6,0,0,7,5,0,0,6,5,5,0,0,0,0,0,0,6,0,0,6,6,5,0,25,59,54,55,55,55,56,57,25,25,25,59,57,25,25,25,0,0,0,0,6,6,6,0,6,0,0,0,6,0
|
||||
6,57,75,77,73,95,26,78,26,25,25,25,59,10,5,0,57,93,25,25,25,25,75,66,56,0,6,57,25,25,81,46,25,25,25,25,25,25,25,25,78,25,43,25,78,25,64,61,61,61,61,70,61,61,63,25,59,0,5,0,0,0,6,5,5,6,0,0,0,5,5,0,0,5,5,0,6,0,6,0,0,6,0,0,0,0,0,0,0,0,25,59,57,25,25,25,59,57,25,25,25,59,57,25,25,25,0,0,0,0,6,6,0,0,0,7,6,0,6,0
|
||||
5,57,77,77,74,25,25,95,25,25,25,25,59,9,10,5,57,77,73,25,40,25,25,92,59,0,6,57,25,25,78,25,25,25,25,25,25,25,76,73,78,43,25,43,78,25,59,0,5,6,5,6,6,0,57,25,59,6,6,5,0,6,0,7,6,0,0,0,5,5,0,5,5,5,0,0,7,6,6,6,0,0,0,0,0,6,0,0,0,0,25,59,57,25,37,25,59,57,25,25,25,59,57,25,25,25,0,0,0,6,6,0,6,0,0,0,0,0,6,0
|
||||
5,57,73,76,77,73,25,25,25,25,25,25,59,9,8,6,57,76,74,108,40,109,25,76,59,5,6,67,93,25,75,77,77,73,25,76,77,77,74,78,78,25,43,25,78,25,66,55,124,56,6,0,0,5,67,25,59,5,5,5,5,0,6,6,0,0,5,5,5,0,6,5,6,0,0,6,0,0,6,0,0,0,10,0,0,0,6,0,0,0,25,59,57,25,25,25,59,57,25,64,61,62,60,61,63,25,0,0,0,6,6,6,0,0,0,0,0,0,6,0
|
||||
7,57,75,74,71,78,46,25,25,25,25,25,59,8,10,5,57,74,108,59,25,57,109,75,59,0,0,57,25,25,25,25,25,78,25,78,28,76,73,75,74,43,25,43,78,25,26,26,125,59,0,0,6,0,57,25,59,0,6,5,0,0,6,6,6,5,5,6,0,0,5,0,6,0,0,0,5,6,6,6,0,6,0,6,0,0,0,5,0,0,25,66,65,25,41,25,66,65,25,66,55,55,55,55,65,25,0,0,6,0,0,6,6,0,0,0,0,6,6,0
|
||||
6,57,77,73,25,75,77,73,25,25,25,25,59,6,7,5,57,108,59,59,37,57,57,109,59,6,6,57,25,43,43,43,25,78,25,78,25,71,75,77,73,25,43,25,78,25,26,26,26,59,0,0,0,6,57,25,68,6,6,5,5,6,6,5,5,6,6,0,5,5,6,0,0,0,5,5,0,6,0,0,0,0,0,0,0,6,0,6,6,0,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,0,0,0,0,0,6,6,0,0,0,10,0,6,0
|
||||
7,57,93,78,25,25,25,78,25,64,63,25,59,5,5,5,57,59,59,59,25,57,57,57,59,6,0,57,25,43,27,43,25,78,47,78,25,46,25,25,78,43,25,43,78,25,64,61,61,62,0,5,0,0,57,25,59,5,0,5,5,0,0,6,6,0,7,5,0,0,0,6,0,5,0,0,0,0,0,0,0,0,6,6,6,0,0,5,6,0,25,42,42,42,42,42,42,42,42,42,42,58,42,42,42,25,0,0,0,6,6,6,0,0,0,0,0,6,6,0
|
||||
6,57,26,75,77,73,25,90,25,59,57,36,59,0,12,6,57,110,110,66,55,65,111,111,59,10,0,67,25,43,43,43,25,78,47,78,25,25,25,25,78,25,43,25,78,25,59,0,0,6,0,0,5,6,67,25,59,0,10,0,0,0,0,0,0,0,5,0,0,5,5,0,6,7,0,0,5,5,5,0,5,6,6,5,0,0,0,0,0,5,25,42,42,42,42,42,58,58,58,58,58,58,58,42,42,25,0,0,0,7,6,6,0,0,0,0,0,0,0,0
|
||||
5,57,25,25,25,75,77,74,25,59,57,36,59,0,6,5,57,73,25,25,25,25,25,76,59,9,0,57,25,43,27,43,25,78,47,78,25,25,25,25,78,43,25,43,78,25,59,5,11,0,0,7,0,0,57,25,59,10,9,5,0,5,0,0,6,0,0,5,0,5,0,0,0,0,5,5,5,5,5,0,0,6,0,0,0,0,0,0,0,0,25,42,42,42,42,42,58,58,58,58,58,58,42,42,42,25,0,0,6,0,6,6,0,0,0,0,0,0,0,0
|
||||
6,57,25,81,25,25,25,25,25,59,57,36,59,0,5,5,57,74,25,25,25,94,25,75,59,8,6,57,25,43,43,43,25,75,77,74,25,25,25,25,75,77,73,76,74,25,59,6,5,0,6,5,6,5,57,38,59,8,8,10,5,5,6,0,0,6,0,6,0,0,0,5,5,5,6,0,0,6,6,5,5,5,0,6,7,0,0,0,0,0,25,42,43,25,25,25,25,58,58,25,58,58,42,42,42,25,0,0,6,0,0,6,0,0,0,6,0,0,0,0
|
||||
6,57,25,25,25,25,25,25,25,59,57,36,59,5,0,6,57,76,73,25,25,75,77,73,59,0,0,57,25,25,25,25,25,25,25,25,25,25,25,25,25,25,78,78,25,25,66,55,55,55,55,55,55,55,65,25,59,5,5,8,0,2,0,6,6,6,6,0,0,5,6,5,5,6,0,5,6,6,0,5,5,0,6,5,5,5,6,6,0,0,25,42,25,25,25,25,25,43,58,58,58,58,42,42,42,25,0,0,0,6,6,6,6,0,0,6,0,6,0,0
|
||||
5,60,61,61,63,86,64,61,61,62,60,61,62,5,5,7,57,74,81,73,25,25,25,78,59,6,5,60,63,25,64,61,70,61,61,61,61,70,61,61,61,61,70,61,61,63,74,78,25,25,49,49,49,25,88,25,59,6,0,0,5,0,0,6,0,6,5,0,6,5,5,5,5,0,5,7,0,0,0,6,6,6,6,0,5,0,5,0,0,0,25,42,25,25,25,25,25,25,25,58,58,58,42,42,42,25,0,0,0,6,6,6,6,6,0,6,7,6,0,0
|
||||
6,6,5,5,57,37,59,10,5,6,5,7,5,6,5,0,57,77,74,95,25,25,25,78,59,0,0,0,57,25,59,0,0,0,0,5,0,5,0,0,0,0,0,0,0,57,77,74,25,64,61,61,61,61,63,58,59,5,7,5,5,0,0,6,6,6,6,5,5,5,6,5,0,0,0,0,6,0,5,5,5,0,0,0,0,0,6,6,5,0,25,42,25,42,42,42,58,58,58,58,58,58,42,42,42,25,0,0,0,6,0,6,6,0,6,0,0,6,0,0
|
||||
6,54,55,55,65,25,66,55,55,69,55,55,55,56,0,5,57,73,25,25,25,25,94,75,59,6,7,0,57,85,59,0,5,0,5,6,0,6,5,54,55,55,55,55,55,65,46,25,25,59,0,0,5,0,57,25,59,6,0,5,5,0,0,0,0,6,6,5,7,6,5,0,0,0,5,5,0,5,7,0,0,0,10,5,0,6,5,6,0,0,25,42,42,42,42,42,58,58,58,58,58,58,42,42,42,25,0,0,0,0,6,10,6,0,6,6,0,6,0,0
|
||||
6,57,36,59,25,25,25,25,25,26,26,26,26,59,5,5,57,55,55,105,25,104,55,55,59,0,0,0,57,37,59,0,6,0,7,0,6,0,6,57,81,25,25,25,25,25,25,25,76,59,0,5,6,5,57,25,59,5,5,5,0,0,0,0,6,0,0,6,6,0,0,5,5,10,0,0,5,0,0,6,5,5,5,0,0,0,0,0,5,0,25,42,42,42,42,42,58,58,58,58,58,58,58,42,42,25,0,0,0,6,0,0,0,0,6,6,6,0,0,0
|
||||
7,57,36,114,25,39,39,25,25,26,26,72,72,59,5,6,57,43,43,43,43,43,43,43,59,0,6,5,57,25,59,5,5,10,0,5,0,5,5,57,28,25,25,94,25,94,25,64,61,62,5,5,6,5,57,25,59,0,5,0,0,5,0,6,6,6,6,6,0,0,0,0,6,6,0,0,0,5,5,5,5,5,0,0,0,5,5,0,7,0,25,42,11,42,42,42,42,42,58,42,58,42,42,42,42,25,0,0,0,6,0,0,6,6,6,0,0,0,0,0
|
||||
5,57,36,114,25,39,39,25,25,26,26,72,26,59,5,6,57,43,43,43,43,43,43,43,59,0,6,0,57,25,59,6,6,8,6,0,6,0,0,60,61,61,61,61,61,61,61,62,5,7,7,0,6,5,57,25,68,6,5,5,0,0,6,6,0,0,6,0,0,0,6,6,6,6,0,5,5,6,5,5,5,5,0,0,5,0,0,0,0,0,25,42,42,42,42,42,42,42,42,42,42,42,42,42,42,25,0,0,6,6,0,6,6,6,0,0,0,0,0,0
|
||||
6,57,36,59,25,25,25,25,25,26,72,72,26,59,6,5,57,43,43,43,43,43,43,43,59,5,0,0,57,25,59,5,6,5,5,6,5,5,5,5,6,5,5,6,5,0,0,5,5,6,7,5,5,0,57,25,59,6,0,5,0,7,0,0,0,6,0,0,6,6,0,6,0,0,0,0,0,0,5,0,0,0,0,0,0,0,6,0,0,0,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,0,0,6,0,0,6,0,6,6,6,6,0,0,0
|
||||
6,57,36,59,25,25,25,25,25,26,26,26,26,59,5,0,60,63,43,43,43,43,43,64,62,0,0,54,65,25,66,55,69,55,55,55,55,69,55,55,55,55,69,55,55,55,55,69,55,55,55,55,69,55,65,25,59,0,5,0,7,0,0,0,6,6,6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,7,6,6,0,0,6,6,6,0,0
|
||||
5,60,61,61,70,61,61,99,98,61,70,61,61,62,6,5,5,60,61,61,61,61,61,62,0,0,5,57,29,25,25,25,25,28,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,43,59,6,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,0,0,6,6,0,0,0,6,0,6,6,6,6,0,0,0,0,6,6,0,6,0,0,0,0,0,6,0,0
|
||||
5,5,6,6,5,6,5,5,6,7,5,6,5,6,6,5,6,5,0,5,0,0,0,5,0,0,0,60,61,70,61,61,61,61,61,70,61,61,61,61,61,61,61,61,61,61,61,61,61,70,61,70,61,70,61,61,62,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,6,6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,6,0,0,0,0,0,0,0,0,0,0,0,0
|
|
160
Tests/assets/maps/catastrophi_level3.csv
Normal file
|
@ -0,0 +1,160 @@
|
|||
17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,17,13,13,13,13,13,17,13,13,13,13,13,13,13,13,14,17,13,13,13,17,17,13,13,13,13,13,13,13,13,17,17,13,13,13,13,13,13,13,13,13,13,13,13,13,16,13,13,13,13,13,16,13,13,13,13,13,13,13,16,13,13,13,17,17,13,13,13,13,13,13
|
||||
13,13,13,13,13,13,13,16,13,13,13,13,13,13,16,13,13,13,13,13,14,13,13,17,13,13,13,13,17,16,13,13,13,13,17,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,13,13,13,13,17,13,13,13,13,14,13,13,13,13,17,13,13,13,13,14,13,13,13,15,13,13,13,13,14,13,13,16,13,13,13,13,13,16,13,16,13,13,14,13,16,13,13
|
||||
13,13,13,13,17,13,13,13,13,13,16,13,13,17,13,13,17,13,13,13,17,13,13,13,13,16,13,13,13,13,17,13,13,13,13,13,13,14,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,17,13,54,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,56,13,13,13,13,13,13,13,13,13,13,13,13
|
||||
13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,17,14,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,17,13,13,13,13,17,16,13,13,13,17,13,13,13,13,17,16,13,57,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,59,13,13,13,13,13,13,17,13,13,13,13,17
|
||||
13,13,17,14,13,13,13,13,17,17,13,13,13,13,13,13,13,13,17,13,17,17,13,13,13,13,14,17,13,13,13,13,14,13,13,13,17,13,13,13,13,17,16,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,16,13,13,13,13,13,57,25,64,61,61,61,61,61,61,61,61,61,61,61,61,61,63,25,59,13,17,13,13,16,13,13,13,16,13,16,13
|
||||
13,13,17,13,13,13,13,13,17,13,13,13,13,17,17,13,13,13,17,13,17,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,16,13,13,13,13,13,13,13,17,17,13,13,13,13,13,13,13,13,13,13,13,17,14,13,13,13,13,13,13,14,13,57,25,59,13,17,13,16,13,13,13,13,13,13,13,13,13,57,25,59,17,17,13,13,17,14,13,13,13,13,13,13
|
||||
17,13,13,13,13,13,13,17,16,14,17,13,17,17,13,17,13,13,13,13,13,17,13,16,13,13,13,13,13,13,13,17,13,13,17,14,13,13,13,13,13,13,13,13,17,13,13,13,13,14,13,13,13,13,17,17,13,13,13,17,13,13,13,13,14,17,13,13,13,57,25,59,13,13,15,13,13,13,17,15,14,13,17,15,13,67,25,59,13,13,13,14,17,13,13,13,13,14,17,13
|
||||
13,13,17,13,16,13,13,13,13,13,13,13,13,13,13,13,17,13,14,13,13,13,13,13,17,13,13,13,13,13,13,13,13,16,17,13,13,13,13,14,17,13,13,13,17,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,17,13,13,13,13,13,13,57,25,59,13,13,13,16,13,13,13,13,13,16,13,16,13,57,25,59,13,13,13,13,13,13,13,17,13,13,13,13
|
||||
13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,17,17,13,13,13,13,13,13,13,13,13,13,17,14,13,13,13,13,13,13,17,13,13,13,13,13,17,16,13,13,13,17,13,13,13,13,17,16,13,13,13,13,17,13,16,13,13,13,13,13,13,14,57,25,59,16,13,17,13,13,17,13,13,17,13,15,13,13,57,25,59,13,13,17,13,17,13,16,13,13,13,13,13
|
||||
13,17,13,13,13,14,17,13,13,13,13,14,13,15,17,13,13,13,17,13,17,13,13,13,13,17,13,13,13,17,13,13,13,13,17,13,16,13,13,13,13,13,13,13,13,13,13,13,13,13,16,13,13,13,13,13,13,13,13,13,13,13,17,13,13,14,13,13,13,57,86,59,13,13,13,15,14,13,13,16,13,13,13,14,16,57,25,68,13,13,13,13,13,13,13,17,13,13,13,13
|
||||
13,13,13,13,13,13,13,13,13,13,13,13,13,15,13,54,69,55,55,55,55,55,55,55,69,55,55,56,13,13,13,13,17,13,13,13,13,17,13,13,13,13,13,13,13,13,17,14,13,13,13,13,13,13,13,13,54,55,55,55,55,55,55,55,55,55,55,55,55,65,26,66,55,55,55,55,55,55,55,55,55,55,56,13,17,57,25,59,17,14,13,13,13,13,13,13,13,13,13,13
|
||||
13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,57,73,78,75,73,78,78,95,79,30,78,75,59,13,17,13,16,13,13,13,13,13,13,13,13,13,14,17,13,13,13,17,13,13,13,13,14,17,13,13,13,57,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,59,13,13,57,25,59,17,13,13,13,13,14,17,13,13,13,13,13
|
||||
14,13,13,13,13,17,13,13,13,13,13,13,13,13,13,57,75,74,76,74,78,75,73,25,25,95,26,66,56,13,13,13,17,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,54,65,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,66,56,13,57,25,59,13,13,13,17,13,13,13,13,13,13,13,13
|
||||
13,13,13,13,13,17,13,17,14,13,13,13,13,13,13,57,93,76,83,81,74,26,81,25,25,25,25,25,59,13,13,13,13,13,13,13,17,13,16,13,13,13,13,13,13,13,17,13,16,13,13,13,13,13,13,57,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,26,26,59,13,67,25,59,17,13,13,13,13,13,13,13,13,13,13,13
|
||||
13,13,13,13,17,16,13,17,13,13,13,18,19,13,17,57,76,74,25,25,25,25,25,25,25,25,25,25,59,13,13,13,13,13,13,13,13,13,13,17,13,13,13,14,13,13,13,13,13,17,13,15,13,13,13,57,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,26,26,59,13,57,25,59,13,13,0,0,0,0,13,13,13,13,13,13
|
||||
13,16,13,13,13,13,13,13,13,13,13,20,21,13,13,57,78,25,47,25,25,25,47,25,25,25,25,25,66,55,55,55,55,69,55,69,55,55,55,55,55,55,55,55,55,55,55,56,13,13,13,16,13,16,13,67,26,26,27,27,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,27,27,26,26,68,17,57,25,59,13,13,43,43,43,43,13,13,17,13,13,13
|
||||
13,13,13,13,13,13,13,17,13,16,13,13,13,13,13,57,74,25,25,25,25,25,25,25,25,25,25,25,25,25,25,47,47,25,25,25,25,25,25,25,25,25,25,25,25,25,25,59,13,16,13,13,17,13,13,67,26,26,27,27,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,27,27,26,26,68,13,57,25,59,13,57,25,25,25,25,59,17,17,13,13,13
|
||||
13,13,14,17,13,13,13,13,13,13,54,55,124,124,55,65,25,25,25,25,25,25,25,25,25,25,25,25,64,61,61,61,61,61,61,61,61,61,61,70,61,61,61,61,63,25,64,62,13,13,13,13,13,14,13,57,26,26,27,27,25,25,25,25,25,25,25,25,64,61,63,25,25,25,25,25,25,25,25,27,27,26,26,59,14,57,25,59,13,57,25,41,41,25,59,13,13,13,14,13
|
||||
17,13,13,13,13,13,17,13,13,13,57,74,125,125,95,25,25,25,25,25,25,25,25,25,25,25,25,25,59,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,57,25,59,13,13,17,13,16,13,13,13,57,26,26,27,27,25,25,25,25,25,25,25,25,59,13,57,25,25,25,25,25,25,25,25,27,27,26,26,59,13,57,25,68,17,57,25,25,25,25,59,13,13,13,13,13
|
||||
13,13,13,13,13,13,13,13,17,13,57,73,25,46,25,25,25,25,25,25,37,25,58,58,58,25,25,25,59,13,13,13,17,13,13,13,13,17,13,13,13,13,17,13,57,25,59,13,13,13,13,13,17,13,13,57,26,26,27,27,25,25,25,25,25,25,25,25,66,55,65,25,25,25,25,25,25,25,25,27,27,26,26,59,17,57,25,59,14,57,25,25,25,25,59,13,13,17,13,13
|
||||
17,13,13,13,13,13,13,13,13,13,57,78,25,25,25,25,25,25,25,25,25,25,58,58,58,25,25,28,59,13,13,17,16,14,17,13,17,17,14,17,13,17,17,13,57,25,59,13,16,13,13,13,13,16,13,57,26,26,27,27,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,27,27,26,26,59,13,57,25,59,17,57,25,41,41,25,59,13,13,13,13,16
|
||||
13,13,13,13,13,13,13,13,16,13,60,63,25,25,25,25,25,25,25,25,25,25,58,58,58,25,25,64,62,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,57,25,68,13,13,13,13,13,15,13,13,67,26,26,27,27,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,27,27,26,26,59,13,57,25,59,13,67,25,25,25,25,68,17,14,13,13,13
|
||||
13,13,13,13,13,17,13,13,13,13,13,57,29,25,25,25,25,25,25,25,25,25,25,25,25,25,25,59,13,13,13,13,13,17,13,13,13,13,17,13,13,13,13,13,57,25,59,13,13,13,17,13,13,13,13,67,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,26,26,59,13,67,25,59,17,57,25,25,25,25,59,17,13,13,13,13
|
||||
13,13,13,13,13,13,13,13,13,13,13,60,61,61,70,61,61,61,61,70,61,61,61,61,70,61,61,62,13,13,17,13,13,13,13,14,13,17,13,13,14,13,13,13,57,25,59,13,15,13,13,13,13,17,13,57,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,26,26,59,13,57,25,59,17,57,25,41,41,25,59,13,13,13,17,13
|
||||
13,13,13,17,14,13,13,13,13,17,17,13,13,13,13,13,13,13,13,17,13,17,13,17,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,67,25,59,13,13,13,13,13,16,13,13,60,63,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,64,62,13,57,25,59,13,57,25,25,25,25,59,17,13,16,13,13
|
||||
13,13,13,17,13,13,13,13,13,17,13,13,13,13,17,17,13,13,13,17,13,17,17,17,13,17,13,13,13,13,13,13,13,13,17,13,13,13,13,17,15,13,13,13,57,25,59,13,13,13,13,13,16,13,13,13,57,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,59,13,13,57,25,59,13,67,25,25,25,25,68,13,13,13,17,13
|
||||
13,17,13,13,13,13,13,13,17,16,14,17,13,17,17,13,17,13,13,13,13,13,13,13,13,13,17,13,17,13,13,13,17,13,16,15,13,13,13,13,13,13,13,13,57,25,59,13,14,16,13,13,13,13,16,13,60,61,61,61,61,61,61,61,61,61,61,61,63,84,64,61,61,61,61,61,61,61,61,61,61,61,62,14,13,57,25,59,13,67,25,41,41,25,68,13,13,13,13,13
|
||||
13,13,13,17,13,16,13,13,13,13,13,13,13,13,13,13,13,17,13,14,13,13,13,13,13,13,13,17,13,13,13,17,17,13,13,13,13,13,13,13,13,13,13,13,57,25,68,13,13,13,13,17,14,13,13,13,13,13,13,13,16,13,13,13,13,13,13,13,57,35,59,13,13,13,17,13,13,13,13,17,13,13,13,13,13,57,25,68,13,57,25,25,25,25,59,13,13,13,13,13
|
||||
13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,17,17,13,13,13,13,17,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,16,13,13,57,25,59,13,13,17,13,13,13,13,15,13,13,13,13,13,15,13,17,13,13,17,13,13,57,25,59,13,13,17,17,13,16,13,13,13,13,13,13,17,13,57,25,59,13,57,25,25,25,25,59,13,13,13,13,13
|
||||
13,13,17,13,13,13,14,17,13,13,13,13,14,13,13,13,13,13,13,13,16,13,13,13,13,13,13,16,13,13,17,16,14,13,13,13,17,14,13,13,13,17,14,13,57,25,59,13,16,13,13,13,13,13,13,16,17,13,13,16,13,13,16,13,13,13,15,13,57,25,59,13,13,13,13,13,14,13,13,13,16,17,13,13,17,57,25,59,13,67,25,41,41,25,68,13,17,13,13,13
|
||||
13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,16,13,13,17,13,13,17,13,13,13,13,13,13,17,13,13,13,13,17,13,13,57,25,59,13,13,13,13,13,16,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,57,37,59,13,13,13,13,13,13,13,13,13,13,17,13,13,17,57,25,59,13,57,25,25,25,25,59,17,17,13,13,13
|
||||
13,13,13,13,13,13,13,16,13,13,13,13,13,13,16,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,57,25,66,55,69,55,55,55,55,69,55,55,55,55,55,55,69,55,55,55,55,55,55,55,65,25,66,55,56,13,13,17,13,13,13,13,16,16,13,17,16,57,25,59,13,57,25,25,25,25,59,13,13,13,14,13
|
||||
13,13,13,13,17,13,13,13,13,13,16,13,13,17,13,17,14,13,13,13,13,17,17,13,13,13,13,13,13,13,13,17,13,17,13,13,13,13,17,13,13,13,13,13,57,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,59,13,13,13,13,16,13,13,13,13,13,13,13,67,25,59,13,67,25,41,41,25,68,13,13,13,13,13
|
||||
13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,17,13,13,13,13,13,17,13,13,13,13,17,17,13,13,13,17,13,17,13,16,17,17,13,16,13,15,13,13,60,61,61,61,61,61,70,61,61,61,61,70,61,61,61,61,61,61,61,61,70,61,61,61,61,70,61,61,62,17,14,16,13,13,13,13,13,13,13,13,13,57,25,59,13,57,25,25,25,25,59,13,13,17,13,13
|
||||
13,13,17,14,13,13,13,13,17,17,13,13,13,13,13,13,13,13,13,13,17,16,14,17,13,17,17,13,17,13,13,13,13,13,13,17,17,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,14,17,13,13,17,13,13,57,25,59,13,57,25,25,25,25,59,13,13,13,13,16
|
||||
13,13,17,13,13,13,13,13,17,13,13,13,13,17,17,17,13,16,13,13,13,13,13,13,13,13,13,13,13,17,13,14,13,13,13,13,16,13,13,17,16,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,17,13,13,13,57,25,66,55,65,25,25,25,25,59,17,14,13,13,13
|
||||
17,13,13,13,13,13,13,17,16,14,17,13,17,17,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,17,17,13,13,13,13,13,13,13,13,17,13,13,13,13,13,17,13,13,13,13,13,13,17,13,13,13,13,14,13,13,13,13,17,17,13,13,13,13,13,17,13,13,17,13,16,13,13,13,13,13,13,13,13,13,57,25,25,48,25,25,25,25,25,59,17,13,13,13,13
|
||||
13,13,17,13,16,13,13,13,13,13,13,13,13,13,13,13,13,13,14,17,13,13,13,13,14,13,13,17,13,13,13,17,13,17,14,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,16,13,13,60,61,61,61,61,61,70,70,61,62,13,13,13,17,13
|
||||
13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,17,13,13,13,13,13,17,13,13,13,13,17,16,14,13,13,13,17,14,13,13,13,13,17,17,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,16,13,13
|
||||
13,17,13,13,13,14,17,13,13,13,13,14,13,13,17,13,17,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,16,13,13,13,13,13,17,13,13,13,13,13,13,17,13,13,13,13,14,13,13,13,13,17,17,13,13,13,13,13,17,13,13,13,13,13,13,13,13,17,13
|
||||
13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,16,13,13,13,13,13,13,16,13,13,13,13,13,13,13,13,13,13,13,17,16,14,13,13,13,17,14,13,13,13,13,13,13,13,17,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,17,13,17,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13
|
||||
13,13,13,17,13,13,13,13,13,13,17,13,13,13,13,14,13,13,13,13,17,17,13,13,13,13,13,17,13,13,13,13,13,16,13,13,17,13,13,17,13,13,13,13,13,13,16,13,13,13,13,13,13,13,13,17,13,13,13,13,14,17,13,13,13,13,13,13,13,17,17,13,13,13,13,13,17,13,13,13,13,17,16,14,13,13,13,17,14,13,13,13,13,17,17,13,13,13,13,13
|
||||
13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,17,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,16,13,13,13,13,13,13,13,13,17,13,13,13,13,13,17,13,13,13,13,17,13
|
||||
13,17,14,13,13,13,13,17,17,13,13,13,13,13,17,13,13,13,13,17,16,14,13,13,13,17,14,13,13,13,13,17,17,13,13,13,13,13,13,13,13,17,13,13,13,13,13,14,17,13,13,13,13,13,13,17,13,16,13,13,13,13,13,13,13,13,13,13,17,16,14,13,13,13,17,14,13,13,13,13,13,13,13,17,13,17,13,13,13,13,13,13,17,16,14,17,13,17,17,13
|
||||
13,17,13,13,13,13,13,17,13,13,13,13,13,13,13,13,16,13,13,13,13,13,13,13,13,17,13,13,13,13,13,17,13,13,13,13,17,13,13,13,13,13,15,15,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,16,13,13,13,13,13,13,13,13,17,13,13,13,13,14,17,13,13,13,13,13,13,17,13,16,13,13,13,13,13,13,13,13,13,13
|
||||
13,13,13,13,13,13,17,16,14,13,13,13,17,14,13,13,13,13,13,13,13,17,13,17,13,13,13,13,13,13,17,16,14,17,13,17,17,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,17,13,17,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13
|
||||
13,17,13,16,13,13,13,13,13,13,13,13,17,13,13,13,13,14,17,13,13,13,13,13,13,17,13,16,13,13,13,13,13,13,13,13,13,13,13,13,13,14,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,17,13,13,14,17,13,13,13,13,13,13,17,13,16,13,13,13,13,13,13,13,13,13,17,13,13,13,14,17,13,13,13,13,14,13,13,13
|
||||
13,13,13,13,13,13,13,13,17,13,17,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,16,13,13,13,13,13,13,13,13,13,17,17,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13
|
||||
17,13,13,13,14,17,13,13,13,13,13,13,17,13,16,13,13,13,13,13,13,13,13,13,17,13,13,13,14,17,13,13,13,13,14,13,13,17,13,13,13,13,13,13,13,13,15,13,13,17,13,13,13,13,13,16,13,13,15,13,13,13,17,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,16,13,13,13,13,13,13,16,13,13,13,13,13,14,13,13
|
||||
13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,15,15,15,13,13,13,13,13,17,16,14,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,17,13,13,13,13,13,16,13,13,17,13,13,17,13,13,13,17,13,13
|
||||
13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,16,13,13,13,13,13,13,16,13,13,13,13,13,14,13,13,16,13,13,13,15,13,13,13,13,17,14,13,13,13,13,17,17,13,13,13,16,13,13,13,13,13,13,13,13,13,13,13,13,16,13,13,13,13,13,13,16,13,13,13,13,13,14,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13
|
||||
13,13,17,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,17,13,13,13,13,13,16,13,13,17,13,13,17,13,13,13,17,13,13,13,13,13,16,16,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,15,13,13,13,13,17,13,13,13,13,17,13,13,13,13,13,16,13,13,17,13,13,17,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13
|
||||
13,13,13,13,13,13,13,13,13,16,13,13,13,13,13,13,16,13,13,13,13,13,14,13,13,13,13,13,13,13,16,16,13,13,13,13,13,15,13,13,13,16,13,13,13,15,15,13,13,13,13,13,13,13,13,13,13,13,15,14,17,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13
|
||||
13,13,13,13,13,13,17,13,13,13,13,13,16,13,13,17,13,13,17,13,13,13,17,13,13,13,13,16,13,16,13,16,13,16,15,13,13,13,16,13,13,13,13,13,13,13,13,13,13,13,13,15,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,14,13,13,13,13,17,17,13,13,13,13,13,13,13,13,17,13,17,13,13,16,13,13,13,13,13,14,13,13,13,13,13,13
|
||||
13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,16,13,13,13,17,13,13,13,13,13,13,13,13,13,15,14,15,13,13,13,17,17,13,15,13,13,15,13,13,13,17,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,16,13,13,13,13,13,13,16,13,13,13,13,13,14,13,13,13,13,13,17,13,17,13
|
||||
13,13,13,13,17,14,13,13,13,13,17,17,13,13,13,13,13,13,13,13,17,13,17,13,13,16,13,16,13,13,13,14,13,0,0,0,0,13,13,13,13,16,13,13,13,13,13,17,13,13,13,13,17,17,15,15,13,17,13,13,13,13,13,13,13,13,13,13,17,13,15,13,13,13,17,13,13,13,13,13,16,13,13,17,13,13,17,13,13,13,17,13,17,13,13,13,17,13,17,13
|
||||
13,13,13,13,17,13,13,13,13,13,17,13,13,13,13,17,17,13,13,13,17,13,17,13,17,13,13,13,13,13,16,17,13,43,43,43,43,13,13,17,13,13,13,13,13,13,17,16,14,17,13,17,17,13,17,15,13,13,13,13,13,13,13,13,16,13,13,13,13,13,15,16,13,13,13,13,13,14,13,13,17,13,13,13,13,13,13,16,13,16,13,13,13,17,13,13,13,13,13,13
|
||||
13,13,17,13,13,13,13,13,13,17,16,14,17,13,17,17,13,17,13,13,13,13,13,13,13,13,13,13,13,13,16,13,57,25,25,25,25,59,13,13,13,17,13,16,13,13,13,13,13,13,13,13,13,13,13,17,13,14,13,13,13,17,13,13,13,13,13,16,13,13,17,13,13,17,13,13,13,17,13,13,17,16,13,13,13,13,13,13,13,16,13,13,13,13,17,13,14,13,13,13
|
||||
13,13,13,13,17,13,16,13,13,13,13,13,13,13,13,13,13,13,17,13,14,13,13,13,13,13,13,13,13,17,13,17,57,25,41,41,25,59,13,13,13,17,13,13,13,13,13,13,17,13,13,13,13,13,13,13,17,17,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,16,13,13,17,13,13,13,13,13,13,13,13,17,17,13,13,13
|
||||
13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,17,17,13,13,13,17,17,13,13,13,17,13,17,57,25,25,25,25,59,13,13,17,13,13,13,14,17,13,13,13,13,14,13,13,17,13,13,13,17,13,17,14,13,13,13,13,17,17,13,13,13,13,13,13,13,13,17,13,17,13,13,16,13,13,17,13,13,14,13,16,13,13,13,17,16,13,13,17,13,17,13
|
||||
13,13,13,17,13,13,13,14,17,13,13,13,13,14,13,13,17,13,13,13,17,13,17,17,17,13,17,13,13,13,13,13,57,25,25,25,25,59,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,16,16,13,13,13,17,13,13
|
||||
13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,17,13,14,13,13,57,25,41,41,25,59,13,15,16,13,17,13,13,54,55,69,55,55,69,55,56,13,13,15,13,13,54,55,55,69,55,55,69,55,55,69,55,55,69,55,56,13,15,13,13,15,13,13,54,55,124,55,55,55,55,69,55,69,55,56,13,13,13,13,14,13,13,13
|
||||
13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,17,17,13,13,67,25,25,25,25,68,13,13,13,13,17,13,13,57,25,25,25,25,25,30,59,13,17,13,13,17,57,30,28,25,25,25,25,25,25,25,25,25,25,25,59,13,13,13,13,13,13,17,57,75,125,77,73,78,78,25,25,25,25,59,13,13,13,13,13,13,15,13
|
||||
13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,14,17,13,13,13,13,14,13,13,17,13,13,13,17,13,17,57,25,25,25,25,59,13,13,13,13,15,13,13,57,25,25,25,25,25,25,59,13,13,13,17,13,57,25,25,25,25,25,25,25,25,25,25,25,25,25,59,13,13,13,14,13,13,13,57,25,25,25,78,78,95,25,25,25,25,68,13,14,13,16,15,13,13,13
|
||||
13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,57,25,41,41,25,59,13,13,17,16,16,16,13,67,25,25,25,25,25,25,68,13,17,13,13,13,67,25,25,25,25,25,25,25,25,25,25,25,25,25,68,13,15,13,13,13,15,13,67,25,25,25,75,74,25,25,25,25,25,59,13,13,13,13,13,13,13,13
|
||||
13,13,13,17,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,15,13,13,13,13,13,17,57,25,25,25,25,59,16,13,13,13,13,13,13,57,25,25,25,25,25,25,59,13,13,15,13,13,57,25,25,25,25,25,25,25,25,25,25,25,25,25,59,13,13,13,13,13,13,13,57,25,25,25,25,25,25,25,25,25,25,66,55,69,55,55,69,55,56,13
|
||||
13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,16,13,13,13,13,13,13,16,13,13,13,13,13,14,57,25,41,41,25,59,13,13,13,54,55,69,55,65,25,25,25,25,25,25,66,55,69,55,69,55,65,25,25,25,25,25,25,25,25,25,25,25,25,25,66,55,69,55,69,55,69,55,65,25,25,25,25,25,25,25,25,25,25,49,25,25,25,25,25,25,59,13
|
||||
13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,17,13,13,13,13,13,16,13,13,17,13,13,17,13,13,13,17,57,25,25,25,25,59,17,16,13,57,25,25,25,25,25,25,25,25,25,25,25,25,25,29,25,25,25,25,25,25,25,104,55,112,55,55,112,55,105,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,49,25,25,25,25,25,25,59,13
|
||||
13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,67,25,25,25,25,68,13,13,13,57,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,49,25,25,50,44,25,25,68,13
|
||||
13,13,13,13,13,17,14,13,13,13,13,13,13,17,14,13,13,13,13,17,17,13,13,13,15,13,13,13,13,17,13,17,57,25,41,41,25,59,13,15,17,57,25,104,55,112,55,55,112,55,105,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,49,25,25,46,51,25,25,59,13
|
||||
13,13,13,13,13,17,13,13,13,13,13,13,13,17,13,13,13,13,13,17,13,13,13,13,17,17,13,13,13,17,13,17,57,25,25,25,25,59,13,13,13,57,25,25,25,25,25,25,25,25,25,25,104,55,112,55,55,112,55,105,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,49,25,25,44,47,25,25,59,13
|
||||
13,13,13,17,13,13,13,13,13,13,13,17,13,13,13,13,13,13,17,16,14,17,13,17,17,13,17,13,13,13,13,13,57,25,25,25,25,59,17,16,13,57,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,104,55,112,55,55,112,55,105,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,49,25,25,50,51,25,25,68,13
|
||||
13,13,13,13,13,17,13,16,13,13,13,13,13,17,13,16,13,13,13,13,13,13,13,13,13,13,13,17,13,14,13,13,57,25,41,41,25,59,13,13,13,57,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,49,25,25,25,25,25,25,59,13
|
||||
13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,17,17,13,13,67,25,25,25,25,68,13,13,17,57,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,64,61,70,61,70,61,70,61,70,61,63,25,25,44,50,25,25,59,13
|
||||
13,13,13,13,17,13,13,13,14,17,13,13,17,13,13,13,14,17,13,13,13,13,14,13,13,17,13,13,13,17,13,17,57,25,41,41,25,59,15,16,13,57,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,59,13,13,13,13,13,13,13,13,13,57,25,25,51,47,25,25,68,13
|
||||
13,13,13,13,13,13,17,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,57,25,25,25,25,59,13,13,13,57,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,104,55,112,55,55,112,55,105,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,59,15,13,13,16,17,13,13,16,13,67,25,25,45,46,25,25,59,13
|
||||
13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,16,13,13,13,13,13,13,16,13,13,13,13,13,14,13,13,13,57,25,94,25,25,59,13,17,13,57,25,104,55,112,55,55,112,55,105,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,68,13,13,14,13,17,13,15,13,13,57,25,25,25,25,25,25,59,13
|
||||
13,13,13,13,13,13,13,13,13,13,15,13,17,13,13,13,13,13,16,13,13,17,13,13,17,13,13,13,17,13,13,13,57,25,78,94,25,59,13,13,15,57,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,59,13,13,13,13,13,13,13,13,13,57,25,25,25,25,25,25,59,13
|
||||
13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,57,94,78,78,25,59,17,13,13,57,90,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,104,55,112,55,55,112,55,105,25,68,13,15,13,16,13,13,16,13,13,60,61,70,63,25,64,61,62,13
|
||||
13,13,13,13,13,13,13,13,13,13,16,13,13,13,13,13,13,16,13,15,13,13,13,14,13,13,17,13,17,13,13,13,57,78,78,78,25,59,13,13,17,57,90,90,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,104,55,112,55,55,112,55,105,25,25,25,25,25,25,25,25,25,25,25,25,25,59,13,16,13,17,13,15,13,13,17,13,17,13,57,25,59,13,13,13
|
||||
13,13,13,13,13,13,13,17,13,13,13,13,13,16,13,13,17,13,13,17,13,13,13,17,13,13,17,13,17,13,13,13,57,78,78,78,25,66,55,55,55,65,25,25,25,25,25,25,104,55,112,55,55,112,55,105,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,59,13,13,13,13,13,16,13,13,16,13,13,13,57,85,59,13,17,13
|
||||
13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,54,55,65,78,78,78,25,25,83,58,81,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,66,55,69,55,55,55,55,69,55,69,55,55,55,65,25,66,55,56,13
|
||||
13,13,13,13,13,17,14,13,13,13,13,17,17,13,13,13,13,13,13,13,13,17,13,17,17,13,14,13,13,13,57,71,77,74,78,78,25,25,25,87,46,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,88,25,25,25,25,25,25,25,25,25,25,25,59,13
|
||||
13,13,13,13,13,17,13,13,13,13,13,17,13,13,13,13,17,17,13,13,13,17,13,17,13,17,17,13,13,13,57,83,77,77,74,78,64,61,61,61,61,63,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,104,55,112,55,55,112,55,105,25,25,25,25,25,25,25,64,61,70,61,61,61,61,70,61,70,63,25,25,64,61,61,61,62,13
|
||||
13,13,13,17,13,13,13,13,13,13,17,16,14,17,13,17,17,13,17,13,13,13,13,13,13,13,17,13,17,13,57,81,77,73,76,74,59,13,13,13,13,57,25,25,25,25,25,25,25,25,25,25,25,25,104,55,112,55,55,112,55,105,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,59,13,13,13,15,13,13,13,13,13,57,40,40,59,13,13,13,13,13
|
||||
13,13,13,13,13,17,13,16,13,13,13,13,13,13,13,13,13,13,13,17,13,14,13,13,13,13,13,17,13,13,60,61,61,61,61,61,62,13,13,16,13,57,104,55,112,55,55,112,55,105,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,59,13,17,13,13,13,17,15,13,54,65,25,25,66,56,13,15,13,18
|
||||
13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,17,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,57,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,59,13,13,15,13,13,13,13,13,57,43,43,43,43,59,13,13,13,20
|
||||
13,13,13,13,17,13,13,13,14,17,13,13,13,13,14,13,13,17,13,13,13,17,13,17,13,13,13,13,16,13,13,13,13,13,13,13,13,13,13,13,13,116,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,117,13,13,15,13,17,13,15,17,57,43,25,25,43,59,15,17,13,13
|
||||
13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,57,79,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,104,55,124,55,105,25,59,13,17,13,13,13,13,13,13,57,43,25,25,43,59,13,13,15,13
|
||||
13,13,13,13,13,13,13,13,13,16,13,13,13,13,13,13,16,13,13,13,13,13,14,13,13,13,16,13,13,13,13,13,13,16,13,13,13,13,13,14,13,57,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,125,25,25,25,59,13,13,13,13,54,55,55,55,65,43,43,43,43,66,56,13,13,13
|
||||
13,13,13,13,13,13,17,13,13,13,13,13,16,13,13,17,13,13,17,13,13,13,17,17,13,13,13,13,13,16,13,13,17,13,13,17,13,13,13,17,13,57,79,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,59,13,13,17,13,57,26,26,26,26,26,26,26,26,26,59,13,13,13
|
||||
13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,57,79,90,25,28,90,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,59,13,15,13,54,65,26,25,25,25,25,25,25,25,26,66,56,13,17
|
||||
13,13,13,13,17,14,13,13,13,13,17,17,13,13,13,13,13,13,13,13,17,13,17,13,13,13,13,17,17,13,13,13,13,13,13,13,13,17,13,13,13,60,61,61,70,70,61,61,70,61,61,70,61,63,58,86,64,61,70,61,61,61,70,61,61,61,70,61,61,61,70,61,61,61,70,61,61,61,70,61,61,62,13,13,13,57,26,25,43,43,25,25,43,43,43,25,26,59,13,13
|
||||
13,13,13,13,17,13,13,13,13,13,17,13,13,13,13,17,17,13,13,13,17,13,17,13,13,13,13,17,13,13,13,13,17,17,13,13,13,17,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,57,74,37,59,13,13,13,13,13,13,13,13,17,13,13,13,13,17,15,13,13,13,13,13,13,13,15,13,13,13,13,13,57,26,25,25,43,25,25,43,25,43,25,26,59,13,17
|
||||
13,13,17,13,13,13,13,13,13,17,16,14,17,13,17,17,13,17,13,13,13,13,13,13,13,13,17,16,14,17,13,17,17,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,17,16,13,13,15,57,36,36,59,17,13,13,15,13,13,13,13,13,13,13,15,13,13,13,13,13,13,13,13,17,13,13,17,15,13,17,13,57,26,25,43,43,43,25,43,43,43,25,26,59,13,13
|
||||
13,13,13,13,17,13,16,13,13,13,13,13,13,13,13,13,13,13,17,13,14,13,13,16,13,13,13,13,13,13,13,13,13,13,13,17,13,14,13,13,13,13,17,16,13,13,13,15,13,13,13,13,13,57,36,36,59,13,15,13,13,54,55,55,55,55,55,55,55,55,55,55,55,55,55,56,13,13,13,13,13,13,13,13,15,57,26,25,25,25,25,25,25,25,25,25,26,59,15,13
|
||||
13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,17,17,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,17,17,13,13,13,13,13,13,13,13,13,13,13,13,16,13,13,57,36,36,59,13,13,13,13,57,25,43,25,43,78,49,49,49,49,78,25,43,25,66,55,55,55,55,55,55,55,55,55,65,26,25,43,25,43,25,43,43,43,25,26,59,13,13
|
||||
13,13,13,17,13,13,13,14,17,13,13,13,13,14,13,13,17,13,13,13,17,13,17,13,14,17,13,13,13,13,14,13,13,17,13,13,13,17,13,17,13,17,13,13,13,13,13,16,13,13,15,13,13,57,36,36,59,13,13,13,54,65,43,25,43,25,78,25,25,25,25,78,43,25,43,25,25,25,25,25,25,88,37,25,25,25,25,25,43,43,43,25,43,25,43,25,26,59,13,13
|
||||
13,13,13,13,13,17,13,13,13,13,15,13,13,13,15,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,15,13,15,14,13,17,13,13,16,13,57,36,36,59,13,15,13,57,43,25,43,25,43,75,77,77,77,77,74,25,43,25,43,64,61,61,61,61,61,61,61,61,63,26,25,25,25,43,25,43,43,43,25,26,59,13,17
|
||||
13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,16,13,13,13,13,13,13,13,13,17,17,13,13,13,13,13,13,13,13,16,13,13,15,13,57,36,36,59,17,13,13,57,25,58,58,58,25,43,25,43,25,43,25,43,25,43,25,59,13,13,13,13,13,13,13,13,60,63,26,25,25,25,25,25,25,25,26,64,62,13,13
|
||||
13,13,13,13,13,13,13,13,13,13,13,13,13,16,13,13,13,13,17,13,13,13,17,13,13,13,17,13,15,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,17,13,13,57,36,36,59,13,15,13,57,43,58,58,58,43,25,43,25,43,25,43,25,43,25,43,59,13,13,17,13,13,13,13,13,13,57,26,26,26,26,26,26,26,26,26,59,13,15,13
|
||||
13,13,13,13,17,13,13,13,13,13,13,13,17,13,17,13,13,13,13,15,13,13,13,13,13,13,13,13,13,13,15,13,13,17,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,57,36,36,59,13,13,13,57,25,58,25,58,25,43,25,43,25,43,25,43,25,43,25,59,13,13,13,15,13,15,15,13,13,60,61,61,61,61,61,61,61,61,61,62,13,13,13
|
||||
13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,16,13,13,13,15,13,13,16,13,13,13,13,13,14,13,17,15,13,13,13,17,13,13,17,13,13,13,17,16,13,13,13,57,36,36,59,13,13,15,57,43,25,43,25,43,25,43,25,43,25,43,25,43,25,43,59,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13
|
||||
13,13,13,17,17,13,13,13,17,16,13,13,13,13,13,13,13,13,17,13,13,13,13,13,16,13,13,17,13,13,17,13,13,13,17,13,13,13,13,13,13,17,13,17,16,16,13,13,13,14,13,13,14,57,36,36,59,13,17,13,57,25,43,25,43,25,76,77,77,77,77,73,43,41,43,25,59,13,13,13,13,13,17,13,13,13,13,13,13,17,13,13,13,17,13,13,15,17,17,13
|
||||
13,13,13,13,13,13,13,13,13,13,13,15,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,16,13,13,14,17,13,13,13,17,17,13,13,13,17,57,36,36,59,15,17,13,60,63,25,43,25,43,78,64,61,61,63,78,25,43,25,64,62,13,15,13,13,13,13,15,13,13,15,13,13,13,17,13,13,13,13,13,13,13,13,13
|
||||
13,13,17,13,13,17,13,13,17,16,13,13,13,13,13,13,17,14,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,17,17,13,13,13,17,17,13,13,13,13,13,13,13,13,17,13,13,57,36,36,59,13,13,13,13,57,43,25,43,25,78,59,13,13,57,78,43,25,43,59,13,15,13,13,13,13,15,13,17,13,13,17,13,13,13,15,13,17,13,17,13,13,13,13
|
||||
13,13,13,13,13,15,13,13,13,17,13,13,13,13,13,13,17,13,13,13,13,13,17,13,13,13,13,13,17,13,13,13,17,13,17,13,14,13,13,13,13,13,13,13,13,13,13,17,14,17,13,13,13,57,36,36,59,13,13,17,13,60,61,61,61,61,61,62,13,13,60,61,61,61,61,62,13,13,17,13,13,13,17,13,17,13,13,13,13,13,17,17,13,13,17,13,13,13,13,13
|
||||
13,17,13,13,13,13,17,13,13,13,13,17,13,13,17,13,13,13,13,13,13,17,16,15,17,13,13,13,13,17,13,13,13,13,13,13,13,17,13,15,13,16,13,16,17,13,13,13,13,13,13,13,13,57,36,36,59,17,13,13,13,13,15,15,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,15,13,13,13,13,13,15
|
||||
13,13,13,17,13,13,13,13,13,14,13,13,13,13,13,13,17,13,16,13,13,13,13,13,13,13,13,13,13,13,17,13,15,13,13,13,13,13,13,13,13,16,13,13,17,13,17,13,13,54,55,55,55,65,36,36,66,55,55,55,56,13,17,13,13,13,17,13,13,13,15,13,13,13,13,13,13,13,13,13,13,17,13,13,15,17,13,15,13,13,13,13,13,13,13,13,13,17,13,13
|
||||
13,17,13,13,13,13,17,18,19,13,13,17,15,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,17,16,13,13,13,13,13,17,13,13,57,43,43,43,43,43,43,43,43,43,43,59,13,13,13,13,13,14,13,13,13,13,13,13,13,13,13,17,13,13,13,13,17,13,13,15,13,13,13,17,13,13,13,13,13,13,13,13,17,13,13
|
||||
13,13,13,14,13,13,13,20,21,13,13,17,13,13,13,17,13,13,13,14,17,13,13,13,13,14,13,13,17,13,13,13,17,13,17,17,13,14,13,16,13,13,13,14,13,13,17,13,54,65,43,43,43,43,43,43,43,43,43,43,66,56,13,17,17,13,13,13,13,13,13,13,13,15,13,17,13,13,15,13,15,13,13,13,13,13,13,13,13,17,13,17,17,13,13,17,13,17,13,13
|
||||
13,16,13,13,13,17,13,13,13,15,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,17,13,13,17,18,19,13,17,13,13,13,13,57,43,43,25,25,25,25,25,25,25,25,43,43,59,17,13,13,13,17,15,17,13,13,14,13,13,15,13,13,17,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13
|
||||
13,13,13,13,54,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,56,15,13,14,13,13,13,13,13,15,13,17,20,21,13,13,13,15,13,13,57,43,25,25,25,25,25,25,25,25,25,25,43,59,13,13,13,13,14,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,17,13,13,13,13,13,13,13,13,13,13
|
||||
13,13,13,13,57,25,25,25,25,25,25,25,25,25,49,25,49,25,49,25,25,25,25,25,25,25,25,27,59,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,57,43,25,25,43,43,43,43,43,43,25,25,43,59,13,17,13,13,13,13,13,17,13,13,17,13,17,13,13,13,13,13,17,13,17,13,13,13,13,13,13,13,13,15,13,13,17,13,13,17,13,13
|
||||
13,16,16,13,57,25,54,55,55,55,135,55,55,55,55,55,55,55,55,55,55,55,135,55,55,55,56,25,66,55,55,69,55,55,69,55,55,69,55,55,69,55,55,69,55,55,55,55,65,43,25,25,43,43,43,43,43,43,25,25,43,59,13,13,14,17,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,15,13,13,13,13,13,17,13,17,17,17,13,17,13,13,13,13,13,13
|
||||
13,17,13,13,57,36,57,27,25,25,57,25,25,25,25,25,25,25,25,25,25,25,57,26,25,25,59,25,87,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,88,25,25,43,25,25,43,43,43,43,43,43,25,25,43,59,13,13,13,13,13,17,17,13,13,13,13,13,13,17,13,17,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13
|
||||
13,13,16,13,57,25,60,61,63,25,57,25,104,55,55,55,134,55,55,55,56,25,60,61,107,25,59,61,61,61,61,70,61,61,70,61,61,70,61,61,70,61,61,70,61,61,61,61,63,43,25,25,43,43,43,43,43,43,25,25,43,59,17,13,13,13,13,17,13,13,13,14,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,17,17,13,13,13,13,13,17,13,13
|
||||
13,13,15,13,57,25,25,25,57,25,57,25,25,25,25,25,59,25,25,27,59,25,25,25,25,25,59,13,13,17,13,17,13,13,17,14,17,13,17,13,13,17,13,17,13,13,13,17,57,43,25,25,43,43,43,43,43,43,25,25,43,59,13,13,17,13,13,13,17,13,13,13,13,13,14,13,13,13,13,13,13,13,13,13,13,13,14,13,13,13,13,13,17,13,17,13,13,13,13,13
|
||||
13,16,13,13,60,61,63,25,111,25,60,61,130,61,107,25,59,25,104,55,126,55,55,55,105,25,59,17,54,55,55,55,55,55,55,55,55,55,56,13,54,55,69,69,55,56,13,13,57,43,25,25,25,25,25,25,25,25,25,25,43,59,13,13,13,17,13,17,13,13,13,17,17,13,13,17,13,13,13,13,13,13,13,17,13,13,13,13,13,13,17,13,13,17,13,13,13,13,13,13
|
||||
13,17,16,13,13,13,57,37,25,25,25,25,57,25,25,25,59,25,25,25,59,25,25,25,25,25,59,17,67,26,27,27,27,27,27,27,27,27,68,17,57,43,43,43,43,59,17,14,57,43,43,25,25,25,25,25,25,25,25,43,43,59,17,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,17,13,13,13,13,13,17,17,13,13
|
||||
13,13,13,17,13,13,127,55,55,55,56,25,111,25,64,61,62,25,108,25,59,25,104,55,55,55,128,13,60,61,61,61,61,63,25,64,61,61,62,13,67,43,43,43,43,68,13,13,60,63,43,43,43,43,43,43,43,43,43,43,64,62,13,14,13,13,13,13,54,55,69,69,55,124,124,124,55,118,69,55,56,13,13,13,13,54,55,69,55,69,69,55,69,55,134,69,69,56,13,17
|
||||
13,14,13,17,15,13,57,27,25,25,59,25,25,25,59,27,25,25,59,25,59,25,25,25,25,27,59,17,17,13,13,13,13,57,25,59,13,17,13,14,57,43,43,43,43,59,17,13,13,57,43,43,43,43,43,43,43,43,43,43,59,13,13,17,13,13,13,13,57,47,27,47,83,125,125,125,27,47,27,47,59,13,14,13,13,57,71,25,25,25,25,25,25,25,110,25,30,68,13,13
|
||||
13,13,13,13,17,13,127,55,105,25,66,55,55,55,129,55,56,25,59,25,66,55,56,25,104,55,128,13,15,13,17,15,13,57,25,66,55,69,69,55,65,43,43,43,43,66,55,56,13,60,61,61,61,61,61,61,61,61,61,61,62,13,13,13,14,17,17,13,67,27,47,27,47,27,47,27,47,27,47,27,59,13,17,17,13,57,83,25,25,25,25,25,25,25,25,25,25,68,13,13
|
||||
13,13,13,16,13,13,57,25,25,25,25,25,25,28,25,25,59,25,59,25,25,27,59,25,25,26,59,13,13,13,14,17,13,57,25,25,25,25,25,25,49,43,43,43,43,49,25,68,13,13,13,13,13,17,13,13,13,13,13,13,13,17,13,13,13,13,17,13,57,47,27,47,27,47,27,47,27,47,27,47,59,13,13,13,13,57,25,25,136,43,43,137,25,25,104,55,55,128,13,13
|
||||
17,13,13,16,13,13,57,25,106,61,130,61,61,61,107,25,59,25,59,25,106,61,62,25,104,55,128,13,13,17,13,13,13,60,61,61,63,25,25,64,61,61,70,70,61,61,61,62,13,14,13,13,13,13,13,17,13,14,13,13,13,13,13,17,13,17,13,13,57,27,47,27,47,27,47,27,47,27,47,27,66,55,55,55,55,65,25,25,81,43,43,25,25,25,25,25,79,59,13,13
|
||||
13,13,16,13,17,13,57,25,25,25,57,25,25,25,25,25,59,25,59,25,25,25,25,25,25,27,59,14,13,13,15,13,13,15,14,17,57,43,43,59,17,17,13,13,17,13,17,13,14,17,13,13,17,13,13,13,13,13,13,17,13,13,13,13,13,13,13,17,57,47,27,47,27,47,27,47,27,47,27,47,38,25,25,88,25,39,25,25,136,43,43,137,25,25,47,47,25,68,13,17
|
||||
13,13,13,13,14,13,57,25,109,25,57,25,54,55,55,55,128,25,66,55,55,55,55,55,55,55,128,13,15,54,55,69,55,55,69,55,65,17,15,59,13,14,17,13,17,13,13,17,13,13,13,13,13,13,54,55,69,55,69,55,55,69,55,69,55,56,13,13,67,27,47,27,47,27,47,27,47,27,47,27,64,61,61,61,61,63,139,25,25,25,25,25,25,25,47,47,25,68,13,13
|
||||
13,15,17,13,16,13,57,27,57,25,57,25,57,26,25,25,59,25,25,25,25,25,25,25,25,27,59,13,13,57,81,46,75,74,25,25,25,43,43,66,55,69,55,55,55,56,17,17,13,17,13,13,14,13,57,25,25,25,25,25,25,25,25,25,30,59,13,14,57,47,27,47,27,47,27,47,27,47,27,47,59,13,13,13,13,57,138,138,139,25,25,25,25,25,25,25,25,59,17,13
|
||||
13,13,13,16,17,13,127,55,65,25,57,25,60,61,63,25,66,55,135,55,55,55,105,25,104,55,128,15,13,67,78,25,25,25,25,25,25,25,25,49,25,25,25,25,25,59,13,17,15,13,16,13,13,13,57,25,64,61,70,61,61,70,61,63,25,59,13,13,57,27,47,27,47,27,47,27,47,27,47,27,59,13,16,13,17,57,138,139,25,25,25,25,25,25,25,81,71,59,13,13
|
||||
13,13,13,13,13,13,57,29,25,25,57,25,25,25,57,25,25,25,57,25,25,25,25,25,25,27,59,13,17,57,74,25,43,25,25,43,43,25,25,64,61,70,61,63,25,59,17,13,17,13,13,17,13,13,67,25,68,13,13,13,13,13,13,57,25,68,13,13,60,61,61,61,61,63,40,64,61,119,61,61,62,13,13,14,13,60,61,61,61,61,63,25,64,61,61,61,61,62,13,16
|
||||
13,13,13,16,13,13,57,25,104,55,132,55,56,25,111,25,108,25,57,25,54,55,135,55,55,55,128,14,13,67,25,25,43,43,25,25,43,25,25,59,13,17,17,57,25,59,13,14,13,13,13,13,15,13,57,25,59,13,13,18,19,17,13,57,25,59,13,13,13,13,13,13,13,57,27,59,13,13,13,16,13,13,13,13,13,13,13,13,13,13,13,80,13,13,13,13,13,13,13,13
|
||||
13,14,17,13,15,13,57,25,25,25,25,27,59,25,25,25,59,27,57,25,57,25,57,25,37,25,59,13,15,57,25,25,25,25,25,25,25,25,25,59,17,14,13,67,25,68,17,13,16,16,13,17,13,13,57,85,59,13,13,20,21,13,13,67,25,59,13,14,13,13,17,13,17,57,85,59,13,13,13,17,16,13,17,13,13,13,13,13,13,13,13,13,13,13,16,17,13,13,17,13
|
||||
13,13,13,17,13,13,57,25,108,25,104,55,129,55,55,55,129,55,65,25,111,25,111,25,108,25,66,55,55,65,25,25,71,81,83,71,83,79,25,59,13,17,13,57,25,59,13,17,13,13,13,13,14,13,57,25,59,13,13,13,13,13,13,57,41,59,13,13,17,13,14,13,13,57,36,59,13,13,14,17,13,13,13,16,17,13,14,13,15,13,13,80,13,13,16,16,17,16,13,13
|
||||
13,13,15,13,13,13,57,27,59,25,25,25,25,25,25,25,25,25,39,25,25,25,25,25,59,25,43,13,43,25,25,25,25,25,25,25,25,25,25,59,15,17,17,67,25,68,13,15,13,15,13,17,13,17,67,25,68,13,14,13,13,13,17,57,25,59,13,13,13,13,13,13,13,57,25,59,13,13,13,13,13,13,13,13,13,13,13,13,13,13,57,25,59,13,13,13,13,13,13,13
|
||||
13,13,13,16,13,13,60,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,62,13,13,17,57,25,59,17,17,13,13,13,13,13,13,57,25,59,13,13,13,13,13,13,57,25,59,17,13,54,69,69,69,55,65,41,66,55,69,55,55,56,13,16,13,13,54,55,69,69,55,65,41,66,55,69,69,55,56,13,13
|
||||
17,17,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,15,13,13,13,13,15,13,13,14,13,17,13,17,13,15,13,15,13,57,25,59,13,13,54,55,69,55,69,55,65,36,66,55,55,55,55,56,13,57,25,59,13,13,67,0,0,0,78,25,25,25,25,25,25,75,59,13,13,14,13,57,49,42,49,42,49,42,49,42,49,42,49,59,13,13
|
||||
13,13,16,13,13,17,15,13,13,13,15,13,14,13,13,15,13,13,16,17,13,17,13,14,13,13,17,13,54,55,55,69,55,69,69,55,69,55,55,55,55,55,55,65,25,59,17,17,57,42,49,42,49,42,49,42,49,42,49,42,49,59,14,57,25,59,13,13,67,0,0,0,78,25,28,25,25,25,25,92,59,13,13,13,13,67,42,49,42,49,42,49,42,49,42,49,42,68,13,13
|
||||
13,13,13,13,15,15,13,13,13,13,13,13,13,13,15,13,14,13,17,16,17,15,13,13,13,13,13,17,57,26,27,25,25,25,25,25,25,27,26,49,25,25,87,25,25,68,15,13,57,49,42,49,42,49,42,49,42,49,42,49,42,59,13,57,25,68,13,17,67,3,0,4,78,25,25,25,25,29,25,25,59,16,13,13,13,57,49,42,49,42,54,55,56,42,49,42,49,68,13,13
|
||||
13,15,13,13,13,14,13,16,13,13,13,13,13,17,15,13,13,15,15,16,15,17,13,13,14,13,13,13,67,27,25,25,25,25,25,25,25,25,27,64,61,61,61,63,25,59,14,13,67,42,49,42,49,42,49,42,49,42,49,42,49,68,13,57,25,59,13,13,57,77,77,77,74,25,25,25,25,25,25,25,66,55,55,55,55,65,42,49,42,49,57,17,59,49,42,49,42,59,13,13
|
||||
13,13,13,13,13,13,13,13,13,16,15,13,13,15,17,15,15,13,17,15,13,17,13,13,13,13,17,17,57,73,25,25,27,27,27,27,25,25,25,59,13,17,13,57,25,59,13,17,67,49,42,49,42,49,42,49,42,49,42,49,42,68,13,57,25,59,13,13,57,93,25,25,25,25,25,25,25,25,25,25,38,25,25,88,25,39,49,42,49,42,57,16,59,42,49,42,49,59,13,13
|
||||
13,13,17,13,13,13,17,13,13,16,16,16,14,15,15,17,15,17,15,14,14,13,17,17,13,15,13,13,67,81,25,25,27,71,83,27,25,25,25,68,17,13,14,67,25,68,17,17,57,42,49,42,49,42,49,42,49,42,49,42,49,59,13,57,25,59,13,13,57,77,73,25,25,25,25,25,25,25,25,25,64,61,61,61,61,63,42,49,42,49,60,61,62,49,42,49,42,68,13,13
|
||||
13,13,13,15,14,13,13,15,13,13,16,13,13,17,13,13,15,15,13,13,13,17,13,15,13,17,13,14,57,74,25,25,27,27,27,27,25,25,25,59,13,15,17,57,25,59,13,15,57,49,42,49,42,49,42,49,42,49,42,49,42,59,17,67,41,59,17,13,67,76,74,25,25,25,25,25,94,25,25,76,59,13,13,13,13,67,49,42,49,42,49,42,49,42,49,42,49,68,13,13
|
||||
13,13,13,13,13,13,13,13,13,13,16,13,13,13,14,16,13,13,13,13,13,13,13,13,17,13,13,13,67,27,25,25,25,25,25,25,25,25,27,68,17,17,13,67,25,68,17,13,60,61,70,61,70,61,61,63,25,25,25,25,25,59,13,57,25,59,13,13,57,74,28,25,25,25,25,25,78,94,28,78,59,13,16,17,13,57,42,49,42,49,42,49,42,49,42,49,42,59,13,13
|
||||
13,17,13,13,13,17,15,13,13,14,13,16,16,16,13,13,13,13,13,14,13,17,13,17,13,13,13,13,57,26,27,25,25,25,25,25,25,27,26,59,13,15,17,57,25,59,17,15,13,13,13,13,13,13,13,57,93,25,25,25,76,59,13,57,25,59,13,13,60,61,61,61,61,63,40,64,61,61,61,61,62,13,13,13,13,60,61,70,70,61,63,42,64,61,70,70,61,62,13,13
|
||||
13,13,13,15,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,17,13,60,61,61,70,61,70,70,61,70,61,61,62,13,13,17,57,25,59,13,17,13,14,13,13,13,13,13,57,73,25,25,25,75,59,17,57,25,59,13,13,13,13,13,13,13,57,25,59,13,13,13,13,13,13,14,13,13,13,13,13,13,13,57,25,59,13,13,13,13,18,19,13
|
||||
13,13,54,55,55,69,55,69,55,69,55,55,56,13,13,14,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,57,86,59,13,13,13,13,13,13,13,13,13,127,55,105,41,104,55,128,13,57,25,59,13,17,17,13,17,14,17,57,85,59,17,13,13,17,13,13,13,13,13,13,16,13,13,13,57,85,59,13,14,16,17,20,21,13
|
||||
13,13,57,43,25,43,25,43,25,43,25,43,59,13,13,13,13,54,55,69,69,55,56,13,13,14,13,13,13,13,13,17,13,13,13,13,13,14,13,13,13,13,14,67,25,68,13,14,13,13,13,13,13,13,13,57,81,25,25,75,77,59,13,57,25,59,13,13,13,13,17,13,13,57,25,59,13,13,13,13,17,13,13,13,13,13,13,13,14,13,67,25,68,13,13,13,13,13,13,13
|
||||
13,13,57,72,43,25,43,80,82,80,82,80,59,13,15,13,13,57,25,25,25,25,59,13,13,13,17,13,15,13,13,13,17,15,13,13,17,13,13,13,13,13,13,57,25,59,13,13,13,13,13,13,13,13,13,57,46,25,25,76,77,59,17,57,25,59,17,17,17,13,13,13,13,57,41,59,13,14,13,13,13,13,13,13,13,13,13,13,13,13,57,25,59,16,13,17,13,14,13,13
|
||||
13,13,57,43,25,72,25,43,25,43,25,43,66,56,13,13,13,57,25,44,26,25,59,13,14,13,13,13,13,13,13,14,17,17,17,13,15,13,13,13,54,69,69,65,25,66,69,56,13,13,13,13,15,13,13,67,25,25,76,74,92,59,13,57,25,68,13,14,54,55,69,55,55,65,41,66,55,69,55,55,56,13,13,13,13,54,69,55,55,69,65,41,66,55,55,69,55,56,13,13
|
||||
13,13,57,25,43,25,43,25,43,25,43,25,95,66,55,134,55,65,25,26,50,25,59,13,13,13,13,13,14,13,13,13,13,13,13,13,13,13,14,13,57,25,25,25,25,25,25,59,14,13,13,13,17,14,13,57,25,25,78,25,25,59,13,57,25,59,13,13,57,138,139,25,25,25,25,25,25,25,25,137,59,13,13,17,13,57,77,74,95,25,25,25,25,71,77,77,74,59,17,13
|
||||
13,54,65,25,25,64,61,70,61,70,61,63,25,25,28,59,25,25,25,51,26,25,66,55,55,69,55,55,69,55,55,69,55,55,69,55,55,69,55,134,65,93,25,71,25,25,25,66,55,69,56,13,13,17,15,67,25,58,58,58,25,68,17,57,41,59,17,13,57,139,25,29,25,25,25,25,25,25,25,137,59,13,14,13,13,57,73,26,25,25,25,25,72,72,72,25,25,68,13,13
|
||||
13,57,42,42,42,59,13,13,13,13,13,57,25,25,25,114,25,25,25,25,25,25,88,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,59,74,25,25,25,25,25,25,25,75,73,59,13,15,13,13,57,25,58,58,58,25,59,13,67,25,59,13,13,67,136,25,25,25,25,25,25,25,25,25,76,59,13,13,13,13,57,74,25,25,25,25,25,25,25,25,25,25,59,13,13
|
||||
13,67,42,42,42,68,15,17,14,17,13,57,25,25,25,59,25,25,25,25,64,61,63,45,79,45,45,79,45,45,79,45,45,79,45,45,79,45,45,59,25,25,104,105,25,25,25,38,15,78,59,14,13,13,13,67,25,58,25,58,25,68,17,57,25,59,14,17,57,136,25,25,25,25,51,25,25,30,25,75,66,55,55,55,55,65,25,26,72,25,25,25,25,25,25,25,25,59,13,13
|
||||
13,57,25,25,25,59,13,17,13,15,13,57,25,25,25,110,25,25,76,77,59,14,57,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,37,88,25,25,25,25,25,25,25,38,14,78,68,13,18,19,13,57,25,51,37,50,25,59,13,57,25,59,13,13,57,138,139,25,25,25,46,25,25,25,25,25,38,38,25,88,25,39,25,25,72,25,25,47,25,25,25,25,25,59,17,13
|
||||
13,67,25,37,25,68,13,13,17,13,13,57,25,94,25,25,25,25,75,77,59,13,60,61,61,70,61,61,70,61,61,70,61,61,70,61,61,70,61,62,61,61,63,25,25,64,63,73,16,78,59,13,20,21,13,57,25,25,25,25,25,59,13,57,25,66,55,55,65,136,25,28,25,25,25,25,25,25,25,92,64,61,61,61,61,63,72,72,72,25,25,25,25,25,25,25,25,68,13,13
|
||||
13,57,25,25,25,66,97,13,13,13,13,57,25,78,25,25,25,25,81,77,59,13,13,13,13,18,19,13,15,13,13,13,14,13,13,13,13,13,13,13,13,13,60,70,70,62,57,78,43,78,59,13,13,13,17,57,28,25,25,25,29,59,13,57,28,25,25,25,37,25,25,25,25,25,25,28,25,25,25,137,59,13,13,13,13,57,43,43,43,25,25,25,25,47,25,25,25,59,13,13
|
||||
13,67,25,25,25,43,43,13,13,15,13,60,61,61,61,70,70,61,61,61,62,13,13,17,15,20,21,13,13,17,15,13,13,13,17,17,13,13,14,13,13,13,13,13,13,13,57,78,25,81,59,13,17,13,13,60,61,61,61,61,61,62,13,60,61,61,61,61,63,138,139,25,25,25,25,25,25,76,77,77,59,13,14,13,13,57,43,43,43,25,25,25,25,25,25,25,25,59,13,13
|
||||
13,57,44,51,50,64,99,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,13,13,13,13,13,13,17,13,13,13,13,13,15,13,13,13,13,17,13,13,13,13,13,60,61,70,61,62,13,17,14,13,13,17,13,13,13,13,13,13,13,13,13,14,13,60,61,61,61,61,61,70,61,61,61,61,61,62,13,13,13,13,60,61,61,70,61,61,61,61,70,61,61,61,62,13,14
|
||||
13,60,61,61,61,62,13,13,15,13,17,15,14,13,17,13,15,13,13,17,13,15,13,13,13,17,13,14,13,13,17,17,17,13,13,13,13,15,17,13,13,13,13,13,13,14,13,13,13,13,13,13,15,13,13,13,17,13,17,13,13,14,17,13,13,13,13,13,13,13,14,13,17,13,13,17,13,13,13,17,13,13,13,17,13,13,13,14,13,13,13,17,13,13,13,13,13,13,17,13
|
||||
13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,17,13,13,13,13,13,13,13,15,13,13,13,13,17,13,13,13,13,13,17,13,13,13,13,13,13,17,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,13,14,13,13,13,13,13,17,13,13,13,13,13,13,13,13,13,13,14,13,17,13,13,13
|
|
11
Tests/assets/maps/compass grid.tmx
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.0" orientation="orthogonal" width="100" height="100" tilewidth="16" tileheight="16">
|
||||
<tileset firstgid="1" name="platformer_tiles" tilewidth="16" tileheight="16">
|
||||
<image source="../tiles/platformer_tiles.png" width="304" height="96"/>
|
||||
</tileset>
|
||||
<layer name="Tile Layer 1" width="100" height="100">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJzt3NuNwkAMhWGaSBm0Qv/l7OOKaC6ei+Pfw3k40oqIYPtLMlkpcL1er0tB5TOQlfdH9rCrf+8+ZupR1u0ze2SocadhbZt1Ht6upf3TjqXWzCznwIxHrf8nLEoe0QYjHrN9luZ/VT7zKY/ZHiM8SsfuTo/WOtQy8vLonauRFvfZlWbWusZYjnfLfYF3r9a6Iz1a9e06P3o+T1hY1rfo9Na2VQ9KWrWR6rYcvyvXKyXGVB6cyIMVebAiD1bkwYo8WJEHL/JgJYPH+5boen7Z425xugvZ4z77d2XbSTZUj9Ksa3M/yYTucercM3nU5i4PXuTBijxYkQcr8mBFHqzIgxV5sCIPVuTBijxYkQcr8mBFHqzIgxV5sCIPVuTByekW8uBFHqzIgxV5sCKP/30TvOXx7RHt4umxuzfvORFMPDy8enpiRtHP05c8Zn0Ix5eny65Z936npOTR+02HEy1a58aOvkZ+w8T63trr1l5292zZ30hK+97lHeUxs50Uj1qt63TP46r8nX3mT/cw+hs/Vg9rP9FzXbHw2Lf1Hqm3zltMTzDxrnmXx+j+PPvz/v/c03vVg5hs51xpzrPrBzGZPUbdouuQiTyIkQcr8mBFHqzIgxV5sCIPVuTBijxYkQcr8mCF7FGavfW1rKF7lJ4xuG+XR5yJPOJT8jjRIpNH6/mt6Pp+zaPmcJpFJo+7SXQt8vg2ia5DHr8RebAiD1bkwYo8WJn1iDCsPeM9+9w3MaXvd1i+Y/B0z9nm3DpGWsdOb/Ykj+gZ76q3ty2LRyaTXR7U61XUZ67UarletTxKvd/3Ez2bkTWd5GedXTaPUbfoOuTBsNhxf5Xdg3idWjmWaus56dqcZb3Y4aHERx6sjN4/Kv75A/snIls=
|
||||
</data>
|
||||
</layer>
|
||||
</map>
|
80
Tests/assets/maps/mapCSV_Group1_Map1.csv
Normal file
|
@ -0,0 +1,80 @@
|
|||
31,31,31,31,31,31,31,31,31,31,31,31,31,32,31,31,31,31,31,31,31,32,32,33,32,33,34,32,34,33,31,32,31,31,31,31,31,31,31,32,32,33,32,33,34,32,34,33,31,32,31,31,31,31,31,31,31,32,32,33,32,33,31,31,31,31,31,31,31,32,32,33,32,33,34,32,34,33,31,32
|
||||
32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,34
|
||||
33,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,31
|
||||
32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,32,32,0,0,0,32
|
||||
31,32,32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,32,32,0,0,0,0,0,32,0,0,0,0,31
|
||||
32,0,0,0,32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,32,0,0,0,0,34
|
||||
34,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,32,32,32,0,0,0,31
|
||||
31,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,32,32,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,32,32,32,32,0,0,0,0,32,32,32,32,0,0,33
|
||||
32,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,32,32,0,0,0,32,32,32,32,32,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,32,0,0,31
|
||||
31,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,32,32,32,32,0,0,0,0,32,32,32,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,34
|
||||
34,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,32,0,0,0,0,32,32,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32
|
||||
31,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,32,0,0,32,32,32,0,0,0,0,0,32,32,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,32,0,0,0,0,32,32,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,33
|
||||
33,0,0,0,0,0,32,32,0,0,0,0,32,32,0,0,0,0,0,32,0,0,0,32,32,32,0,0,0,0,0,32,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,32,32,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,32
|
||||
31,0,0,0,0,0,32,0,0,0,0,0,32,32,0,0,0,0,0,32,32,0,0,32,32,32,0,0,0,0,32,32,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,32,32,0,0,0,0,0,0,32,32,0,32,32,32,32,0,0,0,0,31
|
||||
34,32,0,0,32,32,32,0,0,0,0,0,32,32,0,0,0,0,0,0,32,32,32,32,32,0,0,0,0,0,32,32,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,32,32,0,0,0,0,0,0,32,32,0,0,0,0,0,32,32,0,0,0,32
|
||||
32,32,32,32,32,32,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,32,32,0,0,0,0,0,32,32,0,0,0,0,0,0,32,32,0,0,0,34
|
||||
33,32,32,32,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,32,0,0,0,0,0,0,32,0,0,32,32,0,0,0,0,32,0,0,0,31
|
||||
32,32,32,32,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,32,0,0,0,0,0,32,32,0,0,0,32,32,0,0,0,32,32,0,0,32
|
||||
31,32,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,32,32,32,32,0,0,0,0,0,0,32,0,0,0,0,0,32,0,0,0,0,32,32,0,0,0,32,32,0,0,31
|
||||
32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,32,32,32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,32,32,32,32,0,0,0,0,0,0,32,0,0,0,0,0,32,32,32,32,32,32,0,0,0,32,32,32,0,0,34
|
||||
34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,32,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,32,32,32,0,0,0,0,32,32,0,0,0,31
|
||||
31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,32,32,32,32,0,0,0,0,32,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,32
|
||||
32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,33
|
||||
31,0,0,0,32,32,32,32,32,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,32
|
||||
34,0,0,0,0,0,32,32,32,0,0,0,0,0,0,32,32,32,32,32,32,32,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,32,32,32,32,0,0,0,0,0,31
|
||||
31,0,0,0,0,0,0,32,32,32,0,0,0,0,32,0,0,0,0,0,32,32,32,0,0,0,0,0,0,32,32,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,0,0,0,0,0,0,32
|
||||
33,0,0,0,0,0,0,0,32,32,0,0,0,0,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,34
|
||||
31,0,0,0,0,0,0,0,32,0,0,0,0,32,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,0,0,0,0,32,32,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,31
|
||||
34,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,32,32,32,32,32,32,32,32,32,32,0,0,0,32,32,32,32,32,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,32
|
||||
32,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,32,32,0,0,0,0,0,32,32,32,32,32,32,32,32,32,32,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,31
|
||||
33,0,0,0,0,0,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,32,32,0,0,0,0,32,32,32,32,32,32,32,32,32,32,32,32,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,34
|
||||
32,0,0,0,0,0,32,32,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,32,32,32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,32,32,32,32,32,32,0,0,0,0,32,32,0,0,0,0,0,31
|
||||
31,0,0,0,0,32,32,32,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,32,32,32,32,0,0,0,0,0,0,32,32,32,0,0,0,0,32,32,32,0,0,0,0,0,32,32,32,32,32,32,0,0,0,0,0,32,32,32,0,0,0,0,32
|
||||
32,0,0,0,32,32,32,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,32,32,32,0,0,0,0,0,32,0,0,0,0,0,0,0,32,0,0,32,0,0,0,0,0,0,32,32,32,32,32,0,0,31
|
||||
34,32,32,32,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,34
|
||||
31,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,31
|
||||
32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,32
|
||||
31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,32,0,32,32,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,33
|
||||
34,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,32
|
||||
31,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,32,0,0,0,31
|
||||
33,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,32,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,32,32,0,0,0,32
|
||||
31,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,34
|
||||
34,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31
|
||||
32,0,32,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32
|
||||
33,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31
|
||||
32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,32,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,34
|
||||
31,32,32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,32,0,0,31
|
||||
32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,0,0,0,0,0,32,32,0,32,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,32,32,0,32
|
||||
34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,32,32,32,32,0,0,32,32,32,0,0,0,0,0,0,0,0,0,32,32,0,34
|
||||
31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,32,32,32,32,32,32,32,32,0,0,0,0,0,0,0,0,32,32,32,32,31
|
||||
32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,32,32,32,32,32,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,32,32,32,32,32,0,0,0,0,0,0,0,0,32,32,32,32,0,0,32
|
||||
31,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,0,0,0,0,0,32,32,32,32,32,32,32,32,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,31
|
||||
34,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,32,32,32,32,32,0,32,32,32,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,34
|
||||
31,0,0,0,0,32,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,31
|
||||
33,32,32,32,32,32,32,0,0,0,32,32,32,32,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,33
|
||||
31,0,0,0,0,32,32,32,32,32,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31
|
||||
34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,34
|
||||
32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,32,0,32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32
|
||||
33,0,32,32,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,0,32,32,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,0,33
|
||||
32,0,32,32,32,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,32,32,32,32,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,32,32,32,32,32,0,0,0,0,0,0,0,32,32,32,32,32,32,32,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,32,32,0,0,0,0,32
|
||||
31,32,32,32,32,32,32,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,32,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,32,32,0,0,0,32,32,0,0,0,0,0,32,32,32,32,32,32,32,32,32,32,32,0,0,0,0,0,31
|
||||
32,0,32,32,32,32,32,0,0,0,0,0,0,0,0,32,32,0,0,0,32,32,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,32,32,32,32,0,0,0,0,0,0,0,32
|
||||
34,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,32,0,0,0,32,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,34
|
||||
31,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,32,0,0,32,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31
|
||||
32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32
|
||||
31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31
|
||||
34,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,34
|
||||
31,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,31
|
||||
32,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,32
|
||||
33,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,33
|
||||
32,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,32,32,32,32,32,32,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32
|
||||
31,0,0,0,0,32,32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,32,32,32,32,0,0,0,0,0,32,32,0,0,32,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,31
|
||||
32,32,32,32,32,32,32,32,32,32,32,0,0,0,0,0,32,0,0,32,32,0,0,0,32,32,32,32,32,32,32,32,32,32,32,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,32,0,0,0,0,0,32,32,32,32
|
||||
34,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,32,32,32,0,32,0,0,32,32,32,32,32,32,32,32,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,32,34
|
||||
31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,32,0,32,32,32,32,32,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,31
|
||||
32,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,32
|
||||
31,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,31
|
||||
34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,32,32,32,32,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,34
|
||||
31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,0,0,0,0,0,0,31
|
||||
33,31,31,31,31,31,31,32,32,33,32,33,34,32,34,33,31,31,31,31,31,31,31,31,32,32,33,32,33,34,32,34,33,31,32,31,31,31,31,31,31,31,32,32,33,32,33,34,32,34,33,31,31,31,31,31,31,31,31,32,32,33,32,33,34,32,31,31,31,31,31,31,31,32,32,33,32,33,34,32
|
|
16
Tests/assets/maps/mapCSV_SciFi_Map1.csv
Normal file
|
@ -0,0 +1,16 @@
|
|||
55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55
|
||||
55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55
|
||||
55,40,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,41,55
|
||||
55,50,38,35,1,1,1,1,1,1,29,34,29,1,1,28,1,1,47,55
|
||||
55,50,30,28,34,29,1,2,3,4,5,6,34,34,1,34,28,34,47,55
|
||||
55,50,1,30,34,29,28,7,8,9,10,11,1,33,30,1,39,29,47,55
|
||||
55,50,28,1,29,1,36,12,13,14,15,16,29,35,34,29,34,1,47,55
|
||||
55,50,30,34,29,30,32,17,18,19,20,21,30,35,31,32,1,30,47,55
|
||||
55,50,29,31,36,35,36,22,23,24,25,26,35,28,1,34,34,29,47,55
|
||||
55,42,45,45,45,45,49,35,35,35,35,34,27,34,35,34,35,1,47,55
|
||||
55,55,55,55,55,55,50,36,1,34,28,36,28,29,34,34,34,29,47,55
|
||||
55,40,53,53,53,53,54,28,32,1,1,28,34,35,29,38,34,1,47,55
|
||||
55,50,1,29,30,1,29,33,32,29,1,34,28,1,29,1,32,1,47,55
|
||||
55,42,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,43,55
|
||||
55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55
|
||||
55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55
|
|
18
Tests/assets/maps/platformer_map.csv
Normal file
|
@ -0,0 +1,18 @@
|
|||
31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31
|
||||
32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32
|
||||
33,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,33
|
||||
32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32
|
||||
31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31,34
|
||||
32,105,106,107,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,33
|
||||
34,0,0,0,0,0,0,31,0,0,0,0,0,0,0,0,0,0,0,32
|
||||
31,0,0,0,0,0,0,0,0,0,0,16,104,105,107,17,0,0,31,31
|
||||
32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31
|
||||
31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,33
|
||||
34,0,0,16,104,105,106,107,17,0,0,0,0,0,0,0,0,0,31,31
|
||||
31,0,0,0,0,0,0,0,0,0,0,0,63,65,0,0,0,0,0,31
|
||||
33,13,0,0,0,0,0,0,0,0,0,0,49,50,0,0,0,0,15,33
|
||||
31,33,13,0,0,0,0,0,0,0,0,47,51,52,46,0,0,13,34,31
|
||||
34,31,33,15,0,14,0,15,0,14,0,0,69,71,0,0,14,34,31,32
|
||||
42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42
|
||||
59,59,59,59,60,59,59,59,59,59,59,59,59,59,59,59,59,60,59,59
|
||||
78,78,78,78,79,78,78,78,78,78,78,78,78,78,78,78,78,79,78,78
|
|
90
Tests/assets/maps/shmup_level_1_map.csv
Normal file
|
@ -0,0 +1,90 @@
|
|||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,6,7,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,12,15,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,6,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,12,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,6,7,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,6,8,8,7,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,6,21,8,8,8,7,0,0,0,0,0,6,7,0
|
||||
0,0,0,0,0,6,9,8,11,11,20,9,7,0,0,0,0,12,15,0
|
||||
0,0,0,0,0,20,8,9,11,11,9,10,8,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,13,8,21,11,11,21,20,14,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,12,13,13,14,14,15,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,5,0,0,0
|
||||
0,0,0,0,0,6,7,0,0,0,0,0,0,0,6,11,8,7,0,0
|
||||
0,0,0,0,0,12,15,0,0,0,0,0,0,0,8,9,10,8,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,13,14,15,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,1,1,0,0,0,0,0,0,0,0,0,6,7,0,0,0,0
|
||||
0,0,1,2,2,1,0,0,0,0,0,0,0,0,12,15,0,0,0,0
|
||||
0,0,2,8,20,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,2,12,15,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,3,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,4,5,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,6,11,8,7,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,6,7,0,0,8,9,10,8,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,12,15,0,0,12,13,14,15,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,4,5,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0
|
||||
0,6,11,8,7,0,0,0,0,0,0,0,1,1,2,1,0,0,0,0
|
||||
0,8,9,10,8,0,0,0,0,0,0,0,2,8,20,2,0,0,0,0
|
||||
0,12,13,14,15,0,0,0,0,0,0,0,2,12,15,2,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,3,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,4,5,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,1,6,11,8,7,1,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,2,8,9,10,8,2,0,0,1,0,1,0
|
||||
0,0,0,0,0,0,0,0,3,12,13,14,15,3,0,0,2,8,2,0
|
||||
0,6,7,0,0,0,0,0,0,0,0,0,0,0,0,0,2,13,2,0
|
||||
0,12,15,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,3,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,6,7,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,2,8,8,2,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,6,21,8,8,8,7,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,1,2,9,8,11,11,20,9,2,1,0,0,0,0,0,0,0
|
||||
0,0,0,2,20,8,9,11,11,9,10,20,2,0,0,0,0,0,0,0
|
||||
0,0,0,3,13,8,21,11,11,21,20,14,3,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,12,13,13,14,14,15,0,0,4,5,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,6,11,8,7,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,8,9,10,8,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,12,13,14,15,0,0,0,0
|
||||
0,0,0,0,6,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,12,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,7,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,8,8,7,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,21,8,8,8,7
|
||||
0,0,0,1,0,0,1,0,0,0,0,0,0,6,9,8,11,11,20,9
|
||||
0,0,0,2,9,20,2,0,0,0,0,0,0,20,8,9,11,11,9,10
|
||||
0,0,0,2,12,15,2,0,0,0,0,0,0,13,8,21,11,11,21,20
|
||||
0,0,0,3,0,0,3,0,0,0,0,0,0,0,12,13,13,14,14,15
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,7,0,0
|
||||
0,0,0,0,0,0,4,5,0,0,0,0,0,0,0,0,12,15,0,0
|
||||
0,0,0,0,0,6,11,8,7,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,4,8,9,10,8,5,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,12,13,13,14,14,15,0,0,0,4,5,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,1,6,11,8,7,1,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,2,8,9,10,8,2,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,3,12,13,14,15,3,0,0,0
|
||||
0,0,0,4,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,6,11,8,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,8,9,10,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,12,13,14,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,6,7,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,12,15,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
|
39
Tests/assets/maps/test.json
Normal file
BIN
Tests/assets/misc/NSLIDE6A_020.bmp
Normal file
After Width: | Height: | Size: 188 KiB |
BIN
Tests/assets/misc/baddie1.png
Normal file
After Width: | Height: | Size: 653 B |
BIN
Tests/assets/misc/baddie2.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
Tests/assets/misc/boss1.png
Normal file
After Width: | Height: | Size: 8 KiB |
BIN
Tests/assets/misc/bullet0.png
Normal file
After Width: | Height: | Size: 262 B |
BIN
Tests/assets/misc/bullet1.png
Normal file
After Width: | Height: | Size: 3.1 KiB |