TI99 Environment

# CALL_COINCALL

Syntax

integer-variable = CALL_COINCALL()

Description

The COINCALL function checks for collision (COINCidence) between any two sprites on the screen. Sprites are coincident only if one or more of the dots which make them up occupy the same position on the screen when the function is called. Return values: integer-variable: Returns 0 when there is no sprite collision or -1 when there is a collision between any two sprites. The global variables colsprite1 and colsprite2 hold the colliding TI sprite numbers.

Example Code

    randomize hitimer()
    numobjects = 10
    call_magnify(2)
    for i = 1 to numobjects
    call_sprite(i,96+i,5,96,128,rnd(30) - 10, rnd(30) - 10)
    next i
    tiwait(1000)
    while TIE_Activesprites > 1
       coll = CALL_COINCALL()
       if coll
          display_at(1,8,"***COLLISION***",0)
          call_colorchar(TI_SpriteAscii(colsprite1), 5,1)
          call_colorchar(TI_SpriteAscii(colsprite2), 5,1)
          display_at(2,1,"BETWEEN SPRITE # " + str$(colsprite1) + " (" + chr$(TI_SpriteAscii(colsprite1)) + ") AND",0)
          display_at(3,1,"        SPRITE # " + str$(colsprite2) + " (" + chr$(TI_SpriteAscii(colsprite2)) + ")",0)
          display_at(4,6,"***PRESS ANY KEY***",0)
          call_motion(colsprite1,0,0)
          call_motion(colsprite2,0,0)
          call_screen(16)
          tiwaitkey()
          call_delsprite(colsprite1) : call_delsprite(colsprite2)
          call_screen(8)
          call_clear()
          call_colorchar(TI_SpriteAscii(colsprite1), 2,1)
          call_colorchar(TI_SpriteAscii(colsprite2), 2,1)
       endif
       ti_sync()
    endwhile
    end

Go back to ...

TI99E Commands Menu
Main Menu

Copyright © Carlos Santiago Lebron - TI99 Environment 2020