Example 1: The first example is a very simple program that demonstrates the skeleton of a program based on BETATRON. The program creates a world 62x52 tiles and then lets the user scroll the view window in that world. The program takes as an argument the desired video mode which can be 0 (gmMODEX320x200) ,for modex 320x200, or any supported VESA 2.00 video mode number. For example: C:\> ex1 257 will try to use 640x480x256 VESA 2.00 video mode. To see VESA 2.00 modes your video card must support VESA 2.00 or you must have a VBE2 driver such as UNIVBE. Notice the use of exitaction(). This action funtion is called in every frame by TOworld::animate(). Notice how this function informs animate() to return by setting the 'exitbit' field of its owner TOworld object to 1. The code should be self-explanatory because of all those comments. However you may wonder what is CHECK(). CHECK() is a macro that takes a single argument. If that argument is negative then CHECK() displays an error message and calls 'exit(1)' else it does nothing. CHECK() is designed to be used with all BETATRON functions that return a negative number as an error code. There are also some other BETATRON functions that return FALSE (0) as failure and TRUE as success. CHECK() can't be used with the latter ones. You should always use CHECK() or check yourself what a function returns because in many cases you can't continue if a function fails. For example TOworld::animate() cannot be succesfully executed if TOworld::initmode() or TOworld::setmode() fail. The order in which the various methods are called is important. This example demonstrates an apropriate order that you should follow.