Learn Create Your Own Split Screen

Next Page

How to make this happen?

First, we're going to define a new method for the sprite that makes it point toward a given x,y coordinate.

We haven't yet figured out how it's going to achieve this, but we know there's going to be a method.

MySprite.prototype.Point_Towards = function(target_x, target_y) { // Make the sprite point at the coordinates -- haven't figured this out yet }

Then, whenever we render a frame, we're going to make sure the jellyfish is pointing to wherever the mouse-pointer is.

function Do_a_Frame () { ctx.clearRect(0, 0, myCanvas.width, myCanvas.height); // clear the frame jelly.Point_Towards(mouse_x, mouse_y); // tell jelly to point to mouse jelly.Do_Frame_Things(); // let the jelly do its thing }