forked from dolanmiu/flappy-bird-client
-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
5 changed files
with
96 additions
and
4 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
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 @@ | ||
namespace Flappy { | ||
/*export class PipePool<T> extends Phaser.Group { | ||
constructor(game: Phaser.Game, spriteType: T, instances: number, name: string) { | ||
super(game, game.world, name); | ||
this.game = game; | ||
this.spriteType = spriteType; // Needed when creating new objects in the pool | ||
if (instances > 0) { // We don't need to add anything to the group | ||
let sprite; | ||
for (var i = 0; i < maxInstances; i++) { | ||
sprite = this.add(new spriteType(game)); // Add new sprite | ||
} | ||
} | ||
return this; | ||
} | ||
public create(x: number, y: number, data) { | ||
// Find the first child that has a false exist property: | ||
let obj = this.getFirstExists(false); | ||
if (!obj) { | ||
// We failed to find an availble child, so we create one now and add it to the pool. | ||
obj = new this.spriteType(this.game); | ||
this.add(obj, true); | ||
} | ||
// We call the childs spawn method and return the object to whatever triggered this. | ||
// The spawn method will handle stuff like position, resetting the health property | ||
// and setting exists to true. The spawned object will live even if the returned | ||
// reference is ignored | ||
return obj.spawn(x, y, data); | ||
} | ||
}*/ | ||
} |
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,18 @@ | ||
namespace Flappy { | ||
export class PipeSet extends Phaser.Group { | ||
|
||
constructor(game: Phaser.Game, x: number, y: number, gapSize: number, pipeBodyKey: string, pipeDownCapKey: string, pipeUpCapKey: string) { | ||
super(game); | ||
let upPipe = new UpPipe(game, x, y + gapSize, pipeBodyKey, pipeUpCapKey); | ||
let downPipe = new DownPipe(game, x, y, pipeBodyKey, pipeDownCapKey); | ||
|
||
this.add(upPipe); | ||
this.add(downPipe); | ||
//this.game.add.existing(this); | ||
} | ||
|
||
public update(): void { | ||
this.x -= 1; | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -16,6 +16,9 @@ | |
], | ||
"no-namespace": [ | ||
false | ||
], | ||
"max-line-length": [ | ||
false | ||
] | ||
} | ||
} |