Use a Camera

In this new version of Escape, the pit is much bigger than your game window. You make the pit a square 1600 pixels on a side, while the window is 800 pixels square, so you see only one quarter of the game inside the window at any one time. The part of the game space you’ll show will depend on Chip’s location.

images/sidescroller/camera_window.png

It’s as if a camera is following Chip around as he climbs out of the pit. When Chip gets close to an edge of the pit, or to the top or bottom, the camera doesn’t follow him in the same way. Instead, the camera stops so that the whole camera view remains inside the pit.

The Camera Class

Start by making a copy of the Escape folder ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.