Hi, i don't know if someone can help me with this.. but i will try, i'm making a html 5 game with a friend with socket.io, p5 and angular as frontend, i know that angular is not the best for this but i know i will have to handle the same error in node.js.
Stage.ts
Player.ts
Weapon.ts
So the circular dependency is: Stage.ts -> Player.ts -> Weapon.ts -> Stage.ts
I don't want to pass stage reference's to all the classes that use stage.js, it would destroy singleton pattern...
Stage.ts
Code:
// Singleton have methods like addEntityToWorld, removeEntity, mainUpdate,
static get Instance() {
if (Stage._instance === undefined) {
Stage._instance = new Stage();
}
return Stage._instance;
}
function mainRender(){
this.mainPlayer.render();
for(let e of this.entities){
e.render();
}
}
Code:
//have methods render(),update()
...
constructor(){
this.weapon = new Weapon();
}
...
Code:
...
function fire(){
...
Stage.Instance.addEntityToWorld(new Bullet(...))
...
}
...
I don't want to pass stage reference's to all the classes that use stage.js, it would destroy singleton pattern...