![]() |
| TI99 Environment |
| Syntax |
| integer-variable = CALL_COINC(sprite1,sprite2,tolerance) |
| Description |
|
The COINC function checks for collision (COINCidence) between sprite1 and sprite2. The parameter tolerance indicates the distance in pixels between the two sprites where they will report a collision. A collision occurs when the upper left-hand corner of both sprites is within the value specified by tolerance. Depending on the tolerance value, sprites may trigger a collision even if there is no apparent overlap. Valid Function Values: sprite1, sprite2 - an integer between 1 and maxsprites indicating the sprite number of the sprite being checked for collision. tolerance = an integer indicating the distance in pixels between sprite1 and sprite2 that will report a collision. Return values: integer-variable: Returns 0 when there is no sprite collision or -1 when there is a collision between sprite1 and sprite2. |
| Example Code |
`Call_Coinc function Test
repeat : tolerance$ = ti_input("Tolerance:") : tolerance = val(tolerance$) : until tolerance >= 0
x1 = 180 : y1 = 96 : x2 = 100 : y2 = 96
call_sprite(1,65,16,y1,x1,0,0)
call_sprite(2,65,14,y2,x2,0,0)
call_motion(1,0,-5) : call_motion(2,0,2)
do
coinc = CALL_COINC(1,2,tolerance)
if coinc = -1
ti_printat(1,10,"COINC:"+str$(coinc))
call_motion(1,0,0) : call_motion(2,0,0)
call_clear()
repeat
tolerance$ = ti_input("Tolerance:")
tolerance = val(tolerance$)
until tolerance >= 0
call_sprite(1,65,16,y1,x1,0,-5)
call_sprite(2,65,14,y2,x2,0,2)
endif
ti_sync()
loop
| Go back to ... |
| TI99E Commands Menu |
| Main Menu |
Copyright © Carlos Santiago Lebron - TI99 Environment 2020
![]() |