Learn Create Your Own Split Screen

Next Page

But it gets even better.

We can also add behaviours (called methods) to our object.

Every sprite in our program is going to need to draw itself for each frame, so we add the drawing behaviour as a method of MySprite.

Then, in our Do_a_Frame function, we can just call:

bug.Do_Frame_Things();

Notice that our MySprite definition also includes velocity_x and velocity_y properties, and the Do_Frame_Things method also automatically takes care of adjusting the x and y positions based on the velocity.

In a later lesson, we'll add gravity and bounciness to our MySprites, and the really cool thing is that we only have to add it in one place, and all our MySprites automatically get it.