Commodore 128 Programmer's Reference Manual page 286

Hide thumbs Also See for 128:
Table of Contents

Advertisement

276
COMMODORE 128
Finally, line 80 completes the FOR . . . NEXT structure of the loop.
u
u
Line 97 is another time delay so the retro rocket, sprite 2, has time to move off
the screen.
Line 98 turns off sprite 2, once it is off the screen.
Line 99 is another delay so the capsule can continue to move across the screen.
Line 100 returns you to text mode.
SPRITE PROGRAM EXAMPLES
[I
The best way to create sprites is with SPRDEF. The following examples assume you
Lj
have created your sprites in SPRDEF mode.
The first example sprite program illustrates the use of the SPRITE and MOVSPR
f(
commands. It positions all eight sprites so they appear to converge on one screen
[J
location, then scatter in all eight directions. Here's the listing:
u
10 REM MOVE SPRITE EXAMPLE
20
FOR 1=1
TO 8
30 MOVSPR
1,100,100
40 NEXT
50
FOR 1=1
TO 8
\
,
60 SPRITE 1,1,1,1,1,1,0
70 MOVSPR 1,1*30 #1
LJ
80 NEXT
Lines 20 through 40 place all eight sprites at sprite coordinate location 100,100.
J I
At this point, the sprites are not yet enabled, but when they are, all eight are on top of
L)
one another.
Lines 50 and 60 turn on each of the eight sprites in eight different colors. The first
f |
"I" is the sprite number parameter. The first "1" in line 60 signifies the enabling of
M
each sprite. The second "I" specifies the color code for each sprite. The second "1"
(the fourth parameter) sets the display priority for all the sprites. A display priority of
one tells the C128 to display the sprites behind objects on the screen. A zero display
]
priority enables sprites to pass in front of objects on the text or bit-map screen. The fifth
and sixth parameters, both of which are ones (1), expand the sprites' size in both the
vertical and horizontal directions to twice their original size. The final parameter in the
j I
SPRITE statement selects the graphics display mode for the sprites; either standard
U
bit-map sprites (0) or multi-color bit-map sprites (1). In this example, the sprites are
displayed as standard bit-map sprites.
r /
Line 70 moves the sprites on the screen. The first parameter, I, represents the
jj
sprite number. The second parameter, "1*30", defines the angle at which the sprites
travel on the screen. The pound sign (#) notation signifies that the sprites move
according to a particular angle and speed. The final parameter "I" specifies the speed at
which the sprites travel on the screen. In this example, sprite 1 moves at the slowest rate
~
of 1, sprite 2 moves at the next highest speed of 2, while sprite 8 moves the fastest of
the eight sprites at speed 8. The highest speed a sprite can move is 15.
j I
u

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents