Learn Create Your Own Split Screen

Next Page

Some people think rectangles aren't very exciting.

It's not much harder using an interesting image instead of a boring rectangle.

In Javascript, images are held in variables. We declare and load the image like so:

var MyImg = new Image(); MyImg.src = "http://s2js.com/img/etc/cat_grumpy.png";

You only have to declare and load the image once, then you can draw it as many times as you like:

ctx.drawImage(MyImg, 130, y_pos);