If you've seen how the STOS 'limit sprite' command works, you'll see that the mouse is limited to that part of the screen, its like having it trapped in an invisible box.
This is how this version of 'world' works. It traps the scrolling map in an invisible box. X1 and Y1 hold the start co=ordinates of the screen area to be trapped...in other words the top left hand part of the screen. X2 and Y2 hold the end co-ordinates of the box..IE: the bottom right hand part of the screen. The last two parameters have no meaning as yet so leave them as they are.
In order to create these scrolling areas, known as maps. We first have
to define one. We can do this using the EDDY program supplied with the
missing link package. This is simular to using the 'Map Definer' supplied
with STOS only we don't use normal STOS sprites to create the map. We use
the MAKE program to make the sprites into world blocks so they can be loaded
into EDDY. Note that even though the EDDY manual tells us that we can load
'world' and 'landscape' blocks into the EDDY definer...we can only load
'world' blocks into it. If I get time I'll do an article on these two programs.
SCR= This is the screen to display the map on, it can be either LOGIC, PHYSIC, or BACK.
BLOCKS= This tells 'world' where our world blocks are, load them into a memory bank and use 'start(bank-number)'.
MADR= The bank number of the map data saved from EDDY, note it must have been saved as 'world data', again use 'start(bank-number)'.
X and Y= The X and Y co-ordinates of the maps starting point.
The nought does nothing as yet, maybe in an update. Anyway, heres a routine that shows the use of the two commands.
10 key off : hide : flash off : mode 0If we look at lines 80 and 100 we see that the program is checking if the X and Y varibles are less than a number thats higher than the co-ordinates of the actual screen. This is because the varibles are the co-ordinates of the scrolling area of the map and not the screen.
20 load"BLOCK.MBK",5 : rem load world blocks into bank 5
30 load"MAP.MBK",6 : rem load world map data into bank 6
40 logic=back : X=0 : Y=0
45 world 32,10,288,190,0,1
50 repeat
60 world logic,start(5),start(6),X,Y,0
70 if jleft and X>0 then dec X
80 if jright and X<1500 then inc X
90 if jup and Y>0 then dec Y
100 if jdown and Y<2000 then inc Y
110 screen swap : wait vbl
120 until fire
Note that the first version of the WORLD command must have its X co-ordinates in steps of 16 pixels due to a bug in the ST's registers.
Note, as with the first version of WORLD, the first version of LANDSCAPE must have its X co-ordinates in steps of 16 pixels. Note that we can use the last routine to see these commands in action. Just convert your sprites to LANDSCAPE blocks, load them into EDDY and make your map making sure you don't go over the X co-ordinate of 304 and make your map downwards, not exceeding the 320 X co-ordinate. Save your map data as landscape data, load your landscape blocks into bank five, and new landscape map data in bank six. Remove lines 80 and 90 and run the program. As we can see, we can only move up and down.
Note, due to the bug in EDDY, we have to make our sprites first into world blocks, then landscape blocks. Load the world blocks into EDDY to make the landscape map, then load the landscape blocks into our example routine. Bit of a pain but there we go.
So what we want to do is place our diamond blocks in certain places of the map as we define it, then tell STOS that when our BOB touches it, to detect a collision, add this line to our example.
105 BL=which block (start(6),XBOB+14,YBOB+12)The varibles XBOB and YBOB hold the X and Y co-ordinates of the bob, as the bob touches a certain block, the varible BL would contain the row number of it. So, if the bob touched the diamond, then BL would be set to nought. If the bob touched the next block in the row then BL would be set to one. Lets say we defined two sprites has part of the map, and converted them to map blocks. We could use this routine to check which block has been touched. Try these lines...
106 if BL=0 then print"You have found the diamond."Where the wall is the second block in the world/landscape blocks.
107 if BL=1 then print"You have hit the wall."
10 BL=which block(start(6),XBOB,YBOB)
20 if BL=1 then set block start(6),XBOB,YBOB,0 : bell
100 replace blocks start(6),1,2
100 DIAMONDS=block amount(start(6),1)So, BLOCK holds the number of block ones..(diamonds) there are in the map. As each one is removed with SET BLOCK, the DIAMONDS varible will decrease by one, line 110 checks if all diamonds have gone.
110 if DIAMONDS=0 then print"All diamonds are collected"
10 A=block amount(start(6),1)XADR and YADR are the X and Y arrays to put the co-ordinates in, BLOCK is the row number of the block we want to get the co-ordinates of, and NUMBER is the total number of block ones found in the map.
20 dim XBL(A),YBL(A)
30 xy block start(6),varptr(XBL(0)),varptr(YBL(0)),1,A
40 for X=0 to A : print XBL(X),YBL(X) : next X
This can be used if you had a number of diamonds and you wanted each one to score different points. Using the arrays you can see which diamond block has been collected and update the score with the certain diamonds points....like so
50 if A=1 and XBOB=XBL(1) then SC=SC+40
60 if A=1 and YBOB=YBL(4) then SC=SC+100
10 load"map.mbk",6 : rem World dataThis is usefull if you had some levels in your game that use the landscape command, and some that used 'world'.
20 N=map toggle(start(6))
30 print"The world data is now landscape data"
40 N=map toggle(start(6))
50 print"The landscape data is now back to world data"
Well thats the end of part 2, see you in part 3 next month where we
shall have a look at the text commands.