TI99 Environment

# TI_SPRITE Properties(ASCII,COLOR,XVEL,YVEL,XDIR,YDIR,SIZE,EXIST,MULTICOLOR)

Syntax

integer-variable = TI_SPRITEASCII(sprite-number)

integer-variable = TI_SPRITECOLOR(sprite-number)

integer-variable = TI_SPRITEXVEL(sprite-number)

integer-variable = TI_SPRITEYVEL(sprite-number)

integer-variable = TI_SPRITEXDIR(sprite-number)

integer-variable = TI_SPRITEYDIR(sprite-number)

integer-variable = TI_SPRITESIZE(sprite-number)

integer-variable = TI_SPRITEEXIST(sprite-number)

integer-variable = TI_SPRITEMULTICOLOR(sprite-number)

Description

The TI_SPRITEASCII function returns the ASCII code assigned to a specific TI-99 sprite-number. integer-variable holds the ASCII code of the sprite being checked. Double-sized sprites (sprites consisting of four consecutive ASCII characters) return the ASCII code of the main (top-left) sprite. The TI_SPRITECOLOR function returns the foreground color assigned to a specific TI-99 sprite-number. integer-variable holds the color code (0-16) of the sprite being checked. Multicolor sprites will return a value of 0. The TI_SPRITEXVEL function returns the X velocity assigned to a specific TI-99 sprite-number. integer-variable holds the x velocity (-128 to 127) of the sprite being checked. Stationary sprites in the x axis return a value of 0. The TI_SPRITEYVEL function returns the Y velocity assigned to a specific TI-99 sprite-number. integer-variable holds the y velocity (-128 to 127) of the sprite being checked. Stationary sprites in the y axis return a value of 0. The TI_SPRITEXDIR function returns the X direction of a specific TI-99 sprite-number. integer-variable holds the x direction (-1 for left, 0 for stationary, 1 for right) of the sprite being checked. The TI_SPRITEYDIR function returns the Y direction of a specific TI-99 sprite-number. integer-variable holds the y direction (-1 for up, 0 for stationary, 1 for down) of the sprite being checked. The TI_SPRITESIZE function returns the magnification (size) value assigned to a specific TI-99 sprite-number. integer-variable holds the size of the sprite being checked. Possible values are 1-4. Refer to the CALL_MAGNIFY function help for details about the meaning of the size values. The TI_SPRITEEXIST function checks if the sprite-number is active. A value of 1 indicates an active (existing) sprite. A value of 0 means that the sprite has not been created or has been deleted from memory. The TI_SPRITEMULTICOLOR function checks if the sprite-number is a multicolor sprite. A value of 1 indicates a multicolor sprite. A value of 0 means that the sprite is a regular, single-color sprite.

