All GELs, including VSprites, can participate in the software collision detection features of the graphics library. Simple Sprites must use hardware collision detection. See the Amiga hardware reference manual for information about hardware collision detection. Two kinds of collisions are handled by the system routines: GEL-to-boundary hits and GEL-to-GEL hits. You can set up as many as 16 different routines to handle different collision combinations; one routine to handle the boundary hits, and up to fifteen more to handle different inter-GEL hits. You supply the actual collision handling routines, and provide their addresses to the system so that it can call them as needed (when the hits are detected). These addresses are kept in a collision handler table pointed to by the collhandler field of the gelsinfo list. which routine is called depends on the 16-bit memask and hitmask members of the vsprite structures involved in the collision. When you call docollision(), the system goes through the gelsinfo list which, is constantly kept sorted by x, y position. If a GEL intersects the display boundaries and the GELs hitmask indicates it is appropriate, the boundary collision routine is called. When DoCollision() finds that two GELs overlap, it compares the memask of one with the hitmask of the other. If corresponding bits are set in both, it calls the appropriate inter-GEL collision routine at the table position corresponding to the bits in the HitMask and MeMask, as outlined below. preparing for collision detection vsprite borderline building a table of collision routines vsprite hitmask and memask vsprite collision mask using hitmask and memask