The function returns 0 (false) if there is no collision or the number of the colliding sprite (s2...s3) if there was a collision.
NOTE: If the colliding sprite's id is 0 then 128 is returned.
Any relative sprites following s2 or s3 will also be checked, until the next anchor sprite that is not in the specified range.
The last method of animation is by using the in-built hardware scrolling capabilities of the ZX Spectrum Next. As you will find out in Chapter 22, all layers can be scrolled either in full or within a clipping window (see Chapter 16 – Graphics). NextBASIC provides access to hardware scrolling via the LAYER AT command. Its syntax is as follows:
which moves the current layer to the offset defined by the coordinates x and y. According to which side we're moving to, the existing graphics on that side get wrapped around the opposite side. Let's demonstrate using one of the images we generated earlier while doing frame-based animation:
10 LAYER 2,1:CLS
20 LOAD "ANIM0.SL2" LAYER: PAUSE
0: REM Hasta la vista Kev!
30 FOR %x=0 to 255
40 LAYER AT %x,%0
50 NEXT %x
60 LAYER AT 0,0: LAYER 2,0:LAYER 0
Once you RUN the above, you'll see an image racing towards the left side of the screen so fast it may even be unusable for anything other than a simple effect. Running it at 3.5MHz you will see a very smooth movement which shows how efficient hardware scrolling is on the ZX Spectrum Next.
If you want to reverse the effect and make the screen move towards the right you will need to change line 40 to:
40 LAYER AT %255-x,0
If we borrow a bit from the sprite example, we can even introduce a SIN function to make the screen appear like it's bouncing from left to right and top to bottom and vice-versa.
By itself, the LAYER AT keyword doesn't do much other than roll a screen around; with the combination however of layer clipping windows and background updating of the shadow screens (See Chapters 22 and 23 as well as Chapter 16), you can produce a scrolling effect of very large landscapes. If you combine this with specially crafted screens that can repeat themselves at infinitum then you have the basics for every side scrolling game ever made!
While not strictly an animation aid, the Copper is a hardware module of the ZX Spectrum Next that can definitely be used for, among other things, animation. The Copper runs in parallel and independently from the main Z80n processor and is dedicated to writing Next Registers (NexREG) at specific points on the display. The name derives from "co-processor" and was first seen in the Amiga computer which had a similar function. The Copper, essentially maintains a list of instructions that consists of only two commands; WAIT and MOVE. This simple control allows updating of Next registers at regular times, synchronised to points when the display is updated on the screen. The Copper system can therefore be used to send audio samples to the ZX Spectrum Next's digital audio hardware,
ZX Spectrum Next User Manual, 3rd Edition (ISBN 978-1-5272-5496-1), written and illustrated by Phoebus R. Dokos. Copyright © 2020-2024 Phoebus Dokos / SpecNext Ltd. Licensed under CC BY-NC-SA 4.0. This is a transcription and can contain errors; check any doubt against the printed page.