Shake Your Camera

You added the camera to the game so that you can follow Chip as he leaps his way out of the pit. By moving the camera, you show a region of the pit in Chip’s vicinity. In this section, you’ll take advantage of the camera and add a new feature to the game. Quakes happen randomly. When a quake occurs, the pit appears to shake, and a bunch of boulders rain down all at once. If Chip is near the top during a quake, he’d better move quickly to avoid the boulders. You don’t actually move Chip, the pit, or the platforms during a quake; you just shake the camera, and it looks like everything is shaking. At the same time, give each of the boulders already in the game a random shove, adding to the illusion.

Each quake lasts 30 frames, ...

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.