Reputation: 4048
This is a very simple game I'm trying to write but I have a really bad performance problem.
I'm not using an HTML5 Canvas—just plain javascript—so that may be the problem.
Here's the game: http://ivcdn.net/aga2/dead.html
Currently I'm using divs as game objects. And to move them, I increase or decrease their position on the page (and they're all positioned absolute). But (I think) doing so is causing serious performance issues.
What can I do to increase performance? And do I have have any other options than to use HTML5 and/or a better language?
Upvotes: 0
Views: 186
Reputation: 25763
One suggestion to improve performance in that would be instead of moving each individual div, move the container of the divs instead. That way you're only moving one thing instead of many.
Also limit how many setTimeout calls you're making. Ideally make one that encompasses all your game logic, and at the end of that game logic, call setTimeout again to call itself (provided the game is not over).
Upvotes: 1