The default sprites in STOS are software sprites, meaning that STOS has to do a lot of work with them which makes them slow and flickery. It spends a fair bit of processor time updating them and with them working on interupt...also adds to problems.
Here is a few tipical questions about them along with answers...
QUESTION:- The command 'sprite 16,100,120,4' produces an error.
ANSWER:- This is because STOS only allows up to 15 sprites on
the screen at the same time. Trying to put more than this on screen at
once will produce a SPRITE error.
QUESTION:- The sprite flickers when it moves.
ANSWER:- This is because of the telly picture tube updating
causing the sprite to flicker when it passes it. Use the 'screen swap'
command to avoid this.
QUESTION:- How can I get the sprites moving more smoothly?
ANSWER:- Yes, STOS updates the sprites every 50th of a second.
This can lead to problems with speed and movement so you're best of using
the 'update off' command and updating them yourself with the update command
like this....
10 key off : hide : update offQUESTION:- The more sprites I use, the slower they get.
20 sprite 1,X,Y,4 : update
QUESTION:- Large sprites are difficult to handle.
ANSWER:- Yes they are...the bigger the sprite, the more time
STOS uses to update them. If you must have large sprites then use as few
as possible...about two or three on screen at the same time.
QUESTION:- The sprite flashes on screen.
ANSWER:- This is because it has colour 2 in it, STOS always
flashes this colour. Use the 'flash off' command.
QUESTION:- If I place the sprite on a picture, the colours of
the sprites are different to what they were.
ANSWER:- Pictures and sprites have their own separate palettes.
When you load a picture to the screen or unpack one from a bank STOS adjusts
its palette to the one of the screen so the sprite gets the same palette.
Load your sprites back into the 'Sprite Definer', grab the palette from
your background picture and re-colour the sprites with the pictures colours.
QUESTION:- If I place a sprite on screen, its colours change.
ANSWER:- Again this is due to the sprite and the screen having
two different palettes. Unlike pictures STOS does'nt adjust his palette
to the one of the sprite, you have to do it yourself like this...
10 key off : mode 0 : flash offQUESTION:- The sprite has'nt appeared on screen.
20 XP=hunt(start(1) to start(1)+length(1),"PALT")
30 XP=XP+4 : for I=0 to 15 : colour I,deek(I*2+XP) : next I
1> The image number you used is a blank space in the sprite bank, so
STOS displays a blank space.
2> You've given the X and Y parameters a negative value, IE: you've
typed 'sprite 1,-50,-100,4', putting it off the screen.
QUESTION:- Can I display sprites in medium rez?
ANSWER:- Yes, define them with the 'Sprite2' accessory.
QUESTION:- How can I animate about 20 images, ANIM won't do it.
ANSWER:- The 'anim' command only stores about 10 to 15 images
at a time. You'll have to animate them yourself like this.
10 key off : flash off : mode 0The 'wait' command controls the speed of the animation.
20 for X=1 to 20
30 sprite 1,100,100,X : wait 20
40 next X
QUESTION:- How do I control a sprite using the joystick.
ANSWER:- Don't use the move command for this, it does'nt stop
when you want it to. Instead, use this routine...
10 key off : mode 0QUESTION: Why can't I move the sprite against a scrolling background?
20 if jleft then X=X-2
30 if jright then X=X+2
40 if jup then Y=Y-2
50 if jdown then Y=Y+2
60 sprite 1,X,Y,1 : wait vbl
70 goto 20
Errm......the final bit.
Well thats it for this article. I hope its been useful. Actually most STOS coders use pre-shifted sprites these days but if you are just learning then I'm sure you'll find this article useful.
This is Deano signing off......