gamedev-patterns-ts
gamedev-patterns-ts copied to clipboard
window.requestAnimationFrame = jest.fn().mockImplementationOnce((cb) => cb()) fails the unit test
In Game Loop Part 2 of your tutorial neglects to mention the following in the game
public Awake(): void{
//Components
this.AddComponents(new GameInputComponents())
super.Awake()
//Child entities
for(const entity of this.Entities){
entity.Awake()
}
window.requestAnimationFrame(() => {
this._lastTimeStamp = Date.now()
this.Update()
})
// Remove
this.Update()
// Remove
}
Not removing the this.update() from your Awake() method in game.ts causes the mockImplementation to continuously do a range out of bounds as it is, essentially a forever loop.
Cheers for the guide tho! I've only done Game Dev in Unity and.. This is much more hands on.