Learn Create Your Own Split Screen

Next Page

The drawing context includes the ability to save and restore its status.

This is much better than remembering to "undo" things later

ctx.save(); ctx.rotate(this.angle * Math.PI / 180); // rotate if (this.visible) ctx.drawImage(this.MyImg, this.x, this.y); // draw ctx.restore();

We take a snapshot of the drawing context settings, we rotate and draw (and will end up doing other things too), then when we're done we restore the state of the drawing context so anything subsequent that gets drawn won't be affected by our fiddling.

It's still not rotating properly, but we've got a tidier architecture in which to work.