Learn Create Your Own Split Screen

Next Page

First we add a property to the sprite: a number that indicates how rotated the image should appear.

We'll make it so an angle of zero means the image isn't rotated at all. Positive numbers rotate clockwise; negative anti-clockwise.

function MySprite (img_url) { this.x = 0; this.y = 0; this.visible= true; this.velocity_x = 0; this.velocity_y = 0; this.MyImg = new Image(); this.MyImg.src = img_url ; this.angle= 0; // How many degrees we are rotated }