Learn Create Your Own Split Screen

Next Page

We will set up our watermelon "sprite" as before: declaring a couple of variables to hold the x & y position, an image variable, and load the image itself. Routine stuff, but for a watermelon instead of a bug.

We also add an extra line to our Do_a_Frame function to draw the image at the appropriate coordinates:

ctx.drawImage(MelonImg, melon_x, melon_y);