home *** CD-ROM | disk | FTP | other *** search
/ AMOS PD CD / amospdcd.iso / sourcecode / procedures / letter_slide.amos / letter_slide.amosSourceCode < prev    next >
AMOS Source Code  |  1993-03-07  |  5KB  |  141 lines

  1. '**************************************************************
  2. '        
  3. '                     LETTER SLIDE 
  4. '                          
  5. '                  Copyright (c) 1993
  6. '  
  7. '                Peter Paton & Vic Webber
  8. '
  9. '  Having almost completed our first ever game we were playing 
  10. '  with ideas for the intro screens and, as the game is a sliding
  11. '  tile type puzzle game, thought it might be nice to have some
  12. '  sliding letters on the title screen.
  13. '
  14. '  Everybody does this type of thing by just sliding letters at random 
  15. '  onto the screen to form words, but we wanted to be different so we  
  16. '  came up with the idea that we could make up an anagram of the game  
  17. '  title and get the letters from the title to slide into the anagram. 
  18. '
  19. '  This was the first attempt and took just a couple of hours. 
  20. '
  21. '  The letters move at a nice sedate pace, but if you take out the 
  22. '  Wait Vbl instructions it will leave you breathless. 
  23. '
  24. '  I have Rem(ed) most of the code and you are welcome to use
  25. '  routine and adapt it for your own programs. 
  26. '
  27. '  Big thanks to my wife Cath for the anagram of Amiga Stepping Stones 
  28. '  She is 20 years younger than me and thinks along totally different
  29. '  lines to me. My own anagram was so boring that I won't even tell you it.
  30. '  If you want to tell her that you can't have two G's in MEGGA then 
  31. '  she may well tell you where to stick the spare G
  32. '
  33. '  The bob files have been included on the disk in Tiles.Abk 
  34. '
  35. '    
  36. Screen Open 0,320,256,32,Lowres
  37. Flash Off : Curs Off : Hide On 
  38. Cls 16
  39. Palette 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  40. '
  41. Global C$,_MOVE$
  42. '
  43. _STRING["AMOS",132,80]
  44. _STRING[" AMIGA STEPPING STONES ",55,100]
  45. '
  46. ' The spaces at the ends of Amiga Stepping Stones are simply padding 
  47. ' to make the two trings the same length and thus make them print
  48. ' at the same csreen address. This helps to make the maths easier. 
  49. ' Note that the anagram string has two extra spaces in the words.
  50. '
  51. _MOVE$=C$
  52. _STRING["STEPS INTO A MEGGA SPIN",55,132]
  53. '
  54. ' Now get the original bob palette back and the letters appear 
  55. ' in one go
  56. Fade 1 To -1
  57. '
  58. ' Wait to allow you time to read what's on the screen
  59. Wait 200
  60. '
  61. '
  62. _MOVE_CHAR
  63. '
  64. ' This first procedure is an adaptation of the idea used in text scrolling 
  65. ' where leters are taken from another screen and placed into a scroll. 
  66. '
  67. ' We simply made an 8x8 font in Dpaint and then cut it into bobs 
  68. ' these start at bob No. 20 in the Tiles.Abk 
  69. '
  70. '  
  71. Procedure _STRING[C$,CPOSX,CPOSY]
  72. ' T$ holds a string giving the position of the 8x8 bobs in the file
  73.    T$="ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789+"
  74. ' C$ is the string to be printed 
  75.    For I=1 To Len(C$)
  76. ' C2$ holds the letters within C$
  77.       C2$=Mid$(C$,I,1)
  78. ' C is set to the position of C2$ within T$
  79. ' This has 19 added to it because the bobs start at 20 in the bank 
  80.       C=Instr(T$,C2$)
  81.       Paste Bob CPOSX,CPOSY,C+19
  82. ' CPOSX and CPOSY hold the graphic co-ordinates of the top left corner 
  83. ' of the first letter of C$ and is incremented by 8 for each character 
  84. ' printed. (8x8 font so add 8 pixels)
  85.       CPOSX=CPOSX+8
  86.    Next 
  87. End Proc
  88. Procedure _MOVE_CHAR
  89. ' This is the real work horse of the routine 
  90. '  
  91. ' Notice from the program above that _MOVE$ is picked up from
  92. ' the game title string. 
  93. '
  94. ' Now pick each letter in turn 
  95.    For L=1 To Len(_MOVE$)
  96.       X1=55+((L-1)*8) : Rem Top left corner of letter
  97.       X2=X1+8 : Rem 8 is the letters width 
  98.       Y1=99 : Rem Top line of letter-1 to avoid leaving trails 
  99.       Y2=131 : Rem Bottom of first scroll definition
  100.       QQ$=Mid$(_MOVE$,L,1) : Rem Grab the letter from the title 
  101.       QQ=Instr(C$,QQ$) : Rem find the first matching letter in the anagram
  102.       Mid$(C$,QQ,1)=" " : Rem and turn it into a space 
  103.       X3=55+((QQ-1)*8) : Rem Then find its graphic position 
  104.       X4=X3+8 : Rem Set right hand side of 3rd scroll zone 
  105.  
  106. ' Now we nee to set the direction for the horizontal scroll
  107.       If X3<X1 Then D=-1 : X5=X1-X3 Else D=1 : X5=X3-X1
  108. ' Set the ink colour for the letter to the loop counter
  109.       Ink L
  110. ' Theres no point in scrolling a blank space so skip it
  111.       If QQ$=" " Then Goto SKIP
  112. ' The paint co-ordinates had to find a spot which was set in all letters 
  113. ' and we could have done this scientifically but we just took a guess
  114. ' at 3 pixels in and 2 pixels down and got lucky, (jammy buggers). 
  115.       Paint X1+3,Y1+2 : Wait 50
  116. ' Now set up the 3 scroll definitions
  117.       Def Scroll 1,X1,Y1 To X2,Y2,0,1
  118.       Def Scroll 2,55,120 To 247,131,D,0
  119.       Def Scroll 3,X3,119 To X4,152,0,1
  120. '
  121. ' This loop does the first downward slide        
  122.       For I=1 To 20
  123.          Scroll 1
  124.          Wait Vbl 
  125.       Next 
  126. ' These two are for the left or right scroll 
  127. ' If D=1 then scroll left to right 
  128. ' If D=-1 then scroll right to left  
  129. ' The co-ordinates need to be turned round if D=-1 to define 
  130. ' rectangle to be scrolled properly where right side is > left side  
  131.       If D=1 Then For I=1 To X5 : Scroll 2 : Wait Vbl : Next 
  132.       If D=-1 Then For I=X5 To 1 Step D : Scroll 2 : Wait Vbl : Next 
  133. ' And last but not least drop the letters into place 
  134.       For I=1 To 12
  135.          Scroll 3
  136.          Wait Vbl 
  137.       Next 
  138. ' Land here to avoid moving blank spaces 
  139.       SKIP:
  140.    Next 
  141. End Proc