Learn Create Your Own Split Screen

Next Page

Remember when we wrote the "bug catching melons" game ? We had something like this:
var bug_x = 0; var bug_y = 0; var BugImg = new Image(); BugImg.src = "http://s2js.com/img/etc/ladybug.png";

And also something like this

var melon_x = 0; var melon_y = 0; var MelonImg = new Image(); MelonImg.src = "http://s2js.com/img/etc/melon.png";

Imagine how tedious that would be if we wanted five different types of sprite in our game. Surely there has to be a better way.