TI99 Environment

# CALL_DISTANCEXY

Syntax

integer-variable = CALL_DISTANCEXY(sprite1,y,x)

Description

The CALL_DISTANCEXY function returns the distance in pixels between sprite1 and location y,x. The number returned is computed as follows: The difference in pixels between the dot-row of sprite1 and the y location is found and squared. Then the difference in pixels between the dot-columns of sprite1 and the x location is found and squared. Then the two squares are added. If the sum is larger than 32767, then 32767 is returned (181 squared). To obtain the actual distance between the sprites, use the square root function (SQRT) on the value returned. Valid Function Values: sprite1 = an integer between 1 and maxsprites y, x = integer value between 1 and 256 Return values: integer-variable: distance between sprite1 and x,y coordinates expressed as an integer between 1 and 32,767.

Example Code

    ` Call_DistanceXY function Test
    do
        y1$="" : y2$="" : x1$="" : x2$=""
        y1$ = ti_input("Sprite Y:")
        x1$ = ti_input("Sprite X:")
        y2$ = Ti_input("dot row Y:")
        x2$ =  Ti_input("dot col X:")
        x1 = val(x1$) : x2 = val(x2$) : y1 = val(y1$) : y2=val(y2$)
        call_sprite(1,65,16,y1,x1,0,0) : call_locate(1,y1,x1)
        dst = sqrt(CALL_DISTANCEXY(1,y2,x2))
        ti_printat(2,10,"SQR DISTANCEXY:"+str$(int(dst)))
        tiwaitkey()
        call_clear()
        ti_sync()
    loop

    The above program will calculate and display the distance between a sprites x,y coordinates and the specified dot row, y and dot column, x.

Go back to ...

TI99E Commands Menu
Main Menu

Copyright © Carlos Santiago Lebron - TI99 Environment 2020