Example Code

    Example 1:TI_SPRITEASCII,COLOR,XVEL,YVEL,SIZE

    ` Test TI_SpriteASCII,Color,Xvel,Yvel,Size - Check sprite properties
    call_screen(16)
    call_char(36,"ff" + rpt$("80",14) + "ffff" + rpt$("01",14) + "ff")        ` sprite image definition for secondary sprites
    randomize timer()
    A = RND(10) + 5     ` select random vertical velocity of secondary sprites
    CALL_SPRITE(1,36,rnd(12)+2,96,128,rnd(100)-RND(100),rnd(100)-rnd(100)) : ` sets main sprite in horizontal and vertical motion
    call_sprite(2,36,rnd(12) + 2,8,150,A,0) : call_sprite(3,36,rnd(12) + 2,72,150,A,0) : call_sprite(4,36,rnd(12) + 2,136,150,A,0) : call_sprite(5,36,rnd(12)+ 2,200,150,A,0) ` sets secondary sprites in vertical motion only
    tiwait(50)
    do        ` Main program loop
        display_at(1,1,"ASCII:" + str$(mob(1).origmobascii)+ ":" + chr$(mob(1).origmobascii),0)
        display_at(2,1,"SPR ASCII:" + str$(TI_SPRITEASCII(1))+ ":" + chr$(TI_SPRITEASCII(1)),0)
        display_at(5,1,"COLOR:" + str$(TI_SPRITECOLOR(1)),0)
        display_at(6,1,"X-VEL:" + str$(TI_SPRITEXVEL(1)),0)
        display_at(7,1,"Y-VEL:" + str$(TI_SPRITEYVEL(1)),0)
        display_at(8,1,"SIZE:" + str$(TI_SPRITESIZE(1)),0)
        posx = call_positionx(1)                            ` check main sprite's current x position
        posy = call_positiony(1)                            ` check main sprite's current y position
        display_at(3,1,"X:" + str$(posx),0)
        display_at(4,1,"Y:" + str$(posy),0)
        repeat
            k = call_key(0,k,s)                        ` keeps all sprites in motion while waiting for key press,
            coinc = call_coincall()                    ` check for collision between test sprite and the other sprites
            if coinc
                 display_at(9,1,"**COLLISION**",0)     ` display message and change screen color when main and secondary sprites collide
                 call_screen(15)
                 tiwait(750)
                 display_at(9,1,"",0)
                 call_screen(16)
            ENDIF
            ti_sync()
        until tikeystatus = 1                                    ` when any key is pressed...
        call_locate(1,rnd(128)+32,rnd(192)+32)                     ` changes location of sprite
        call_motion(1,rnd(100)-rnd(100), rnd(100)-rnd(100))     ` changes sprite velocity
        call_colorsprite(1,rnd(12)+2)                             ` changes sprite color
        call_pattern(1,rnd(93)+33)                                ` changes sprite pattern to an image of a random ascii character
        call_magnify(rnd(3)+1)                                     ` changes size of all sprites
    loop

    Example 2:TI_SPRITEEXIST

    ` This program displays a number of moving sprites and then magnifies and deletes them randomly
    randomize hitimer()
    numsprites = 20
    call_screen(2)
    for i=1 to numsprites
       repeat
          cl = rnd(14)+2
       until cl <> 8
       call_sprite(i,42,cl,rnd(255)+1,rnd(255)+1,rnd(10)-5,rnd(10)-5)
    next i
    repeat
       tiwait(500)
       repeat
          a = rnd(numsprites) + 1
       until a <= numsprites
       if TI_SPRITEEXIST(a)
          call_magnifysprite(a,2)
          call_colorsprite(a,16)
          tiwait(3000)
          call_delsprite(a)
       endif
    until TIE_Activesprites = 0

    Example 3:TI_SPRITEXDIR, TI_SPRITEXDIR, TI_SPRITEMULTICOLOR

    ` Test functions TI_SpriteXDir, TI_SpriteYDir, TI_SpriteMulticolor
    call_magnify(2)
    a$ = "0055550009C99C9009999990000990009EEEEEE9000EE00000FEEF000FF00FF"
    a$ = a$ + rpt$("0",256 - fast len(a$))
    call_multicolorchar(128,a$)
    do
       call_sprite(1,42,2,rnd(192),rnd(256),rnd(50) - 20, rnd(50) - 20)
       call_sprite(2,128,0,rnd(192),rnd(256),rnd(50) - 20, rnd(50) - 20)
       display_at(12,1,"TI_SpriteMulticolor(1):" + str$(TI_SpriteMulticolor(1)),0)
       display_at(13,1,"TI_SpriteXDir(1):" + str$(TI_SpriteXDir(1)),0)
       display_at(14,1,"TI_SpriteYDir(1):" + str$(TI_SpriteYDir(1)),0)
       display_at(16,1,"TI_SpriteMulticolor(2):" + str$(TI_SpriteMulticolor(2)),0)
       display_at(17,1,"TI_SpriteXDir(2):" + str$(TI_SpriteXDir(2)),0)
       display_at(18,1,"TI_SpriteYDir(2):" + str$(TI_SpriteYDir(2)),0)
       display_at(24,1,"Press any key to restart",0)
       tiwaitkey()
    loop

Go back to ...

TI99E Commands Menu
Main Menu

Copyright © Carlos Santiago Lebron - TI99 Environment 2020