ZZT-oop

ZZT-oop was an early in-game scripting programming language, designed by Tim Sweeney, for his computer game ZZT. The name stands for ZZT Object Oriented Programming language.

Overview

ZZT-oop is event-driven. A ZZT game is composed of a set of objects, each of which has an attached script. Scripts are executed concurrently (one command being taken in turn from each script running on the current screen), and objects communicate by passing messages to one another.

Peculiarities and limitations

Shortcomings

The ZZT-oop language is limited in application. It was designed for simplicity rather than flexibility. Boolean flags are the only kind of variables, making arithmetic quite difficult; the programmer is forced to be creative with algorithms, often relying on physical movement, possibly in invisible (but still physically present) objects, rather than arithmetic calculations.

Although ZZT-oop calls itself "object-oriented", objects are not instantiable due to their physical nature, meaning that one needs to duplicate much code to create complex systems.

ZZT-oop also lacks functions, and routines are likely to be interrupted by rogue messages — including ones sent by the object itself when it is shot or touched — and never completed. It is possible to overcome this disadvantage in a crude manner by using state flags or the lock and unlock commands during important routines; however, this is likely to cause the object to miss out on signals.

ZZT-oop is wholly run-time interpreted with no pre-parsing. No lexical analysis is performed before running, nor is any byte code translation applied. This means that any errors are reported in a cryptic way during run-time, and this can make debugging time consuming.

ZZT was intended for creating adventure games with multiple "boards" (that is, locations), but ZZT-oop does not have any way of creating state that persists from one board to the next, with the exception of boolean variables. A board's objects are only accessible while the player is on that board, and pause on board exit until the player reenters.

Strengths

The language has some advantages:

Syntax

The syntax of the language is exceedingly simple. It is line-based, and the first character of each line determines that line's effect.

Example

The program below illustrates a simple "shooter" object that will move back and forth horizontally (east to west), periodically shooting downward (to the south). (If the player is shot, the player will lose health.) If the player touches the shooter, the shooter will be destroyed.

Note the use of an invisible "timer" object to send a periodical ShootDownward message to the Shooter. The timer's program would normally be attached to an object whose graphical representation was the same as a wall (character number 219); then, it would go completely unnoticed by the player, since it does not move and turns into a real wall when its program ends.

@Shooter
#GO WEST
:TurnAround
#GO OPP FLOW
:KeepMoving
?FLOW
#IF BLOCKED FLOW THEN TurnAround
#SEND KeepMoving
:Touch
'No need to keep the timer around anymore
#SEND InvisibleTimer:Die
#DIE
:ShootDownward
#SHOOT SOUTH
#SEND KeepMoving
@InvisibleTimer
'The #CYCLE command sets the rate at which this object is updated.
#CYCLE 40
:Loop
#SEND Shooter:ShootDownward
#SEND Loop
:Die
'Turn into a red wall
#BECOME RED SOLID

External links


References

    This article is issued from Wikipedia - version of the 1/11/2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.