Commit 872e687d authored by wildfirecode13's avatar wildfirecode13

init

parent 8598e278
import MovableManager from "../lib/MovableManager";
import Vector2 from "../lib/Vector2";
import Enemy from "./Enemy";
export default class EnemyFactory {
private _timer;
constructor() {
this._timer = setInterval(this.onTimer, 10 * 1000)
private _stage: FYGE.Stage;
movableManager: MovableManager
constructor(stage: FYGE.Stage, movableManager: MovableManager) {
this.movableManager = movableManager;
this._stage = stage;
this._timer = setInterval(this.onTimer, 1000)
}
onTimer = () => {
const enemy = this._stage.addChild(new Enemy(this.movableManager));
enemy.position.set(Math.random() * 300 + 200, 0);
enemy.velocity = new Vector2((Math.random() - 0.5) * 2, Math.random() * 5 + 2);;
}
destroy() {
......
......@@ -3,6 +3,7 @@ import DragDropManager from "../dragdrop/DragDropManager";
import MovableManager from "../lib/MovableManager";
import Vector2 from "../lib/Vector2";
import Enemy from "./Enemy";
import EnemyFactory from "./EnemyFactory";
import Hero from "./Hero";
......@@ -13,9 +14,7 @@ export function addGame(stage: FYGE.Stage) {
const hero = stage.addChild(new Hero(movableManager)) as DragDropable;
hero.position.set(300, 1000);
const enemy = stage.addChild(new Enemy(movableManager));
enemy.position.set(0, 0);
enemy.velocity = new Vector2(4, 1);
const enemyFactory = new EnemyFactory(stage,movableManager);
dragDropManager.add(hero);
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment