ddd00000ff00fe0080888000a3f ^7TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT ^1 PROGRAMMING HINTS AND TIPS. ^7TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT ^2 Here Are The Latest Totally Amos Top Tips! ^7TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT ^6 When you need to load something from disk, it is a good idea to put ^6the filename inside a string and then check to see if the file exists ^6in the following way. ^2 FIL$="Save.game" ^2 If Exist (FIL$) ^2 Load F$ ^2 Else ^6 Here you would put in an error trap to tell you if the file does not ^6exist ^2 End If ^7TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT ^4 How many times have you finished a program, especially one for ^4children, only to find that the user clicks the mouse button on the ^4wrong thing at the wrong time? ^4 This can cause a program to crash, or something extremely unexpected ^4to happen if the mouse is clicked, for example, during an animation ^4sequence. ^4 The answer is simple, freeze the mouse! ^4 Thanks to Paul Townsend for sorting out this problem when the ^4situation arouse during one of our projects. ^4 You use Limit Mouse to do this, but using the same beginning and end ^4coordinates in the following manner. ^4 This will freeze the mouse at a point roughly centre of the screen. ^2 Limit Mouse 272,162 to 272,162 ^4 Any coordinates will work as long as the two sets of coordinates are ^4identical. We had previously assumed that this would be illegal and ^4so had never tried it. This proves the point that you cannot find ^4out if something wiill work until you try it! ^2 Note that all the coordinates are hardware coordinates not screen ^2coordinates. This adds 128 to the X axis and 50 to the Y axis. ^7TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT ^1For more advanced coders..... ^1 If you want to open Workbench from inside Amos, use the following. ^2 A=Intcall(-210) ^1To close it again ^2 A=Intcall(-78) ^1Note. If you close Workbench with this method, and workbench has ^1some windows open, when you open up Workbench again, these windows ^1will be as you left them. ^2 This tip comes courtesy of Simon Nicoll. ^7TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT ^6 This a routine for Ctext users which will centre a line of text. ^6With a little alteration it can be used with the normal Text command. ^2 PRNT: ^2 NBR=Plen(M$) ^2 Ctext160-(NBR/2),YT,M$ ^2 Return ^6 Call this subroutine as follows ^2 YT=100 ^2 M$="Hello Totally Amos Readers!" ^2 Gosub PRNT ^6 You could also put in a Cls command before the Ctext command to ^6clear the line the text is on. ^7TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT ^4 This tip is for those of you who have really got to grips with using ^4Intcall and Execall. ^4 This tip comes again from Simon Nicoll, and comes with a programers ^4health warning!!!! If you don't know what you are doing, then make ^4sure that you are messing about with a backup of your program or you ^4could end up with a totally useless program! Read on to find out ^4what it does and what could go wrong!! ^4 The two routines are ^2 Dreg(0)=Execall(-132) ^2 Dreg(0)=Execall(-138) ^4 These respectively turn multi-tasking off and on. They do have ^4certain limitations, but the benefits of using them properly far ^4outweigh these according to the type off game you are writing. ^4 One of the main faults is that when you use Execall(-132) to switch ^4off multi-tasking, you lose all access to the keyboard, according to ^4which version of Amos you are using, you will also lose the use of ^4the mouse until the program has been compiled. In all cases, the ^4keyboard is disabled. It has no effect on the Joystick. ^4 The type of game where it would have no use is a shoot'em up where ^4the keyboard is needed to gain access to extra weopons or a `Pause' ^4feature in addition to movement with the joystick. ^4 On the other hand, if you are writing a game that contains animated ^4sequences with no keyboard interaction, then this one is for you. ^4 When using AMAL, under certain circumstances, you can get a little ^4shudder which is difficult to get rid of. From what we've seen over ^4the past few weeks since learning about this tip, this shudder seems ^4to have been completely removed. As an added bonus, the program ^4appears to have speeded up by about 10%. ^4 All you have to do is turn off the keyboard when multi-tasking isn't ^4needed, and turn it back on when it is. ^4 It is strongly recommended that this routine is ^2NOT ^4attached until ^4all developing of your program has been done because if you run your ^4program in developing time and come up with an error, all you will be ^4left with is a useless disk as you will not have ANY access to the ^4keyboard to correct the error. ^2 The only way out here is a 3 key reset. ^3 YOU HAVE BEEN WARNED! ^4 This is a marvellous facility if used correctly, thanks Simon. ^7TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT ^1 Tiny Tip ^1 To automatically toggle a variable from 0 to 1, use the following ^2 T=1-T ^1 Every pass of the loop will change the value of T. ^1 Thanks to Aaron Fothergill for this one! ^7TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT ^5 To save wear and tear on your keyboard and your pinkies when using ^5the Fade or palette commands and all the parameters are the same ^5colour. ^2 For example for a 16 colour screen ^2 Palette ^2$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF, ^2$FFF,$FFF,$FFF ^2do F=$FFF then all you have to type is ^2 Palette F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F ^7TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT ^2 Proc*NBR*: rem Use square brackets in place of `*' ^2 Repeat ^2 Add CV,1 ^2 K$=Inkey$ ^2 If K$=Inkey$ ^2 If k$<>" ":CV=NBR:End If ^2 Wait 1 ^2 Until CV=NBR ^2 End Proc ^1 This procedure makes the computer sit and wait for a specified ^1amount of time as contained in the variable NBR, or until the user ^1hits a key. ^1 It can also be used to check for a click of a mouse key or a ^1joystick quite easily. ^1eg for the mouse ^2 If Mouse Key<>0:CV=NBR:End If ^1 The call to this procedure would be WT[30], for example. ^7TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT ^4 This tip will give you back about 10k in run time. ^4 Set the Sprite Buffer to 18, but only if you are not using sprites. ^4You will notice that your `Amos' sprite has disappeared from the ^4editor screen as now you cannot display sprites more than 16 pixels ^4deep. ^7TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT \