Missing Link Tutorial

part 1 By DEANO

 BOB | JOEY | B WIDTH and B HEIGHT | Defining BOBS & JOEYS
The Missing Link is, in my opinion, the best extension to be written for STOS.  It covers a lot of areas of STOS programming including a set of  extra commands plus better faster versions of old ones....

In  this  tutorial  I shall take you step by step  through  the  commands explaining  in detail how to use them.  Although Top Notch have given  a fair  idea of how to use the extensions new commands there are  still  a few of you who need that extra bit of help....
This month we shall have a look at the new SPRITE commands...

BOB SCR,ADR,IMAGE,X,Y,0
BOB X1,Y1,X2,Y2,0,1
JOEY SCR,ADR,IMAGE,COLOUR,X,Y,0
JOEY X1,Y1,X2,Y2,0,0,1
H=B HEIGHT (ADR,IMAGE)
W=W HEIGHT (ADR,IMAGE)

BOB

The  BOB  command is a new version of the SPRITE  command.  It  is  much faster and smoother, and theres no limit to how many you can have on the screen  at the same time.  This is a new method of sprite movement known as  Pre-Shifting,  and  although it takes up more  memory  than  normal sprites, it is much better. The format of this command is.....

bob SCR,ADR,IMAGE,X,Y,0

SCR
is the screen to place the BOB on.  Note that unlike SPRITE which is only displayed on the physic or logic screen,  a BOB can be displayed on either the BACK screen,  the PHYSIC screen, or even the LOGIC screen. It can also be placed in a memory bank.
ADR
is the memory bank where the BOB's are held. Unlike sprites that can only be accessed from bank one,  BOB's can be loaded into any bank. Note that we need to use the START command to tell STOS which bank the  BOB's are in.  So if the BOB's were loaded into bank 5,  the varible ADR would be 'start(5)' and not '5' as we use with commands like 'screen copy'.
IMAGE
is the number of the BOB to display on screen which  ranges  from nought  to the number of bobs in the bank.  It's important  to  remember that when you convert your sprites to bobs,  the image numbers are moved back by one place.  So the first sprite would become BOB 0,  the  second would become BOB 1, and so on.......
X,Y
are simply the X and Y co-ordinates of the BOB. Note that unlike sprites,  the hot spot for a bob is best being put in the top left  hand corner. So the BOB is placed on the co-ordinates of the hot spot.
0
The  last number (nought) does'nt do anything yet,  it's just there  for future purposes so you can leave it at nought.

bob X1,Y1,X2,Y2,0,1

This  command  is a new version of the LIMIT  SPRITE  command,  only  it limits a BOB to a certain part of the screen.  To limit the bob means to set  up an area on screen where the bob is to be visible,  if  it  moves outside this area then it will vanish. Try this routine...
10 key off : hide : curs off : mode 0
20 load"bob.mbk",5
25 A=palt(start(5)
30 box 50,50 to 150,150
40 bob 50,50,150,150,0,1
50 logic=back
60 XB=60 : YB=60
70 repeat
80 XB=XB+2
90 bob logic,start(5),0,XB,YB,0
100 wait 5
110 screen swap : wait vbl
120 until XB=170
130 goto 60
This routine will draw a box on screen and move the BOB to the right  by steps  of  two pixels.  Note that when the bob moves out of the  box  it starts to vanish. This could be used to great effect in games.  As  you can  see,  the  co-ordinates  of the box are the same as  those  of  the limiting version of BOB meaning keep the bob between these co-ordinates.

JOEY

The next command is the JOEY command. This command is simular to the BOB command  only  its  used for sprites which  are  only  one  colour...for example, a white bullet sprite. The format of the command is...
joey SCR,ADR,IMAGE,X,Y,COLOUR,0
The parameters of this command are the same as the BOB command, with the extra parameter called COLOUR.  This is the number of the colour in  the present palette that the joey is...for example,  if the joey was  white, and white was colour number ten in the palette then COLOUR would be ten. For unknown reasons, colour fifteen is the fastest.
joey X1,Y1,X2,Y2,0,0,1
This  version  of the command limits the joey to a certain part  of  the screen.  It  just the same as the BOB version only the two  noughts  are reserved for future use.

B WIDTH and B HEIGHT

The last two commands are B WIDTH and B HEIGHT, the format is.....
W=b width (ADR,IMAGE)
H=B height(ADR,IMAGE)
These commands return the size of a bob, in pixels.
ADR is the number of the bank where the bob is stored and IMAGE is the image number of it.

EXAMPLE:-

10 key off : curs off : hide : mode 0 
20 load"bob.mbk",5 
30 W=b width(start(5),0) 
40 H=b height(start(5),0) 
50 print"This bob is ";W;" pixels across" 
60 print"This bob is ";H;" pixels down" 
70 print"Total size is ";W;"X";H
This command would be useful in finding out the size of a bob so we  can calulate if it will fit on a certain part of the screen.

Defining BOBS and JOEYS

If you look at the MAKE program,  you'll see that the options to convert bobs and joeys ask how many images it should make of each  sprite.  Well the  smaller  the number,  the less memory used,  and  the  smaller  the converted  BOB bank.  If you set the program to make eight images  of  a sprite,  then  they  will move quite smoothly if you move  them  at  two pixels  at  a time.  Lower numbers mean you would have to move  them  in bigger  steps in order for them to move smoothly.  The same  applies  to JOEY's,  although, these would normally be used as bullets which need to be fast so you can make about two images of each one.

Well  thats the end of the first part of this tutorial and I  hope  I've managed to make the SPRITE commands more clearer to you.  Next month  we shall have a look at the Mapping commands.

Till next month..........DEANO