Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
2,795 additions
and
1,167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
coverage/ | ||
node_modules/ | ||
lib/ | ||
yarn-error.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"include": [ | ||
"lib/entities/*.js" | ||
], | ||
"exclude": [ | ||
"**/entity.js" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { | ||
Behavior, | ||
BehaviorState, | ||
BehaviorOptions, | ||
} from "./behavior"; | ||
|
||
export class NegateBehavior implements Behavior { | ||
private _negate: Behavior; | ||
|
||
constructor(negate: Behavior) { | ||
this._negate = negate; | ||
} | ||
|
||
reset(): void { | ||
this._negate.reset(); | ||
} | ||
|
||
call(options: BehaviorOptions): BehaviorState { | ||
const tmp = this._negate.call(options); | ||
|
||
if (tmp === "success") { | ||
return "failure"; | ||
} else if (tmp === "failure") { | ||
return "success"; | ||
} else { | ||
return "pending"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { | ||
Behavior, | ||
BehaviorState, | ||
BehaviorOptions, | ||
} from "./behavior"; | ||
|
||
export class UntilBehavior implements Behavior { | ||
private _until: Behavior; | ||
|
||
constructor(until: Behavior) { | ||
this._until = until; | ||
} | ||
|
||
reset(): void { | ||
this._until.reset(); | ||
} | ||
|
||
call(options: BehaviorOptions): BehaviorState { | ||
const tmp = this._until.call(options); | ||
|
||
if (tmp === "success") { | ||
return tmp; | ||
} else { | ||
if (tmp === "failure") { | ||
this._until.reset(); | ||
} | ||
|
||
return "pending"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export interface BackgroundData { | ||
fixed: boolean; | ||
xPeriod: number; | ||
yPeriod: number; | ||
xAmp: number; | ||
yAmp: number; | ||
} | ||
|
||
export class BackgroundComponent implements BackgroundData { | ||
fixed: boolean; | ||
xPeriod: number; | ||
yPeriod: number; | ||
xAmp: number; | ||
yAmp: number; | ||
|
||
constructor(options?: Partial<BackgroundData>) { | ||
this.fixed = false; | ||
this.xPeriod = 0; | ||
this.yPeriod = 0; | ||
this.xAmp = 0; | ||
this.yAmp = 0; | ||
|
||
Object.assign(this, options); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
export type ParticleField = "LIFETIME" | | ||
"X" | "Y" | | ||
"X_SUBPIXEL" | "Y_SUBPIXEL" | | ||
"X_SPEED" | "Y_SPEED" | | ||
"X_ACCEL" | "Y_ACCEL" | | ||
"SPRITE_FRAME"; | ||
|
||
export const PARTICLE_FIELDS = [ | ||
"LIFETIME", | ||
"X", | ||
"Y", | ||
"X_SUBPIXEL", | ||
"Y_SUBPIXEL", | ||
"X_SPEED", | ||
"Y_SPEED", | ||
"X_ACCEL", | ||
"Y_ACCEL", | ||
"SPRITE_FRAME", | ||
] as ParticleField[]; | ||
|
||
export const PARTICLE_FIELDS_ENUM = {} as { [key in ParticleField]: number }; | ||
for (let i = 0; i < PARTICLE_FIELDS.length; ++i) { | ||
PARTICLE_FIELDS_ENUM[PARTICLE_FIELDS[i]] = i; | ||
} | ||
|
||
export interface ParticleData { | ||
sprite: string; | ||
length: number; | ||
capacity: number; | ||
data: number[]; | ||
} | ||
|
||
export class ParticleComponent implements ParticleData { | ||
sprite: string; | ||
length: number; | ||
capacity: number; | ||
data: number[]; | ||
|
||
constructor(options?: Partial<ParticleData>) { | ||
this.sprite = ""; | ||
this.length = 0; | ||
this.capacity = 0; | ||
this.data = []; | ||
|
||
Object.assign(this, options); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Assets } from "../util/assets"; | ||
import { Stage } from "../util/stage"; | ||
|
||
export interface StageData { | ||
name: string; | ||
assets: Assets; | ||
stage: Stage; | ||
gravity: number; | ||
} | ||
|
||
export class StageComponent implements StageData { | ||
name: string; | ||
assets: Assets; | ||
stage: Stage; | ||
gravity: number; | ||
|
||
constructor(options?: Partial<StageData>) { | ||
this.name = ""; | ||
this.assets = new Assets(); | ||
this.stage = new Stage(0, 0); | ||
this.gravity = 0; | ||
|
||
Object.assign(this, options); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Assets } from "../util/assets"; | ||
|
||
export interface TilesetData { | ||
assets: { load(asset: string): any }; | ||
tileset: string; | ||
data: number[][]; | ||
} | ||
|
||
export class TilesetComponent implements TilesetData { | ||
assets: { load(asset: string): any }; | ||
tileset: string; | ||
data: number[][]; | ||
|
||
constructor(options?: Partial<TilesetData>) { | ||
this.assets = new Assets(); | ||
this.tileset = ""; | ||
this.data = []; | ||
|
||
Object.assign(this, options); | ||
} | ||
} |
Oops, something went wrong.