TI99 Environment

CALL_SPRITE


Syntax

CALL_SPRITE(sprite-number,ascii-code,forecolor,y,x,yspd,xspd)

Description

The Call_Sprite function builds sprites out of regular or redefined ASCII characters and optionally sets them in auto-motion when velocity parameters yspd, xspd are non-zero. The background color of a sprite is always transparent.

Function parameters and valid values:
sprite-number = integer value between 1 and maxsprites indicating the sprite number.
ascii-code = integer value between 32 and endchar indicating the ASCII code associated to the sprite.
forecolor = integer value between 1 and 16 indicating the foreground color of the sprite. Enter 0 for multicolor sprites.
y, x = integer values between 1 and 256 indicating the sprite's initial y,x coordinates on the screen. Y-values beyond 192 will place a sprite out the visible area, but it will still be active and trigger collisions.
yspd, xspd = integer values between -128 to 127 indicating the sprites vertical and horizontal velocity. Positive x values set horizontal sprite motion to the right; negative values set sprite motion to the left. Positive y values set vertical sprite motion down; negative values set sprite motion up.

Note: The values for maxsprites and endchar are constants set at the beginning of the program during initialization and can be adjusted to fit your needs.

Note: To keep sprites in auto-motion, use the ti_sync() function in your program loop. The functions TI_Wait() and TIWaitkey() also preserve sprites in motion and should be used instead of the built-in wait and wait key commands, which will stop sprite motion.

  Example Code
Example 1:

call_screen(2)
randomize perftimer()
for i = 1 to 32
    CALL_SPRITE(i,42,rnd(13) + 3,96,128,rnd(60)-30,rnd(70)-35) ` Displays sprites
    tiwait(250)
next i
do : ti_sync() : loop


Example 2:
`Sprite Priority Demo
randomize timer()
call_screen(2)
call_magnify(3)
call_char(128,rpt$("f",64))
strtcolor = 3 : endcolor = 16
color=strtcolor
FOR I = 2 TO 8 : CALL_COLOR(I,16,2) : NEXT I
display_at(1,1,"TI-99 SPRITE PRIORITY TEST",0)
display_at(13,1,"SPRITES ALWAYS OVERLAP TEXT",0)
display_at(14,1,"PRESS ANY KEY TO START",0)
TIWAITKEY()
CALL_HCHAR(2,1,32,736)
display_at(13,1,"LOWER NUMBERED SPRITES",0)
display_at(14,1,"OVERLAP THE HIGHER NUMBERED",0)
for i = 1 to 28
    CALL_SPRITE(i,128,color,96,i * 8 - 7,0,0,)
    inc color
    if color > endcolor then color = strtcolor
next i
` Lower-numbered sprites overlap higher numbered sprites
for i = 1 to 28; call_magnifysprite(i,4)
    for xx = i * 8 - 7 to 256 step 3 : call_locate(i,96,xx) : ti_sync() : next xx    
    call_delsprite(i) : TIWAIT(250)
NEXT i
display_at(15,1,"PRESS ANY KEY",0)
TIWAITKEY()
CALL_HCHAR(2,1,32,736)
display_at(13,1,"HIGHER NUMBERED SPRITES",0)
display_at(14,1,"PASS UNDER THE LOWER ONES",0)
display_at(15,1,"PRESS ANY KEY",0)
TIWAITKEY()
CALL_HCHAR(15,1,32,32)
call_magnify(3)
for i = 1 to 28
    CALL_SPRITE(i,128,color,96,i * 8 - 7,0,0,)
    inc color
    if color > endcolor then color = strtcolor
next i
` Higher-numbered sprites pass under the higher numbered sprites
for i = 28 to 1 step - 1 : call_magnifysprite(i,4)
    for xx = 256 to 1 step -3  : call_locate(i,95,xx) : ti_sync() : next xx     
    call_delsprite(i) : TIWAIT(250)
NEXT i
display_at(15,1,"PRESS ANY KEY",0)
tiwaitkey()
end

Go back to ...

TI99E Commands Menu
Main Menu

Copyright © Carlos Santiago Lebron - TI99 Environment 2020