SPRITE functions
VGA AND HDMI VERSIONS ONLY
The SPRITE functions return information regarding sprites which are small graphic images on the VGA/HDMI screen. These are useful when writing games. See also the SPRITE commands.
Position & Dimensions
SPRITE(X, [#]n)
Returns the X-coordinate of sprite n. This function is only active when the sprite is currently displayed (active). Returns 10000 otherwise.
SPRITE(Y, [#]n)
Returns the Y-coordinate of sprite n. This function is only active when the sprite is currently displayed (active). Returns 10000 otherwise.
SPRITE(W, [#]n)
Returns the width of sprite n. This function is active whether or not the sprite is currently displayed (active).
SPRITE(H,[#]n)
Returns the height of sprite n. This function is active whether or not the sprite is currently displayed (active).
Collision & Contact Detection
SPRITE(C, [#]n )
Returns the number of currently active collisions for sprite n. If n=0 then returns the number of sprites that have a currently active collision following a SPRITE SCROLL command
SPRITE(T, [#]n)
Returns a bitmap showing all the sprites currently touching the requested sprite n
Bits 0-63 in the returned integer represent a current collision with sprites 1 to
64 respectively
SPRITE(E, [#]n)
Returns a bitmap indicating any edges of the screen the sprite is in contact with:
- 1=left of screen
- 2=top of screen
- 4=right of screen
- 8=bottom of screen
Sprite Management
SPRITE(N)
Returns the number of displayed (active) sprites
SPRITE(N,n)
Returns the number of displayed (active) sprites on layer n
SPRITE(L, [#]n)
Returns the layer number of active sprites number n
SPRITE(S)
Returns the number of the sprite which last caused a collision. NB if the number returned is Zero then the collision is the result of a SPRITE SCROLL command and the SPRITE(C…) function should be used to find how many and which sprites collided.
Distance & Vector Operations
SPRITE(D ,[#]s1, [#]s2)
Returns the distance between the centres of sprites s1 and s2 (returns -1 if
either sprite is not active)
SPRITE(V,[#]s1, [#]s2)
Returns the vector from sprite s1 to s2 in radians.
The angle is based on the clock so if s2 is above s1 on the screen then the
answer will be zero. This can be used on any pair of sprites that are visible. If
either sprite is not visible the function will return -1.
This is particularly useful after a collision if the programmer wants to make some differential decision based on where the collision occurred. The angle is calculated between the centre of each of the sprites which may of course be different sizes.