home *** CD-ROM | disk | FTP | other *** search
- THE WALKER
-
- by Captain COMAL
-
- There is no need to be frightened of
- sprites. COMAL adds simple commands
- to easily control all 8 sprites at
- once. WALKER is a simple program that
- animates a sprite using 4 shapes. Try
- the program. Watch the WALKER hobble
- across the screen. COMAL is so fast
- that a pause routine is added to slow
- the WALKER down.
-
- The whole program is merely 5 lines
- long. Well, actually more if you
- count all the procedures too. It
- takes advantage of COMAL's modular
- nature, and sets up procedures to
- perform the several routines needed.
- The first one is called SETUP. As you
- might guess it sets up things for the
- program. Before setting up the sprite
- colors and size the SETUP procedure,
- calls DEFINE'IMAGES. Now, that is
- where the sprite shapes are
- determined - all four of them.
-
- Sprite images are defined by a 63
- byte string, just as in BASIC. But
- COMAL does all the work. DEFINE puts
- the images in a special reserved area
- of memory for you! No PEEK or POKE
- needed. Then IDENTIFY lets any sprite
- use any of the defined shapes at any
- time, even simultaneously. But why
- use a 64 byte string to DEFINE our
- shapes? Only 63 are for the shape
- itself! If the 64th byte is a CHR$(0)
- it tells COMAL that the sprite is
- Hi-Res. Otherwise the sprite will be
- Multi-Color (like in this program).
- Lines 240-260 show how easy it is to
- set up the colors for our sprites, as
- well as to choose to expand their
- size.
-
- The rest of the program is a simple
- REPEAT loop. It continues WALKING
- until you press the Q key. WALKING
- keeps moving our sprite across the
- screen while animating the images.
- SPRITEPOS in line 520 changes its
- position while IDENTIFY in line 530
- gives it an image. Then line 540
- pauses a bit. Change the (30) to
- something smaller for a shorter
- pause. Remove the line altogether for
- some really fast walking.
-
- Finally, notice the use of MOD in
- lines 510 and 530. It does a division
- and throws away the answer. The only
- thing it remembers is the remainder.
- Thus 9 MOD 4 is 1, the remainder of 9
- divided by 4. This is a convenient
- way to have images cycle by fours.
-