Showing posts with label game. Show all posts
Showing posts with label game. Show all posts

Tuesday, 7 December 2010

html5 canvas speed notes

Setting fill and Stroke style can have a negative performance impact even if you dont use them and are setting them to what they used to be. (Firefox)

ctx.fillStyle
ctx.strokeStyle



Also I can't make dirty rectangles code run as fast as just doing a big clearRect for the whole canvas. This is for frantic - a space invaders style game where nearly every sprite will have moved since the last paint

ctx.clearRect(0,0,width,height);


Drawing text on canvas:
fillText about twice as fast as strokeText

Sunday, 21 November 2010

JS Game programming main loop

Use this piece of JS to repeatedly call update() method every 10ms.

Handy for game loops!

setInterval(update, 10);


http://www.elated.com/articles/javascript-timers-with-settimeout-and-setinterval/

Full breakout game guide with keypress, mouse & animation