TI99 Environment

# CALL_COINCSPRITE

Syntax

integer-variable = CALL_COINCSPRITE(sprite1)

Description

The COINCSPRITE function checks for collision (COINCidence) between sprite1 and any other sprite. Valid Function Values: sprite1 = an integer between 1 and maxsprites indicating the sprite number of the sprite being checked for collision. Return values: integer-variable: Returns 0 when there is no sprite collision or -1 when there is a collision between sprite1 and any other sprite. The global variable colsprite2 holds the other colliding TI sprite number.

Example Code

    ` Demo of coincsprite, joyst - use joyst to move "*" and push the sprites on the screen
    numsprites = 20
    call_screen(2)
    call_char(128,"3C7EFFFFFFFF7E3C")
    call_magnify(2)
    randomize timer()
    for i = 1 to numsprites
        call_sprite(i,128,rnd(13) + 3,rnd(176)+8,rnd(232)+8,0,0) ` Displays sprites
    next i
    call_pattern(1,42)
    do
      call_joyst(1,sx,sy) : sx = joystx * 6 : sy = -joysty * 6 : sxg = sgn(sx) : syg = sgn(sy)
      call_motion(1,sy,sx)
      colliz = CALL_COINCSPRITE(1)
      if colliz
         call_motion(colsprite2,syg*36,sxg*36)
      endif
      ti_sync()
    loop

Go back to ...

TI99E Commands Menu
Main Menu

Copyright © Carlos Santiago Lebron - TI99 Environment 2020