Move the Ruby

What do we mean, in a game like this one, when we say we want to move something? A video game is like a movie in that it basically fools the user into seeing motion by showing a rapid sequence of pictures in which some things are in a slightly different position. We call these pictures frames. If an image on our screen changes position too far between one frame and the next, it doesn’t look like it is moving; it looks like it is jumping around.

Velocity

To give the ruby image the appearance of smooth motion, you can change its position by the same amount every frame. This amount is called the velocity. To move the ruby in the horizontal direction, change the value of @x. To move it in the vertical direction, change the value of ...

Get Learn Game Programming with Ruby now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.