HTML5 Canvas and Game Programming

Posted by LemonBeagle on Stack Overflow See other posts from Stack Overflow or by LemonBeagle
Published on 2012-06-09T14:26:45Z Indexed on 2012/06/09 16:40 UTC
Read the original article Hit count: 162

Filed under:
|
|

I hope this isn't too open ended.

I'm wondering if there is a better (more battery-friendly) way of doing this --

I have a small HTML 5 game, drawn in a canvas (let's say 500x500). I have some objects whose positions I update every 50ms or so. My current implementation re-draws the entire canvas every 50ms. I can't imagine that being very good for battery life on mobile platforms.

Is there a better way to do this? This must be a common pattern with games.

EDIT:

as requested, here are some more updates:

Right now, the objects are geometric primitives drawn via arcs and lines. I'm not opposed to making these small png/jpg/gif files instead of that'd help out. These are small graphics -- just 15x15 or so.

As the game progresses, more and more of the screen changes at a time. However, at the start, the screen changes relatively slowly (the objects randomly moved a few pixels every 50ms).

© Stack Overflow or respective owner

Related posts about html5

Related posts about game-development