home *** CD-ROM | disk | FTP | other *** search
/ AMOS PD CD / amospdcd.iso / totallyamos / issue4 / programming / 1.seq next >
Encoding:
Text File  |  1992-03-10  |  6.8 KB  |  210 lines

  1. ddd00000ff00fe0080888000a3f
  2. ^7TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
  3.  
  4. ^1                        PROGRAMMING HINTS AND TIPS.
  5.  
  6. ^7TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
  7.  
  8. ^2 Here     Are     The     Latest     Totally     Amos    Top    Tips!
  9.  
  10. ^7TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
  11.  
  12. ^6 When  you need to load something from disk, it is a good idea to put
  13. ^6the filename inside a string and then check to see if the file exists
  14. ^6in the following way.
  15.  
  16. ^2 FIL$="Save.game"
  17. ^2 If Exist (FIL$)
  18. ^2 Load F$
  19. ^2 Else
  20.  
  21. ^6 Here you would put in an error trap to tell you if the file does not
  22. ^6exist
  23.  
  24. ^2 End If
  25.  
  26. ^7TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
  27.  
  28. ^4  How  many  times  have  you  finished a program, especially one for
  29. ^4children,  only  to find that the user clicks the mouse button on the
  30. ^4wrong thing at the wrong time?
  31.  
  32. ^4 This can cause a program to crash, or something extremely unexpected
  33. ^4to  happen  if the mouse is clicked, for example, during an animation
  34. ^4sequence.
  35.  
  36. ^4 The answer is simple, freeze the mouse!
  37.  
  38. ^4 Thanks  to  Paul  Townsend  for  sorting  out  this problem when the
  39. ^4situation arouse during one of our projects.
  40.  
  41. ^4 You use Limit Mouse to do this, but using the same beginning and end
  42. ^4coordinates in the following manner.
  43.  
  44. ^4 This will freeze the mouse at a point roughly centre of the screen.
  45.  
  46. ^2 Limit Mouse 272,162 to 272,162
  47.  
  48. ^4 Any coordinates will work as long as the two sets of coordinates are
  49. ^4identical.   We had previously assumed that this would be illegal and
  50. ^4so  had  never  tried it.  This proves the point that you cannot find
  51. ^4out if something wiill work until you try it!
  52.  
  53. ^2 Note  that  all  the coordinates are hardware coordinates not screen
  54. ^2coordinates.  This adds 128 to the X axis and 50 to the Y axis.
  55.  
  56. ^7TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
  57.  
  58. ^1For more advanced coders.....
  59.  
  60. ^1 If you want to open Workbench from inside Amos, use the following.
  61.  
  62. ^2 A=Intcall(-210)
  63.  
  64. ^1To close it again
  65.  
  66. ^2 A=Intcall(-78)
  67.  
  68. ^1Note.   If  you  close  Workbench with this method, and workbench has
  69. ^1some  windows  open,  when you open up Workbench again, these windows
  70. ^1will be as you left them.
  71.  
  72. ^2 This tip comes courtesy of Simon Nicoll.
  73.  
  74. ^7TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
  75.  
  76. ^6 This  a  routine  for  Ctext users which will centre a line of text.
  77. ^6With a little alteration it can be used with the normal Text command.
  78.  
  79. ^2 PRNT:
  80. ^2 NBR=Plen(M$)
  81. ^2 Ctext160-(NBR/2),YT,M$
  82. ^2 Return
  83.  
  84. ^6 Call this subroutine as follows
  85.  
  86. ^2 YT=100
  87. ^2 M$="Hello Totally Amos Readers!"
  88. ^2 Gosub PRNT
  89.  
  90. ^6 You  could  also  put  in  a Cls command before the Ctext command to
  91. ^6clear the line the text is on.
  92.  
  93. ^7TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
  94.  
  95. ^4 This tip is for those of you who have really got to grips with using
  96. ^4Intcall and Execall.
  97.  
  98. ^4 This tip comes again from Simon Nicoll, and comes with a programers
  99. ^4health  warning!!!!   If you don't know what you are doing, then make
  100. ^4sure  that you are messing about with a backup of your program or you
  101. ^4could  end  up  with  a totally useless program!  Read on to find out
  102. ^4what it does and what could go wrong!!
  103.  
  104. ^4 The two routines are 
  105.  
  106. ^2 Dreg(0)=Execall(-132)
  107. ^2 Dreg(0)=Execall(-138)
  108.  
  109. ^4 These  respectively  turn  multi-tasking  off  and on.  They do have
  110. ^4certain  limitations,  but  the  benefits  of using them properly far
  111. ^4outweigh these according to the type off game you are writing.
  112.  
  113. ^4 One  of the main faults is that when you use Execall(-132) to switch
  114. ^4off  multi-tasking, you lose all access to the keyboard, according to
  115. ^4which  version  of  Amos you are using, you will also lose the use of
  116. ^4the  mouse  until the program has been compiled.  In all cases, the
  117. ^4keyboard is disabled.  It has no effect on the Joystick.
  118.  
  119. ^4 The  type  of game where it would have no use is a shoot'em up where
  120. ^4the  keyboard  is needed to gain access to extra weopons or a `Pause'
  121. ^4feature in addition to movement with the joystick.
  122.  
  123. ^4 On  the other hand, if you are writing a game that contains animated
  124. ^4sequences with no keyboard interaction, then this one is for you.
  125.  
  126. ^4 When  using  AMAL, under certain circumstances, you can get a little
  127. ^4shudder  which is difficult to get rid of.  From what we've seen over
  128. ^4the  past few weeks since learning about this tip, this shudder seems
  129. ^4to  have  been  completely  removed.   As an added bonus, the program
  130. ^4appears to have speeded up by about 10%.
  131.  
  132. ^4 All you have to do is turn off the keyboard when multi-tasking isn't
  133. ^4needed, and turn it back on when it is.
  134.  
  135. ^4 It  is strongly recommended that this routine is ^2NOT ^4attached until
  136. ^4all  developing of your program has been done because if you run your
  137. ^4program in developing time and come up with an error, all you will be
  138. ^4left  with  is  a useless disk as you will not have ANY access to the
  139. ^4keyboard to correct the error.
  140.  
  141. ^2 The only way out here is a 3 key reset.
  142.  
  143. ^3                           YOU HAVE BEEN WARNED!
  144.  
  145. ^4 This is a marvellous facility if used correctly, thanks Simon.
  146.  
  147.  
  148. ^7TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
  149.  
  150. ^1 Tiny Tip
  151.  
  152. ^1 To automatically toggle a variable from 0 to 1, use the following
  153.  
  154. ^2 T=1-T
  155.  
  156. ^1 Every pass of the loop will change the value of T.
  157.  
  158. ^1 Thanks to Aaron Fothergill for this one!
  159.  
  160. ^7TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
  161.  
  162. ^5 To  save  wear and tear on your keyboard and your pinkies when using
  163. ^5the  Fade  or  palette  commands  and all the parameters are the same
  164. ^5colour.
  165.  
  166. ^2 For example for a 16 colour screen
  167. ^2 Palette
  168. ^2$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,
  169. ^2$FFF,$FFF,$FFF
  170.  
  171. ^2do F=$FFF then all you have to type is
  172.  
  173. ^2 Palette F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F
  174.  
  175. ^7TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
  176.  
  177. ^2 Proc*NBR*: rem Use square brackets in place of `*'
  178. ^2 Repeat
  179. ^2 Add CV,1
  180. ^2 K$=Inkey$
  181. ^2 If K$=Inkey$
  182. ^2 If k$<>" ":CV=NBR:End If
  183. ^2 Wait 1
  184. ^2 Until CV=NBR
  185. ^2 End Proc
  186.  
  187. ^1 This  procedure  makes  the  computer  sit  and wait for a specified
  188. ^1amount  of  time  as contained in the variable NBR, or until the user
  189. ^1hits a key.
  190. ^1 It  can  also  be  used  to  check  for  a click of a mouse key or a
  191. ^1joystick quite easily.
  192.  
  193. ^1eg for the mouse
  194.  
  195. ^2 If Mouse Key<>0:CV=NBR:End If
  196.  
  197. ^1 The call to this procedure would be WT[30], for example.
  198.  
  199. ^7TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
  200.  
  201. ^4 This tip will give you back about 10k in run time.
  202.  
  203. ^4 Set  the Sprite Buffer to 18, but only if you are not using sprites.
  204. ^4You  will  notice  that  your  `Amos' sprite has disappeared from the
  205. ^4editor  screen  as now you cannot display sprites more than 16 pixels
  206. ^4deep.
  207.  
  208. ^7TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
  209. \
  210.