collslib
The library finds collisions in two ways. ShapesHit, ShapeSpriteHit,
SpritesHit and RectsHit compare the rectangles that two objects
cover at the positions given, taking the handles of shapes and sprites
into account. They return true (-1) if the rectangles overlap, else
false (0), and work in both modes.
The hardware of the Amiga also notices when a sprite touches another
sprite or a coloured pixel of a bitmap. SetColl, SetCollOdd and
SetCollHi choose which bitmap colours count, so that a game can have
safe and unsafe colours. DoColl reads what the hardware noticed since
the last DoColl, and SColl and PColl then tell which sprites
collided. DoColl, SColl and PColl work in Blitz mode only.
BLITZ
SetCollOdd
Repeat
VWait
ShowSprite 0,x,100,0
DoColl
If PColl(0) Then hits+1
x+1
Until x=300The hardware notices collisions of sprite pairs: channels 0 and 1, 2 and 3, and so on, count together.
Based on the collslib guide by Acid Software.
Library number 104.
Commands
DoColl
Reads the collisions the hardware noticed since the last DoColl. SColl and PColl then return these until the next DoColl. Blitz mode only.
Statement. No help text.
No arguments.
Which bitmap colours count for PColl is what SetColl, SetCollOdd
or SetCollHi chose.
PColl
True (-1) if the sprite on the channel collided with a bitmap colour that counts, as DoColl read it, else false (0). Blitz mode only.
Function, result .w. Help text: (Sprite Channel)
Arguments: .w
RectsHit
True (-1) if the two rectangles, each given by its top left corner, width and height, overlap, else false (0).
Function, result .w. Help text: (X1,Y1,Width1,Height1,X2,Y2,Width2,Height2)
Arguments: .w, .w, .w, .w, .w, .w, .w, .w
SColl
True (-1) if the sprites on the two channels collided, as DoColl read it, else false (0). Blitz mode only.
Function, result .w. Help text: (Sprite Channel,Sprite Channel)
Arguments: .w, .w
The order of the two channels does not matter. Sprites of the same pair of channels (0 and 1, 2 and 3, 4 and 5, 6 and 7) have no collision of their own. With runtime error checking, two such channels are the error “Sprite channels must be of different pairs”, and two equal ones are the error “Sprite channels must be different”.
SetColl
Makes a collision of a sprite with bitmap colour Colour count, in a bitmap of Bitplanes bitplanes (1 to 6). In a dual playfield slice, Playfield 1 means the colour of the front bitmap, 2 that of the back bitmap.
Statement. Help text: Colour,Bitplanes[,Playfield 1=front, 2=back]
2 forms:
.w, .w.w, .w, .w
With runtime error checking, 0 bitplanes is the error “Illegal number of BitPlanes”. As in the original, only that check catches it: without it, the library loops 65536 times.
SetCollHi
Makes collisions of sprites with every colour that has the highest of Bitplanes bitplanes set count, the upper half of the colours.
Statement. Help text: Bitplanes
Arguments: .w
SetCollOdd
Makes collisions of sprites with the odd colours of a bitmap (1, 3, 5 …) count, and those with the even colours not.
Statement. No help text.
No arguments.
ShapesHit
True (-1) if the rectangles of two shapes at the positions given overlap, else false (0). The handles of the shapes are taken into account.
Function, result .w. Help text: (Shape#,X,Y,Shape#,X,Y)
Arguments: .w, .w, .w, .w, .w, .w
ShapeSpriteHit
True (-1) if the rectangles of a shape and a sprite at the positions given overlap, else false (0). The handles of both are taken into account.
Function, result .w. Help text: (Shape#,X,Y,Sprite#,X,Y)
Arguments: .w, .w, .w, .w, .w, .w
SpritesHit
True (-1) if the rectangles of two sprites at the positions given overlap, else false (0). The handles of the sprites are taken into account.
Function, result .w. Help text: (Sprite#,X,Y,Sprite#,X,Y)
Arguments: .w, .w, .w, .w, .w, .w