Help please find the reason why the game hangs. This is reflected in the inability to move the player's ship by more than 100px in any direction.
The main algorithm of the game is as follows: For each entity, a separate view has been created:
APP.SpaceView - содержит основную логику игры APP.InformerView - табличка, отображающая количество снарядов, жизненные силы, счёт и т.д. APP.InfolineView - бегущая строка с разной информацией APP.FieldView - игровая область(в ней летают корабли протвника, корабль игрока и звёзды) APP.PlayerShipView - корабль игрока APP.PlayerRocketView - снаряды игрока APP.StarView - звёзды на фоне Most of the logic is in APP.SpaceView and is organized as follows: When initializing this view, the main game loop is started, in which coordinates and conditions for each game object are calculated:
setInterval(function() { self._makeMoves(self) }, 100); in _makeMoves () are calculated: the movements of the stars (enumeration of the entire collection), the movement of the player’s projectiles tracked keystrokes responsible for moving the player’s ship and shooting
That is, every 0.1 seconds, a fairly large number of operations are calculated. But I do not think that the reason for the brakes of the game in this. First of all, because there are not so many calculations (8GB RAM). Secondly, because I made a similar game in the same way (on pure js) and also with a considerable amount of object and there was not even a hint of a hang
Please help me find the cause of the hang
requestAnimationFrameand make normal games. And if you are too lazy to write from scratch, use any of the game engines . - hindmost