home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TCE Demo 2
/
TCE_DEMO_CD2.iso
/
demo_cd_.2
/
mags
/
stosser
/
stoser08.arj
/
stoser08.msa
/
ISSUE_8
/
34.PNE
< prev
next >
Wrap
Text File
|
1987-04-22
|
25KB
|
813 lines
I assume little/no prior knowledge of Stos. Each lesson will also
have a Stos BASic or ASCii file to go with it.
Listed here for your convenience. i.e. to make it easier to write
them down or to look at the structure of the command. Are the new
commands to be dealt with.
Do not worry if you find things hard at first, practice makes
perfect. Actual progs are used to explain things, called
'name.asc' and included in this folder.
The Main Commands:
CHANGE MOUSE FADE PUT SPRITE LENGTH(N)
If you have any problems, then look for the command on pages
271/73 of the manual. This is not intended to replace the manual,
but to add to it where needed.
Right then, there would have been more commands and a better
tutorial this time except for the computer breaking down, and me
only just getting it back.
I had intended to cover Squashing and Unsquashing this time, and
also show a finished version of the jigsaw creator - or at least
how to make everything work - but as I only got he computer back
yesterday, and this has to be sent away today, I decided to limit
it to changing the mouse sprite, and showing how to place the
jigsaw piece on the screen.
Lesson 1
10 rem **************************
20 rem *** ***
30 rem *** CHANGE MOUSE ***
40 rem *** ***
50 rem **************************
60 if mode<>0 then mode 0
70 cls : key off : curs off : hide on
80 if length(1)<>0 then goto 150
90 DRV=drive : drive=0 : dir$="A:\"
100 locate 10,10 : print "LOAD A SPRITE BANK" : wait 50
110 cls : show on : SPR$=file select$("*.MBK")
120 load SPR$
130 hide on : locate 10,10
140 print SPR$;" IS LOADED" : wait 50
150 cls
160 locate 0,0 : centre "Mouse key = start"
170 MK=0
180 repeat 190 MK=mouse key
200 until MK<>0
210 SP=1
220 show on
230 change mouse SP+3
240 if mouse key=3 then goto 250 else goto 240
250 fade 10
260 default : end
These four lessons are all virtually the same, but I will take you
through each new idea as it is implemented. This lesson just
changes the mouse into the first sprite in the bank.
Lines:
10 rem **************************
20 rem *** ***
30 rem *** CHANGE MOUSE ***
40 rem *** ***
50 rem **************************
Inform you of what the programme is intended to do.
Lines:
60 if mode<>0 then mode 0
70 cls : key off : curs off : hide on
Set the screen up by checking the resolution, then clearing the
screen of any rubbish, and hiding the mouse and cursor.
Line:
80 if length(1)<>0 then goto 150
This is a new idea. It it checks to see if there is anything in
BANK 1 - it is bank one because that is the default sprite bank,
and whilst you can store sprites in other banks, you can not
display them until they are placed in bank 1.
The (LENGTH(n)) command informs you of how large the particular
bank is. The (n) is which ever bank you nominate. In this case
it is bank 1 as that is the sprite bank.
The check is to see if (n=0) - in fact it checks to make sure it
does not equal zero - if (n) does equal zero then there are no
sprites loaded in bank 1, and it will ask you to load a sprite
bank later on. If it is not zero then there is a sprite bank
already loaded so it jumps to the next part of the programme.
Line:
90 DRV=drive : drive=0 : dir$="A:\"
This is only activated if there is no sprite bank loaded in. I.e.
only the first time the programme is run, or the loop is operated.
It stores the current drive, then resets to drive A: and the root
directory, so that when the programme ends it takes you back to
where you ran the programme from.
If this line was missed out then the programme would remain
wherever you loaded the sprites from. Basically, it allows you to
run the programme from one disk drive/ram disk, and then defaults
to Drive A: in order to load the sprites from Drive A:, and then
return to the place it started from, rather than remaining on
drive A:
Lines:
100 locate 10,10 : print "LOAD A SPRITE BANK" : wait 50
110 cls : show on : SPR$=file select$("*.MBK")
120 load SPR$
130 hide on : locate 10,10
140 print SPR$;" IS LOADED" : wait 50
Are the bit that allows you to load a sprite bank, and have been
dealt with in last months tutorial, but for those who missed it.
A message is printed on screen - actually the screen should have
been cleared here with a (CLS) first just in case there was any
junk on the screen.
Then the message is removed and the mouse is shown in order to
allow you to select the appropriate file. The file selector is
called by the (FILE SELECT("*.MBK") command. And the file type is
set to (MBK) as this is what we want. It could have been (Neo) or
(PI1) for a screen, or even (PAC) which is a squashed file.
The (SPR$) is the variable created to hold the name of the
selected file, and is then used with the (LOAD SPR) command to
load it into a bank.
The mouse is then hidden again, and the message informing you that
the task is completed appears.
Lines:
150 cls
160 locate 0,0 : centre "Mouse key = start"
Inform you of what to do after clearing the screen, There should
have been another line here informing you that if you press both
mouse keys together, then the programme will quit back to the
editor. It was missed off, and I do not have time to alter this,
however it is corrected on all the other lessons.
Lines:
170 MK=0
180 repeat 190 MK=mouse key
200 until MK<>0
Set up a loop that continues until any mouse key is pressed.
Line:
210 SP=1
Sets up a variable to store the value of the sprite to use with
the (Change mouse) command later. Normally it would be linked to
the mouse key pressed, so as to store the first press - in case I
wanted to use the mouse to do something else, or pressed another
key afterwards. But in this case I wanted it to remain fixed as
sprite 1, so I made (SP) a fixed value rather than linking it to
the mouse key as (SP = MK) because (MK = MOUSE KEY) but only
within the loop.
If you are confused I will be explaining this nest time in more
detail, as I am pushed for time at the moment..
Lines:
220 show on
230 change mouse SP+3
Make the mouse key appear and then change it to the selected
sprite. (SP+3) because the Mouse already can take a value between
1 and 3, so it has to be (3) plus the sprite value.
Here again, I notice a mistake. The (Show) command should have
come after the (Change Mouse).
Why? Well if the programme was running slower - put a (225 Wait
200) to see the effect - then it would first make the mouse
pointer appear, and then change it to the sprite.
The point being that we do not want to see the mouse pointer, only
the sprite, so I should have placed the (Show) command after the
mouse pointer had been changed.
The same principle applies to compiled programmes. If you forget
to turn the KEYs off within the Compiler, then the Editor screen
will flash to screen when you run a compiled programme.
Line:
240 if mouse key=3 then goto 250 else goto 240
Tests to see if both mouse keys are being pressed. If so it jumps
to line 250, if not it loops around and starts another test.
Lines:
250 fade 10
260 default : end
Quit the programme in a proper manner, returning you to the
default settings. I always start off with a medium resolution
screen, as it is easier to read the programme there than in low
resolution.
The (DEFAULT) command resets the mouse and cursor and keys (MENU
at top of screen), but is simpler than entering each command one
at a time.
The (End) command is not really needed, but it is nice to finish
up cleanly, so I put it in there. The difference between it and
(STOP) is that it will not allow the programme to start up again
with a (CONTINUE) command.
Well there was not really that much to the previous programme, and
this is much the same thing, with just a few frills added to it.
Neither this, nor the previous programme attempted to get the
proper colours for the sprite bank, and as a result they are
displayed in the default colours.
Lesson 2
10 rem **************************
20 rem *** ***
30 rem *** CHANGE MOUSE 2 ***
40 rem *** ***
50 rem **************************
60 if mode<>0 then mode 0
70 cls : key off : curs off : hide on
80 if length(1)<>0 then goto 150
90 DRV=drive : drive=0 : dir$="A:\"
100 locate 10,10 : print "LOAD A SPRITE BANK" : wait 50
110 cls : show on : SPR$=file select$("*.MBK")
120 load SPR$
130 hide on : locate 10,10
140 print SPR$;" IS LOADED" : wait 50
150 cls
160 locate 0,0 : centre "Left mouse key = start"
170 locate 0,2 : centre "Right mouse key = Place"
180 locate 0,4 : centre "Both keys = Quit"
190 MK=0
200 repeat
210 MK=mouse key
220 until MK=1
240 SP=1
250 show on 260 change mouse SP+3
270 if mouse key=3 then goto 340
280 if mouse key=2 then goto 300
290 goto 270
300 XP=x mouse : YP=y mouse
310 wait vbl : sprite 1,XP,YP,1
320 put sprite 1
330 goto 270
340 fade 10
350 default : end
And now for the explanation of the programme. This time the
sprite will be able to be placed to the screen by pressing the
left mouse key. For some odd reason there is a line missing from
this programme. Usually I renumber the programme with (RENUM)
after deleting a line, but I must of forgotten here.
So line 230 is meant to be missing, and the programme should have
been renumbered to correct this, but I missed it, and do not have
time to change all three parts of this programme.
I should point out that I load the ascii text into a wp prog and
then duplicate it. However, I am not able to just load in the
modified text and copy it now, because this programme does odd
things when I try to do that, and I might loose everything, or
spend hours resetting everything up again. And as you know I am
short of time. So I will just point out any errors I see.
Lines:
10 rem **************************
20 rem *** ***
30 rem *** CHANGE MOUSE 2 ***
40 rem *** ***
50 rem **************************
Tell you what the programme does, and that this is a different
version from the first programme. If it was significant, then I
would enter a few more lines of code to explain the changes.
Lines:
60 if mode<>0 then mode 0
70 cls : key off : curs off : hide on
80 if length(1)<>0 then goto 150
90 DRV=drive : drive=0 : dir$="A:\"
Are the same as the previous programme, and set up the screen and
default disk drive.
Lines:
100 locate 10,10 : print "LOAD A SPRITE BANK" : wait 50
110 cls : show on : SPR$=file select$("*.MBK")
120 load SPR$
130 hide on : locate 10,10
140 print SPR$;" IS LOADED" : wait 50
Are the same as the previous programme, and load in the sprites.
Lines:
150 cls
160 locate 0,0 : centre "Left mouse key = start"
170 locate 0,2 : centre "Right mouse key = Place"
180 locate 0,4 : centre "Both keys = Quit"
Are a bit different. This time I remembered to clear the screen
before the message appears, in case there is junk on the screen
from before the programme was run.
They inform you of how to control the programme. I.E. by pressing
a mouse key.
Lines:
190 MK=0
200 repeat 210 MK=mouse key
220 until MK=1
Are slightly different. This time the loop is set up to test for
the left mouse key, and repeats until it is pressed. In the
previous programme it was set up to test for any mouse key being
pressed. But as key two is being used, and both together would
quit the programme, we have to make sure that they are not pressed
at this stage.
Lines:
240 SP=1
250 show on
260 change mouse SP+3
Are the same as the previous programme. Again, note that the
value of (SP) has to take into account the three preset mouse
shapes, and thus must have a value of at least (4).
Lines:
270 if mouse key=3 then goto 340
280 if mouse key=2 then goto 300
290 goto 270
Test to see if either the left mouse key or both are being
pressed. The left key jumps out of the loop to continue the
programme, and both keys together jump to the lines that quit the
programme in a proper fashion.
Line:
300 XP=x mouse : YP=y mouse
Stores the current values of the mouse co-ordinates, so that you
always have access to where the mouse is located on the screen.
This will be used to position the sprite to screen at the correct
position on the screen.
Line:
310 wait vbl : sprite 1,XP,YP,1
Waits for the next Vertical Line Break - which is when the screen
is updated - and then places a sprite at the co-ordinates of the
mouse pointer. In this case it is a fixed sprite value - sprite 1
out of the bank - and makes it the first sprite on the screen.
Remember that the Mouse has a sprite value of zero, and the
sprites that are normally shown on the screen range from (1) to
(15). Which unfortunately, is the same amount of sprites in the
sprite bank, so do not get confused.
Line:
320 put sprite 1
Copies the sprite being shown to the screen, so that it is no
longer classed as a sprite, and is fixed permanently in place.
Although the mouse is still shown as the same sprite.
Remember that although the first sprite in the bank is also the
one being displayed as sprite 1 - i.e. (sprite 1,x,y,1) - it could
just as easily have been sprite 6 from the sprite bank being
displayed as sprite 1 on the screen - i.e. (SPRITE 1,x,y,6).
Line:
330 goto 270
Loops back to check if a mouse key is being pressed.
Lines:
340 fade 10
350 default : end
Quit the programme in a proper manner.
This next lesson is the same as the previous lesson, except that
it now displays the sprites in their true colours.
Lesson 3
10 rem **************************
20 rem *** ***
30 rem *** CHANGE MOUSE 3 ***
40 rem *** ***
50 rem **************************
60 if mode<>0 then mode 0
70 cls : key off : curs off : hide on
80 if length(1)<>0 then goto 150
90 DRV=drive : drive=0 : dir$="A:\"
100 locate 10,10 : print "LOAD A SPRITE BANK" : wait 50
110 cls : show on : SPR$=file select$("*.MBK")
120 load SPR$
130 hide on : locate 10,10
140 print SPR$;" IS LOADED" : wait 50
150 cls
160 locate 0,0 : centre "Left mouse key = start"
170 locate 0,2 : centre "Right mouse key = Place"
180 locate 0,4 : centre "Both keys = Quit"
190 rem ** Find & Load Palette **
200 X=hunt(start(1) to start(1)+length(1),"PALT")
210 rem Add 4 to pass by string PALT
220 X=X+4
230 rem Copy to current palette.
240 for A=0 to 15
250 colour A,deek(X+A*2)
260 next A
270 rem
280 MK=0
290 repeat
300 MK=mouse key
310 until MK=1
320 SP=1
330 show on
340 change mouse SP+3
350 if mouse key=3 then goto 420
360 if mouse key=2 then goto 380
370 goto 350
380 XP=x mouse : YP=y mouse
390 wait vbl : sprite 1,XP,YP,1
400 put sprite 1
410 goto 350
420 fade 10
430 default : end
And now what the programme does.
10 rem **************************
20 rem *** ***
30 rem *** CHANGE MOUSE 3 ***
40 rem *** ***
50 rem **************************
Are the same as the previous programme, and inform you that this
is the third version of the same or similar programme.
Lines:
60 if mode<>0 then mode 0
70 cls : key off : curs off : hide on
80 if length(1)<>0 then goto 150
90 DRV=drive : drive=0 : dir$="A:\"
Are the same as the previous programme, and set up the screen and
the default disk drive.
Lines:
100 locate 10,10 : print "LOAD A SPRITE BANK" : wait 50
110 cls : show on : SPR$=file select$("*.MBK")
120 load SPR$
130 hide on : locate 10,10
140 print SPR$;" IS LOADED" : wait 50
Are the same as the previous programme, and load the sprites into
the sprite bank.
Lines:
150 cls
160 locate 0,0 : centre "Left mouse key = start"
170 locate 0,2 : centre "Right mouse key = Place"
180 locate 0,4 : centre "Both keys = Quit"
Are the same as the previous programme, and inform you of what
controls the programme.
Lines:
190 rem ** Find & Load Palette **
200 X=hunt(start(1) to start(1)+length(1),"PALT")
210 rem Add 4 to pass by string PALT
220 X=X+4
230 rem Copy to current palette.
240 for A=0 to 15
250 colour A,deek(X+A*2)
260 next A
Are new, and are the lines that get the true colours of the
sprites and replace the default colours. These were dealt with in
last months tutorial, I think, but it is not necessary to
understand them too well. However, I will detail their function
in the final programme of this lesson anyway.
Lines:
270 rem
280 MK=0
290 repeat
300 MK=mouse key
310 until MK=1
Set up a loop to test for the left mouse key being pressed.
Lines:
320 SP=1
330 show on
340 change mouse SP+3
Are the same as the previous programme, and display and then
change the mouse into a sprite. It should really have been change
and then display, as I said before, but does not really matter in
this case.
Lines:
350 if mouse key=3 then goto 420
360 if mouse key=2 then goto 380
370 goto 350
set up a loop to test fro a mouse key being pressed. IN this case
it ignores the left mouse key.
Lines:
380 XP=x mouse : YP=y mouse
390 wait vbl : sprite 1,XP,YP,1
400 put sprite 1
Do the same thing they did on the previous programme. Namely,
display a sprite to screen and then fix it to the screen. This
will become clearer in the next programme, when the sprites on
screen can be changed.
Line:
410 goto 350
Jumps back to the mouse test loop.
Lines:
420 fade 10
430 default : end
Quit the programme in a proper way.
This is the final lesson of this tutorial, there should have been
another one to test for the jigsaw being completed, but I did not
have time to write it.
Lesson 4
10 rem **************************
20 rem *** ***
30 rem *** CHANGE MOUSE 4 ***
40 rem *** ***
50 rem **************************
60 if mode<>0 then mode 0
70 cls : key off : curs off : hide on
80 if length(1)<>0 then goto 150
90 DRV=drive : drive=0 : dir$="A:\"
100 locate 10,10 : print "LOAD A SPRITE BANK" : wait 50
110 cls : show on : SPR$=file select$("*.MBK")
120 load SPR$
130 hide on : locate 10,10
140 print SPR$;" IS LOADED" : wait 50
150 cls
160 locate 0,0 : centre "Left mouse key = start"
170 locate 0,2 : centre "Right mouse key = Place"
180 locate 0,4 : centre "Both keys = Quit"
190 rem ** Find & Load Palette **
200 X=hunt(start(1) to start(1)+length(1),"PALT")
210 rem Add 4 to pass by string PALT
220 X=X+4
230 rem Copy to current palette.
240 for A=0 to 15
250 colour A,deek(X+A*2)
260 next A
270 rem
280 MK=0
290 repeat
300 MK=mouse key
310 until MK=1
320 SP=1
330 show on
340 if mouse key=3 then goto 450
350 if mouse key=2 then goto 410
360 if mouse key=1 then inc SP
370 if SP>=16 then SP=1
380 if SP<=0 then SP=15
390 change mouse SP+3
395 wait 20
400 goto 340
410 XP=x mouse : YP=y mouse
420 wait vbl : sprite 1,XP,YP,SP
430 put sprite 1
440 goto 350
450 fade 10
460 default : end
And now a bit more meat onto the bones.
10 rem **************************
20 rem *** ***
30 rem *** CHANGE MOUSE 4 ***
40 rem *** ***
50 rem **************************
These inform you that this is yet another version of the same
programme. In this case, I have been giving a different version
number to more or less each change in the programme. Once you are
programming yourself, you will only rename the version once you
make large changes to it.
You do this to remind you of which version is which, and there is
no point in creating a new version unless the changes are really
significant.
Lines:
60 if mode<>0 then mode 0
70 cls : key off : curs off : hide on
80 if length(1)<>0 then goto 150
90 DRV=drive : drive=0 : dir$="A:\"
Set up the initial screen and starting perameters that the
programme will run to.
LInes:
100 locate 10,10 : print "LOAD A SPRITE BANK" : wait 50
110 cls : show on : SPR$=file select$("*.MBK")
120 load SPR$
130 hide on : locate 10,10
140 print SPR$;" IS LOADED" : wait 50
Load in the sprites to the sprite bank.
Lines:
150 cls
160 locate 0,0 : centre "Left mouse key = start"
170 locate 0,2 : centre "Right mouse key = Place"
180 locate 0,4 : centre "Both keys = Quit"
Inform you of the control method.
Line:
190 rem ** Find & Load Palette **
Informs you this is where the sprite colour is obtained from.
Line:
200 X=hunt(start(1) to start(1)+length(1),"PALT")
Sets up a command to find the colours of the sprites. (Hunt)
searches for any given information that you have defined. Whilst
it it tied to searching within the length of bank 1. And (PALT)
is the bit that informs the programme that it is looking for the
sprite palette in bank 1.
Lines:
210 rem Add 4 to pass by string PALT
220 X=X+4
Inform you of why the value of (x) is set as it is, and then sets
the value of (x).
Lines:
230 rem Copy to current palette.
240 for A=0 to 15
250 colour A,deek(X+A*2)
260 next A
Set up a loop to copy the information from the sprite bank, and
replace each colour with the one that is found in the sprite bank.
Lines:
270 rem
280 MK=0
290 repeat 300 MK=mouse key
310 until MK=1
Set up the loop seen in the previous programmes, to test for a
mouse key - again, it is only testing for the left mouse key.
Lines:
320 SP=1
330 show on
Set the value of the first sprite to be changed into the mouse
pointer, and then make the mouse appear.
Line:
340 if mouse key=3 then goto 450
Tests to see of both mouse keys are being pressed, if so, it moves
on to terminate the programme.
Line:
350 if mouse key=2 then goto 410
Tests for the right mouse key being pressed, if so, it moves on to
place the sprite on the screen.
Line:
360 if mouse key=1 then inc SP
Tests to see if the left mouse key is being pressed, if so, it
alters the value of the sprite to change into the mouse pointer.
Lines:
370 if SP>=16 then SP=1
380 if SP<=0 then SP=15
Test to make sure that the value of (SP) is not greater or lower
than the number of sprites in the sprite bank. What it does is
loop the value around. So that if it becomes too large, it jumps
to the bottom sprite, and if too small, it jumps to the last
sprite.
Line:
390 change mouse SP+3
395 wait 20
Changes the mouse into the selected sprite, and then delays for a
short time to allow you to let go of the mouse key. Without the
pause, you would scroll through the sprites to fast to be able to
control them.
Line:
400 goto 340
Jumps back to the mousekey testing loop.
Lines:
410 XP=x mouse : YP=y mouse
420 wait vbl : sprite 1,XP,YP,SP
Set up the sprite on the screen where the mouse is. Notice that
the screen sprite is always set as (sprite 1), but that the sprite
that will become (sprite1) is dependant upon the current value of
(SP) which changes each time the left mouse key is pressed.
Line:
430 put sprite 1
Fixes the current (sprite 1) to the screen, so that it will not
disappear next time you press the right mouse key to place another
(sprite 1) onto the screen..
Line:
440 goto 350
Jumps back to the mouse key testing loop.
Lines:
450 fade 10
460 default : end
Quit the programme in an acceptable way, and return control back
to you.
Given time I would have improved these programmes. There needs to
be some way of ensuring that the mouse builds the jigsaw up
correctly. At the moment there is no checks made to see if the
pieces are in the proper places on screen, or if they are in the
proper order, or if there is more than one copy of each piece on
the screen.
The answer to placing the pieces so that they all fit on the
screen, can be taken from lesson 5 of last months tutorial. You
use the same system of checking their place on screen and their
order on screen.
However, you also need a way of only accessing those pieces that
have not been placed upon the screen. After all, you do not want
to have to sort through 15 pieces each time you place a piece.
Once you have placed a piece to screen it needs to be removed from
the accessible sprites to prevent it being places again.
Also you need to devise a way to remove sprites from screen that
are placed in the wrong place. Either by clicking on them to
remove them, or by replacing them with another sprite.
I will do this for you next tutorial, as well as explaining how to
squash and unsquash files, and why it is done.