-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
4afe228
commit c58cd08
Showing
9 changed files
with
65 additions
and
13 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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Engine, Vector } from "excalibur"; | ||
import BaseSoldier from "../soldier/base_soldier"; | ||
import { SoldierResources } from "../soldier/resources"; | ||
|
||
export interface EnemySoldierParams { | ||
pos: Vector; | ||
} | ||
|
||
class EnemySoldier extends BaseSoldier { | ||
constructor({ pos }: EnemySoldierParams) { | ||
super({ | ||
pos, | ||
spriteImageSource: SoldierResources.EnemySprites, | ||
}); | ||
} | ||
|
||
public soldierInput() { | ||
/* | ||
move right: this.direction = 1; this.isRunning = true; | ||
move left: this.direction = -1; this.isRunning = true; | ||
stop moving: this.isRunning = false; | ||
shoot this.activeWeapon?.shoot(); | ||
*/ | ||
|
||
// move for 200px to the right and then to the left | ||
const baseX = 250; | ||
this.isRunning = true; | ||
if (this.direction === 1 && this.pos.x > baseX + 200) { | ||
this.direction = -1; | ||
} else if (this.direction === -1 && this.pos.x < baseX) { | ||
this.direction = 1; | ||
} | ||
} | ||
|
||
public onDie() {} | ||
|
||
public onInitialize(engine: Engine) { | ||
super.onInitialize(engine); | ||
// TODO: remove this | ||
(window as any).player = this; | ||
} | ||
} | ||
|
||
export default EnemySoldier; |
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
File renamed without changes.
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
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