Balloon Script SECTION 7 Script Example
121
SECTION 7
Script Example
This chapter provides an example application for a script. The script is a
typical script exercising the basic commands. It is described twice, once as a
whole, and once on a line by line basis.
7-1 Balloon Script
The following script applies to a simple game.
The user must attempt to land the balloon on the plateau on the right, using
the Max/Min slider control throughout the flight. Clicking Reset clears the
current game and initialises a new game. Clicking the on/off pushbutton starts
the game.
When the balloon is airborne, clouds move slowly horizontally and change
colour slightly. Clicking Help at any time brings up a special help page;
clicking Close from this help page returns the user to the game. The blue
gauge shows the amount of fuel consumed and left.
The project consists of three page scripts and one object. The three page
scripts are initiated at varied intervals: 10 milliseconds, 100 milliseconds and
1000 milliseconds.
The page script initiated at intervals of 10 milliseconds determines the position
of each cloud, and the speed at which each cloud moves. The page script
initiated at intervals of 1000 milliseconds determines how the balloon reacts to
the conditions.
The page script initiated at intervals of 100 milliseconds provides the main
configuration of the game, reacting to user input and moving the balloon
accordingly. This page script is as follows:
IF burner AND alt > 400.0 THEN
burner = FALSE
ENDIF
IF burner THEN
fuel = fuel - rate
IF fuel < 0.0 THEN
fuel = 0.0
burner = FALSE