Optimizing Wes Mantooth

Fri, 08/04/2017 - 22:13

The whole idea behind this project has never been to create games. It was really an exercise to optimize my Javascript abilities. Generally at work if I write Javascript it's using jQuery and due to time constraints it can often be quite ugly and not very efficient. 

So I built a list of tools I felt would be necessary for a game engine and currently they aren't exactly efficient or easy to use.

For example the multi-canvas example currently can run about 60 objects on screen before it starts to slow down. .. That's terrible.

But I plan to change that and so I built a section for running bench tests.

The best way to do this is to rebuild the various parts of the tool in smaller code to find where the bottle necks are.

For example this latest version of the multi-canvas animation can run 600 balls at 60 FPS


Some of the changes I made to optimize the code included:

  • Avoiding declaring variables inside loops
  • Prototyping functions where possible to keep recursion to a minimum
  • Flattening float numbers into integers
  • And I hate to say it, because I like organizing my code into classes, but there is a lot of buzz about using more procedural methods versus OOP and, some of what I have heard makes sense...So I'll be taking that into consideration.

Once I finished optimizing the balls I decided to add a z coordinate for fun.