O'Reilly logo

Learn Game Programming with Ruby by Mark Sobkowicz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required