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 >
Text File  |  1987-04-22  |  25KB  |  813 lines

  1.  
  2.  
  3. I assume little/no prior knowledge of Stos.  Each lesson will also 
  4. have a Stos BASic or ASCii file to go with it.
  5.  
  6. Listed here for your convenience.  i.e. to make it easier to write 
  7. them down or to look at the structure of the command. Are the new
  8. commands to be dealt with.
  9.  
  10. Do not worry if you find things hard at first, practice makes 
  11. perfect.  Actual progs are used to explain things, called 
  12. 'name.asc' and included in this folder.
  13.  
  14. The Main Commands:
  15.  
  16. CHANGE MOUSE     FADE      PUT SPRITE    LENGTH(N)  
  17.  
  18. If you have any problems, then look for the command on pages 
  19. 271/73 of the manual.  This is not intended to replace the manual,
  20. but to add to it where needed. 
  21.  
  22.  
  23. Right then, there would have been more commands and a better 
  24. tutorial this time except for the computer breaking down, and me 
  25. only just getting it back.
  26.  
  27. I had intended to cover Squashing and Unsquashing this time, and 
  28. also show a finished version of the jigsaw creator - or at least 
  29. how to make everything work - but as I only got he computer back 
  30. yesterday, and this has to be sent away today, I decided to limit 
  31. it to changing the mouse sprite, and showing how to place the 
  32. jigsaw piece on the screen.
  33.  
  34.  
  35.  
  36.  
  37. Lesson 1
  38.  
  39.  
  40. 10 rem **************************
  41. 20 rem ***                    ***
  42. 30 rem ***   CHANGE MOUSE     ***
  43. 40 rem ***                    ***
  44. 50 rem **************************
  45. 60 if mode<>0 then mode 0
  46. 70 cls : key off : curs off : hide on
  47. 80 if length(1)<>0 then goto 150
  48. 90 DRV=drive : drive=0 : dir$="A:\"
  49. 100 locate 10,10 : print "LOAD A SPRITE BANK" : wait 50
  50. 110 cls : show on : SPR$=file select$("*.MBK")
  51. 120 load SPR$
  52. 130 hide on : locate 10,10
  53. 140 print SPR$;" IS LOADED" : wait 50
  54. 150 cls
  55. 160 locate 0,0 : centre "Mouse key = start"
  56. 170 MK=0
  57. 180 repeat 190 MK=mouse key
  58. 200 until MK<>0
  59. 210 SP=1
  60. 220 show on
  61. 230 change mouse SP+3
  62. 240 if mouse key=3 then goto 250 else goto 240
  63. 250 fade 10
  64. 260 default : end
  65.  
  66.  
  67. These four lessons are all virtually the same, but I will take you 
  68. through each new idea as it is implemented.  This lesson just 
  69. changes the mouse into the first sprite in the bank.
  70.  
  71.  
  72. Lines:
  73.  
  74. 10 rem **************************
  75. 20 rem ***                    ***
  76. 30 rem ***   CHANGE MOUSE     ***
  77. 40 rem ***                    ***
  78. 50 rem **************************
  79.  
  80. Inform you of what the programme is intended to do.
  81.  
  82. Lines:
  83. 60 if mode<>0 then mode 0
  84. 70 cls : key off : curs off : hide on
  85.  
  86. Set the screen up by checking the resolution, then clearing the 
  87. screen of any rubbish, and hiding the mouse and cursor. 
  88.  
  89. Line:
  90. 80 if length(1)<>0 then goto 150
  91.  
  92. This is a new idea. It it checks to see if there is anything in 
  93. BANK 1 - it is bank one because that is the default sprite bank, 
  94. and whilst you can store sprites in other banks, you can not 
  95. display them until they are placed in bank 1. 
  96.  
  97. The (LENGTH(n)) command informs you of how large the particular 
  98. bank is.  The (n) is which ever bank you nominate.  In this case 
  99. it is bank 1 as that is the sprite bank.
  100.  
  101. The check is to see if (n=0) - in fact it checks to make sure it 
  102. does not equal zero - if (n) does equal zero then there are no 
  103. sprites loaded in bank 1, and it will ask you to load a sprite 
  104. bank later on.  If it is not zero then there is a sprite bank 
  105. already loaded so it jumps to the next part of the programme.
  106.  
  107. Line:
  108. 90 DRV=drive : drive=0 : dir$="A:\"
  109.  
  110. This is only activated if there is no sprite bank loaded in.  I.e. 
  111. only the first time the programme is run, or the loop is operated. 
  112. It stores the current drive, then resets to drive A: and the root 
  113. directory, so that when the programme ends it takes you back to 
  114. where you ran the programme from.
  115.  
  116. If this line was missed out then the programme would remain  
  117. wherever you loaded the sprites from.  Basically, it allows you to 
  118. run the programme from one disk drive/ram disk, and then defaults 
  119. to Drive A: in order to load the sprites from Drive A:, and then 
  120. return to the place it started from, rather than remaining on 
  121. drive A:
  122.  
  123.  
  124. Lines:
  125. 100 locate 10,10 : print "LOAD A SPRITE BANK" : wait 50
  126. 110 cls : show on : SPR$=file select$("*.MBK")
  127. 120 load SPR$
  128. 130 hide on : locate 10,10
  129. 140 print SPR$;" IS LOADED" : wait 50
  130.  
  131. Are the bit that allows you to load a sprite bank, and have been 
  132. dealt with in last months tutorial, but for those who missed it. 
  133.  
  134. A message is printed on screen - actually the screen should have 
  135. been cleared here with a (CLS) first just in case there was any 
  136. junk on the screen.
  137.  
  138. Then the message is removed and the mouse is shown in order to 
  139. allow you to select the appropriate file.  The file selector is 
  140. called by the (FILE SELECT("*.MBK") command.  And the file type is 
  141. set to (MBK) as this is what we want.  It could have been (Neo) or 
  142. (PI1) for a screen, or even (PAC) which is a squashed file.
  143.  
  144. The (SPR$) is the variable created to hold the name of the 
  145. selected file, and is then used with the (LOAD SPR) command to 
  146. load it into a bank.
  147.  
  148. The mouse is then hidden again, and the message informing you that 
  149. the task is completed appears.
  150.  
  151.  
  152. Lines:
  153. 150 cls
  154. 160 locate 0,0 : centre "Mouse key = start"
  155.  
  156. Inform you of what to do after clearing the screen,  There should 
  157. have been another line here informing you that if you press both 
  158. mouse keys together, then the programme will quit back to the 
  159. editor.  It was missed off, and I do not have time to alter this, 
  160. however it is corrected on all the other lessons.
  161.  
  162. Lines:
  163. 170 MK=0
  164. 180 repeat 190 MK=mouse key
  165. 200 until MK<>0
  166.  
  167. Set up a loop that continues until any mouse key is pressed.
  168.  
  169. Line:
  170. 210 SP=1
  171.  
  172. Sets up a variable to store the value of the sprite to use with 
  173. the (Change mouse) command later.  Normally it would be linked to 
  174. the mouse key pressed, so as to store the first press - in case I 
  175. wanted to use the mouse to do something else, or pressed another 
  176. key afterwards.  But in this case I wanted it to remain fixed as 
  177. sprite 1, so I made (SP) a fixed value rather than linking it to 
  178. the mouse key as (SP = MK) because (MK = MOUSE KEY) but only 
  179. within the loop.
  180.  
  181. If you are confused I will be explaining this nest time in more 
  182. detail, as I am pushed for time at the moment..
  183.  
  184.  
  185. Lines:
  186. 220 show on
  187. 230 change mouse SP+3
  188.  
  189. Make the mouse key appear and then change it to the selected 
  190. sprite.  (SP+3) because the Mouse already can take a value between 
  191. 1 and 3, so it has to be (3) plus the sprite value.
  192.  
  193. Here again, I notice a mistake.  The (Show) command should have 
  194. come after the (Change Mouse).
  195.  
  196. Why?  Well if the programme was running slower - put a (225 Wait 
  197. 200) to see the effect - then it would first make the mouse 
  198. pointer appear, and then change it to the sprite. 
  199.  
  200. The point being that we do not want to see the mouse pointer, only 
  201. the sprite, so I should have placed the (Show) command after the 
  202. mouse pointer had been changed.
  203.  
  204. The same principle applies to compiled programmes.  If you forget 
  205. to turn the KEYs off within the Compiler, then the Editor screen 
  206. will flash to screen when you run a compiled programme.
  207.  
  208.  
  209. Line:
  210. 240 if mouse key=3 then goto 250 else goto 240
  211.  
  212. Tests to see if both mouse keys are being pressed.  If so it jumps 
  213. to line 250, if not it loops around and starts another test.
  214.  
  215. Lines:
  216. 250 fade 10
  217. 260 default : end
  218.  
  219. Quit the programme in a proper manner, returning you to the 
  220. default settings.  I always start off with a medium resolution 
  221. screen, as it is easier to read the programme there than in low 
  222. resolution.
  223.  
  224. The (DEFAULT) command resets the mouse and cursor and keys (MENU 
  225. at top of screen), but is simpler than entering each command one 
  226. at a time.
  227.  
  228. The (End) command is not really needed, but it is nice to finish 
  229. up cleanly, so I put it in there.  The difference between it and 
  230. (STOP) is that it will not allow the programme to start up again 
  231. with a (CONTINUE) command.
  232.  
  233.  
  234.  
  235. Well there was not really that much to the previous programme, and 
  236. this is much the same thing, with just a few frills added to it.  
  237. Neither this, nor the previous programme attempted to get the 
  238. proper colours for the sprite bank, and as a result they are 
  239. displayed in the default colours.
  240.  
  241.  
  242. Lesson 2
  243.  
  244. 10 rem **************************
  245. 20 rem ***                    ***
  246. 30 rem ***   CHANGE MOUSE 2   ***
  247. 40 rem ***                    ***
  248. 50 rem **************************
  249. 60 if mode<>0 then mode 0
  250. 70 cls : key off : curs off : hide on
  251. 80 if length(1)<>0 then goto 150
  252. 90 DRV=drive : drive=0 : dir$="A:\"
  253. 100 locate 10,10 : print "LOAD A SPRITE BANK" : wait 50
  254. 110 cls : show on : SPR$=file select$("*.MBK")
  255. 120 load SPR$
  256. 130 hide on : locate 10,10
  257. 140 print SPR$;" IS LOADED" : wait 50
  258. 150 cls
  259. 160 locate 0,0 : centre "Left mouse key = start"
  260. 170 locate 0,2 : centre "Right mouse key = Place"
  261. 180 locate 0,4 : centre "Both keys = Quit"
  262. 190 MK=0
  263. 200 repeat
  264. 210 MK=mouse key
  265. 220 until MK=1
  266. 240 SP=1
  267. 250 show on 260 change mouse SP+3
  268. 270 if mouse key=3 then goto 340
  269. 280 if mouse key=2 then goto 300
  270. 290 goto 270
  271. 300 XP=x mouse : YP=y mouse
  272. 310 wait vbl : sprite 1,XP,YP,1
  273. 320 put sprite 1
  274. 330 goto 270
  275. 340 fade 10
  276. 350 default : end
  277.  
  278.  
  279. And now for the explanation of the programme.  This time the 
  280. sprite will be able to be placed to the screen by pressing the 
  281. left mouse key.  For some odd reason there is a line missing from 
  282. this programme.  Usually I renumber the programme with (RENUM) 
  283. after deleting a line, but I must of forgotten here. 
  284.  
  285. So line 230 is meant to be missing, and the programme should have 
  286. been renumbered to correct this, but I missed it, and do not have 
  287. time to change all three parts of this programme.
  288.  
  289. I should point out that I load the ascii text into a wp prog and 
  290. then duplicate it.  However, I am not able to just load in the 
  291. modified text and copy it now, because this programme does odd 
  292. things when I try to do that, and I might loose everything, or 
  293. spend hours resetting everything up again.  And as you know I am 
  294. short of time.  So I will just point out any errors I see.
  295.  
  296.  
  297. Lines:
  298. 10 rem **************************
  299. 20 rem ***                    ***
  300. 30 rem ***   CHANGE MOUSE 2   ***
  301. 40 rem ***                    ***
  302. 50 rem **************************
  303.  
  304. Tell you what the programme does, and that this is a different 
  305. version from the first programme.  If it was significant, then I 
  306. would enter a few more lines of code to explain the changes.
  307.  
  308. Lines:
  309. 60 if mode<>0 then mode 0
  310. 70 cls : key off : curs off : hide on
  311. 80 if length(1)<>0 then goto 150
  312. 90 DRV=drive : drive=0 : dir$="A:\"
  313.  
  314. Are the same as the previous programme, and set up the screen and 
  315. default disk drive.
  316.  
  317. Lines:
  318. 100 locate 10,10 : print "LOAD A SPRITE BANK" : wait 50
  319. 110 cls : show on : SPR$=file select$("*.MBK")
  320. 120 load SPR$
  321. 130 hide on : locate 10,10
  322. 140 print SPR$;" IS LOADED" : wait 50
  323.  
  324. Are the same as the previous programme, and load in the sprites.
  325.  
  326. Lines:
  327. 150 cls
  328. 160 locate 0,0 : centre "Left mouse key = start"
  329. 170 locate 0,2 : centre "Right mouse key = Place"
  330. 180 locate 0,4 : centre "Both keys = Quit"
  331.  
  332. Are a bit different.  This time I remembered to clear the screen 
  333. before the message appears, in case there is junk on the screen 
  334. from before the programme was run. 
  335.  
  336. They inform you of how to control the programme.  I.E. by pressing 
  337. a mouse key.
  338.  
  339. Lines:
  340. 190 MK=0
  341. 200 repeat 210 MK=mouse key
  342. 220 until MK=1
  343.  
  344. Are slightly different.  This time the loop is set up to test for 
  345. the left mouse key, and repeats until it is pressed.  In the 
  346. previous programme it was set up to test for any mouse key being 
  347. pressed.  But as key two is being used, and both together would 
  348. quit the programme, we have to make sure that they are not pressed 
  349. at this stage.
  350.  
  351. Lines:
  352. 240 SP=1
  353. 250 show on
  354. 260 change mouse SP+3
  355.  
  356. Are the same as the previous programme.  Again, note that the 
  357. value of (SP) has to take into account the three preset mouse 
  358. shapes, and thus must have a value of at least (4).
  359.  
  360. Lines:
  361. 270 if mouse key=3 then goto 340
  362. 280 if mouse key=2 then goto 300
  363. 290 goto 270
  364.  
  365. Test to see if either the left mouse key or both are being 
  366. pressed.  The left key jumps out of the loop to continue the 
  367. programme, and both keys together jump to the lines that quit the 
  368. programme in a proper fashion.
  369.  
  370. Line:
  371. 300 XP=x mouse : YP=y mouse
  372.  
  373. Stores the current values of the mouse co-ordinates, so that you 
  374. always have access to where the mouse is located on the screen.  
  375. This will be used to position the sprite to screen at the correct 
  376. position on the screen.
  377.  
  378. Line:
  379. 310 wait vbl : sprite 1,XP,YP,1
  380.  
  381. Waits for the next Vertical Line Break - which is when the screen 
  382. is updated - and then places a sprite at the co-ordinates of the 
  383. mouse pointer.  In this case it is a fixed sprite value - sprite 1 
  384. out of the bank - and makes it the first sprite on the screen.
  385.  
  386. Remember that the Mouse has a sprite value of zero, and the 
  387. sprites that are normally shown on the screen range from (1) to 
  388. (15).  Which unfortunately, is the same amount of sprites in the 
  389. sprite bank, so do not get confused.
  390.  
  391. Line:
  392. 320 put sprite 1
  393.  
  394. Copies the sprite being shown to the screen, so that it is no 
  395. longer classed as a sprite, and is fixed permanently in place.  
  396. Although the mouse is still shown as the same sprite.
  397.  
  398. Remember that although the first sprite in the bank is also the 
  399. one being displayed as sprite 1 - i.e. (sprite 1,x,y,1) - it could 
  400. just as easily have been sprite 6 from the sprite bank being 
  401. displayed as sprite 1 on the screen - i.e. (SPRITE 1,x,y,6).
  402.  
  403. Line:
  404. 330 goto 270
  405.  
  406. Loops back to check if a mouse key is being pressed.
  407.  
  408.  
  409. Lines:
  410. 340 fade 10
  411. 350 default : end
  412.  
  413. Quit the programme in a proper manner.
  414.  
  415.  
  416. This next lesson is the same as the previous lesson, except that 
  417. it now displays the sprites in their true colours.
  418.  
  419.  
  420. Lesson 3
  421.  
  422. 10 rem **************************
  423. 20 rem ***                    ***
  424. 30 rem ***   CHANGE MOUSE 3   ***
  425. 40 rem ***                    ***
  426. 50 rem **************************
  427. 60 if mode<>0 then mode 0
  428. 70 cls : key off : curs off : hide on
  429. 80 if length(1)<>0 then goto 150
  430. 90 DRV=drive : drive=0 : dir$="A:\"
  431. 100 locate 10,10 : print "LOAD A SPRITE BANK" : wait 50
  432. 110 cls : show on : SPR$=file select$("*.MBK")
  433. 120 load SPR$
  434. 130 hide on : locate 10,10
  435. 140 print SPR$;" IS LOADED" : wait 50
  436. 150 cls
  437. 160 locate 0,0 : centre "Left mouse key = start"
  438. 170 locate 0,2 : centre "Right mouse key = Place"
  439. 180 locate 0,4 : centre "Both keys = Quit"
  440. 190 rem ** Find & Load Palette **
  441. 200 X=hunt(start(1) to start(1)+length(1),"PALT")
  442. 210 rem Add 4 to pass by string PALT
  443. 220 X=X+4
  444. 230 rem Copy to current palette.
  445. 240 for A=0 to 15
  446. 250 colour A,deek(X+A*2)
  447. 260 next A
  448. 270 rem
  449. 280 MK=0
  450. 290 repeat
  451. 300 MK=mouse key
  452. 310 until MK=1
  453. 320 SP=1
  454. 330 show on
  455. 340 change mouse SP+3
  456. 350 if mouse key=3 then goto 420
  457. 360 if mouse key=2 then goto 380
  458. 370 goto 350
  459. 380 XP=x mouse : YP=y mouse
  460. 390 wait vbl : sprite 1,XP,YP,1
  461. 400 put sprite 1
  462. 410 goto 350
  463. 420 fade 10
  464. 430 default : end
  465.  
  466.  
  467. And now what the programme does.
  468.  
  469. 10 rem **************************
  470. 20 rem ***                    ***
  471. 30 rem ***   CHANGE MOUSE 3   ***
  472. 40 rem ***                    ***
  473. 50 rem **************************
  474.  
  475. Are the same as the previous programme, and inform you that this 
  476. is the third version of the same or  similar programme.
  477.  
  478. Lines:
  479. 60 if mode<>0 then mode 0
  480. 70 cls : key off : curs off : hide on
  481. 80 if length(1)<>0 then goto 150
  482. 90 DRV=drive : drive=0 : dir$="A:\"
  483.  
  484. Are the same as the previous programme, and set up the screen and 
  485. the default disk drive.
  486.  
  487. Lines:
  488. 100 locate 10,10 : print "LOAD A SPRITE BANK" : wait 50
  489. 110 cls : show on : SPR$=file select$("*.MBK")
  490. 120 load SPR$
  491. 130 hide on : locate 10,10
  492. 140 print SPR$;" IS LOADED" : wait 50
  493.  
  494. Are the same as the previous programme, and load the sprites into 
  495. the sprite bank.
  496.  
  497. Lines:
  498. 150 cls
  499. 160 locate 0,0 : centre "Left mouse key = start"
  500. 170 locate 0,2 : centre "Right mouse key = Place"
  501. 180 locate 0,4 : centre "Both keys = Quit"
  502.  
  503. Are the same as the previous programme, and inform you of what 
  504. controls the programme.
  505.  
  506. Lines:
  507. 190 rem ** Find & Load Palette **
  508. 200 X=hunt(start(1) to start(1)+length(1),"PALT")
  509. 210 rem Add 4 to pass by string PALT
  510. 220 X=X+4
  511. 230 rem Copy to current palette.
  512. 240 for A=0 to 15
  513. 250 colour A,deek(X+A*2)
  514. 260 next A
  515.  
  516. Are new, and are the lines that get the true colours of the 
  517. sprites and replace the default colours.  These were dealt with in 
  518. last months tutorial, I think, but it is not necessary to 
  519. understand them too well.  However, I will detail their function 
  520. in the final programme of this lesson anyway.
  521.  
  522. Lines:
  523. 270 rem
  524. 280 MK=0
  525. 290 repeat
  526. 300 MK=mouse key
  527. 310 until MK=1
  528.  
  529. Set up a loop to test for the left mouse key being pressed.
  530.  
  531. Lines:
  532. 320 SP=1
  533. 330 show on
  534. 340 change mouse SP+3
  535.  
  536. Are the same as the previous programme, and display and then 
  537. change the mouse into a sprite.  It should really have been change 
  538. and then display, as I said before, but does not really matter in 
  539. this case.
  540.  
  541. Lines:
  542. 350 if mouse key=3 then goto 420
  543. 360 if mouse key=2 then goto 380
  544. 370 goto 350
  545.  
  546. set up a loop to test fro a mouse key being pressed.  IN this case 
  547. it ignores the left mouse key.
  548.  
  549. Lines:
  550. 380 XP=x mouse : YP=y mouse
  551. 390 wait vbl : sprite 1,XP,YP,1
  552. 400 put sprite 1
  553.  
  554. Do the same thing they did on the previous programme.  Namely, 
  555. display a sprite to screen and then fix it to the screen.  This 
  556. will become clearer in the next programme, when the sprites on 
  557. screen can be changed.
  558.  
  559. Line:
  560. 410 goto 350
  561.  
  562. Jumps back to the mouse test loop.
  563.  
  564. Lines:
  565. 420 fade 10
  566. 430 default : end
  567.  
  568. Quit the programme in a proper way.
  569.  
  570.  
  571. This is the final lesson of this tutorial, there should have been 
  572. another one to test for the jigsaw being completed, but I did not 
  573. have time to write it.
  574.  
  575.  
  576. Lesson 4
  577.  
  578. 10 rem **************************
  579. 20 rem ***                    ***
  580. 30 rem ***   CHANGE MOUSE 4   ***
  581. 40 rem ***                    ***
  582. 50 rem **************************
  583. 60 if mode<>0 then mode 0
  584. 70 cls : key off : curs off : hide on
  585. 80 if length(1)<>0 then goto 150
  586. 90 DRV=drive : drive=0 : dir$="A:\"
  587. 100 locate 10,10 : print "LOAD A SPRITE BANK" : wait 50
  588. 110 cls : show on : SPR$=file select$("*.MBK")
  589. 120 load SPR$
  590. 130 hide on : locate 10,10
  591. 140 print SPR$;" IS LOADED" : wait 50
  592. 150 cls
  593. 160 locate 0,0 : centre "Left mouse key = start"
  594. 170 locate 0,2 : centre "Right mouse key = Place"
  595. 180 locate 0,4 : centre "Both keys = Quit"
  596. 190 rem ** Find & Load Palette **
  597. 200 X=hunt(start(1) to start(1)+length(1),"PALT")
  598. 210 rem Add 4 to pass by string PALT
  599. 220 X=X+4
  600. 230 rem Copy to current palette.
  601. 240 for A=0 to 15
  602. 250 colour A,deek(X+A*2)
  603. 260 next A
  604. 270 rem
  605. 280 MK=0
  606. 290 repeat
  607. 300 MK=mouse key
  608. 310 until MK=1
  609. 320 SP=1
  610. 330 show on
  611. 340 if mouse key=3 then goto 450
  612. 350 if mouse key=2 then goto 410
  613. 360 if mouse key=1 then inc SP
  614. 370 if SP>=16 then SP=1
  615. 380 if SP<=0 then SP=15
  616. 390 change mouse SP+3
  617. 395 wait 20
  618. 400 goto 340
  619. 410 XP=x mouse : YP=y mouse
  620. 420 wait vbl : sprite 1,XP,YP,SP
  621. 430 put sprite 1
  622. 440 goto 350
  623. 450 fade 10
  624. 460 default : end
  625.  
  626.  
  627. And now a bit more meat onto the bones.
  628.  
  629. 10 rem **************************
  630. 20 rem ***                    ***
  631. 30 rem ***   CHANGE MOUSE  4  ***
  632. 40 rem ***                    ***
  633. 50 rem **************************
  634.  
  635. These inform you that this is yet another version of the same 
  636. programme.  In this case, I have been giving a different version 
  637. number to more or less each change in the programme.  Once you are 
  638. programming yourself, you will only rename the version once you 
  639. make large changes to it. 
  640.  
  641. You do this to remind you of which version is which, and there is 
  642. no point in creating a new version unless the changes are really 
  643. significant.
  644.  
  645. Lines:
  646. 60 if mode<>0 then mode 0
  647. 70 cls : key off : curs off : hide on
  648. 80 if length(1)<>0 then goto 150
  649. 90 DRV=drive : drive=0 : dir$="A:\"
  650.  
  651. Set up the initial screen and starting perameters that the 
  652. programme will run to.
  653.  
  654. LInes:
  655. 100 locate 10,10 : print "LOAD A SPRITE BANK" : wait 50
  656. 110 cls : show on : SPR$=file select$("*.MBK")
  657. 120 load SPR$
  658. 130 hide on : locate 10,10
  659. 140 print SPR$;" IS LOADED" : wait 50
  660.  
  661. Load in the sprites to the sprite bank.
  662.  
  663. Lines:
  664. 150 cls
  665. 160 locate 0,0 : centre "Left mouse key = start"
  666. 170 locate 0,2 : centre "Right mouse key = Place"
  667. 180 locate 0,4 : centre "Both keys = Quit"
  668.  
  669. Inform you of the control method.
  670.  
  671. Line:
  672. 190 rem ** Find & Load Palette **
  673.  
  674. Informs you this is where the sprite colour is obtained from.
  675.  
  676. Line:
  677. 200 X=hunt(start(1) to start(1)+length(1),"PALT")
  678.  
  679. Sets up a command to find the colours of the sprites.  (Hunt) 
  680. searches for any given information that you have defined.  Whilst 
  681. it it tied to searching within the length of bank 1.  And (PALT) 
  682. is the bit that informs the programme that it is looking for the 
  683. sprite palette in bank 1.
  684.  
  685. Lines:
  686. 210 rem Add 4 to pass by string PALT
  687. 220 X=X+4
  688.  
  689. Inform you of why the value of (x) is set as it is, and then sets 
  690. the value of (x).
  691.  
  692. Lines:
  693. 230 rem Copy to current palette.
  694. 240 for A=0 to 15
  695. 250 colour A,deek(X+A*2)
  696. 260 next A
  697.  
  698. Set up a loop to copy the information from the sprite bank, and 
  699. replace each colour with the one that is found in the sprite bank.
  700.  
  701. Lines:
  702. 270 rem
  703. 280 MK=0
  704. 290 repeat 300 MK=mouse key
  705. 310 until MK=1
  706.  
  707. Set up the loop seen in the previous programmes, to test for a 
  708. mouse key - again, it is only testing for the left mouse key.
  709.  
  710. Lines:
  711. 320 SP=1
  712. 330 show on
  713.  
  714. Set the value of the first sprite to be changed into the mouse 
  715. pointer, and then make the mouse appear.
  716.  
  717. Line:
  718. 340 if mouse key=3 then goto 450
  719.  
  720. Tests to see of both mouse keys are being pressed, if so, it moves 
  721. on to terminate the programme.
  722.  
  723. Line:
  724. 350 if mouse key=2 then goto 410
  725.  
  726. Tests for the right mouse key being pressed, if so, it moves on to 
  727. place the sprite on the screen.
  728.  
  729. Line:
  730. 360 if mouse key=1 then inc SP
  731.  
  732. Tests to see if the left mouse key is being pressed, if so, it 
  733. alters the value of the sprite to change into the mouse pointer.
  734.  
  735. Lines:
  736. 370 if SP>=16 then SP=1
  737. 380 if SP<=0 then SP=15
  738.  
  739. Test to make sure that the value of (SP) is not greater or lower 
  740. than the number of sprites in the sprite bank.  What it does is 
  741. loop the value around.  So that if it becomes too large, it jumps 
  742. to the bottom sprite, and if too small, it jumps to the last 
  743. sprite.
  744.  
  745. Line:
  746. 390 change mouse SP+3
  747. 395 wait 20
  748.  
  749. Changes the mouse into the selected sprite, and then delays for a 
  750. short time to allow you to let go of the mouse key.  Without the 
  751. pause, you would scroll through the sprites to fast to be able to 
  752. control them.
  753.  
  754. Line:
  755. 400 goto 340
  756.  
  757. Jumps back to the mousekey testing loop.
  758.  
  759. Lines:
  760. 410 XP=x mouse : YP=y mouse
  761. 420 wait vbl : sprite 1,XP,YP,SP
  762.  
  763. Set up the sprite on the screen where the mouse is.  Notice that 
  764. the screen sprite is always set as (sprite 1), but that the sprite 
  765. that will become (sprite1) is dependant upon the current value of 
  766. (SP) which changes each time the left mouse key is pressed.
  767.  
  768. Line:
  769. 430 put sprite 1
  770.  
  771. Fixes the current (sprite 1) to the screen, so that it will not 
  772. disappear next time you press the right mouse key to place another 
  773. (sprite 1) onto the screen..
  774.  
  775. Line:
  776. 440 goto 350
  777.  
  778. Jumps back to the mouse key testing loop.
  779.  
  780. Lines:
  781. 450 fade 10
  782. 460 default : end 
  783.  
  784. Quit the programme in an acceptable way, and return control back 
  785. to you. 
  786.  
  787. Given time I would have improved these programmes.  There needs to 
  788. be some way of ensuring that the mouse builds the jigsaw up 
  789. correctly.  At the moment there is no checks made to see if the 
  790. pieces are in the proper places on screen, or if they are in the 
  791. proper order, or if there is more than one copy of each piece on 
  792. the screen.
  793.  
  794.         The answer to placing the pieces so that they all fit on the 
  795. screen, can be taken from lesson 5 of last months tutorial.  You 
  796. use the same system of checking their place on screen and their 
  797. order on screen.
  798.  
  799. However, you also need a way of only accessing those pieces that 
  800. have not been placed upon the screen.  After all, you do not want 
  801. to have to sort through 15 pieces each time you place a piece.  
  802. Once you have placed a piece to screen it needs to be removed from 
  803. the accessible sprites to prevent it being places again.
  804.  
  805. Also you need to devise a way to remove sprites from screen that 
  806. are placed in the wrong place.  Either by clicking on them to 
  807. remove them, or by replacing them with another sprite.
  808.  
  809. I will do this for you next tutorial, as well as explaining how to 
  810. squash and unsquash files, and why it is done.
  811.  
  812.  
  813.