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 { export default class EnemyFactory {
private _timer; private _timer;
constructor() { private _stage: FYGE.Stage;
this._timer = setInterval(this.onTimer, 10 * 1000) movableManager: MovableManager
constructor(stage: FYGE.Stage, movableManager: MovableManager) {
this.movableManager = movableManager;
this._stage = stage;
this._timer = setInterval(this.onTimer, 1000)
} }
onTimer = () => { 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() { destroy() {
......
...@@ -3,6 +3,7 @@ import DragDropManager from "../dragdrop/DragDropManager"; ...@@ -3,6 +3,7 @@ import DragDropManager from "../dragdrop/DragDropManager";
import MovableManager from "../lib/MovableManager"; import MovableManager from "../lib/MovableManager";
import Vector2 from "../lib/Vector2"; import Vector2 from "../lib/Vector2";
import Enemy from "./Enemy"; import Enemy from "./Enemy";
import EnemyFactory from "./EnemyFactory";
import Hero from "./Hero"; import Hero from "./Hero";
...@@ -13,9 +14,7 @@ export function addGame(stage: FYGE.Stage) { ...@@ -13,9 +14,7 @@ export function addGame(stage: FYGE.Stage) {
const hero = stage.addChild(new Hero(movableManager)) as DragDropable; const hero = stage.addChild(new Hero(movableManager)) as DragDropable;
hero.position.set(300, 1000); hero.position.set(300, 1000);
const enemy = stage.addChild(new Enemy(movableManager)); const enemyFactory = new EnemyFactory(stage,movableManager);
enemy.position.set(0, 0);
enemy.velocity = new Vector2(4, 1);
dragDropManager.add(hero); 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