home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
totallyamos
/
issue5
/
programming
/
6.seq
< prev
Wrap
Text File
|
1992-05-13
|
13KB
|
355 lines
fff00000ff00fe0080001a7f
^4*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF
^2 T O T A L L Y A M A L
^1 By Paul Townsend
^5 Of Technical Fred Software
^4*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF
^2 THE FOLLOWING TWO ARTICLES APPEARED IN THE LAST ISSUE OF TOTALLY
^2AMOS, BUT DUE TO THE FACT THAT SOME CHARACTERS USED IN THE TA DRIVER
^2PROGRAM APPEAR IN THE LISTINGS, THERE WAS A SCRAMBLING OF SOME OF THE
^2CODE.
^2 TO AVOID ALL CONFUSION, THESE ARTICLES ARE BEING REPEATED AS THE
^2DRIVER PROG HAS NOW BEEN AMMENDED TO TAKE THE CHARACTERS INTO
^2ACCOUNT.
^2 PAUL SENDS HIS APOLOGIES FOR THE LACK OF PART TWO OF BOTH HIS
^2TUTORIALS, BUT THIS IS DUE TO ILL HEALTH AND OTHER COMMITMENTS, HE
^2GIVES HIS SOLOMN PROMISE THAT THEY WILL APPEAR NEXT TIME.
^4*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF
^2 So you want to learn Amal ?
^3 Sure ?
^7 In that case read on !
^4*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF
^1 The Very Beginings
^6 It seems that there are a lot of people out there who seem to be
^6getting the hang of Amos Basic, but seem to be having difficulty in
^6using Amal, this short tuturial aims to get those people started at
^6writing simple programs in Amal.
^6 This tutorial has no intentions of teaching you to program in BASIC,
^6there are enougth books on that already.
^6 I do not think that I am any expert with Amal ( At least not yet !),
^6I am still getting to grips with some of it's finer details, but I
^6will try to tell you what little I know in a bit more detail and in a
^6more understandable way than the Amos manual.
^6 Right that's enough waffle, let's get down to business.
^6 First I will out line a couple of rules that you must always follow
^6when using Amal.
^1 Rule 1
^4This is the one mistake that many new users seem to make,
^2 A M A L I S C A S E S E N S I T I V E
^4 That means that it is VERY fussy when it comes down to giving it
^4commands, you may have noticed that whenever you type in a command in
^4normal Amos, it noes not matter whether you use UPPER case (Capital
^4letters eg.'ABCD') or lower case letters (small letters eg. 'abcd'),
^4for example take the "Print" command, Amos does not care if you
^4type:-
^2PRINT
^2print
^2Print
^4or even :-
^2PrInT
^4It always seems to understand and convert it to :-
^2Print (i.e. the first letter is Captal, the rest are not !)
^4 You may be forgiven for thinking that Amal would be just as
^4carefree, well sorry to disappoint you, but Amal is nowhere near
^4being that helpful
^4If you mean,
^2For X=1 To 100 ; Pause ; Next X
^4then that is what you must type in to Amal, it's no good saying,
^2For X=1 to 100 ; Pause ; Next X
^4because it just will not work
^6Spot the difference?
^1 Yes there is one, look carefully, the word 'to' in the second
^1example should be 'To' not 'to', you see what a headache Amal can be
^1to it's newcommers.
^1 Don't worry if you don't understand what the last line of Amal
^1commands meant, all will be revealed later, as long as you can see
^1the difference between them, then you are over one of the first Amal
^1hurdles.
^7 Rule 2
^2Colons (:) in Amal
^6 When programming in BASIC you may be used to using the colon to
^6seperate commands that you want to stay on the same line for
^6example:-
^2For F=1 To 100 : Print "Hello" : Next F
^6The use of the colon changes once in Amal. (More on this later)
^6 To keep things simple, to separate commands in Amal, just use a
^6semi-colon (;) like I have done in the above examples
^6 To get commands into Amal you first need to get them into an Amos
^6String, the simplest way I have found is to say somthing like :-
^2AM$="For R0=1 To 100 ; Pause ; Next R0"
^6And then to run it use the following:
^2Amal 1,Am$
^2Amal On
^6 This will get your Amal program running, (Hopefully!). If you run
^6that last program, what do you see? If you ran it and got absolutely
^6nothing at all, then it probably worked OK. If you got one of those
^6ever so helpful "Syntex Error in Animation String" messages then look
^6carefully at the program and make sure that everything is typed in
^6correctly.
^6 OK. so you want me to tell you why you should have got nothing on
^6the screen? Well if you look at the above AM$, you may recognise
^6that it looks a little like an Amos Basic Program i.e.
^2For R0=1 To 200
^2Pause
^2Next R0
^6 The Pause statement in Amal is rather like the Wait Vbl statement in
^6Amos Basic ie does nothing but waits for a while (about the same as
^61/50th of a second). This is why nothing appears on the screen,
^6because like all computer languages, they only do what is asked of
^6them no more and no less. (That's the theory anyway, I've never yet
^6ASKED foe a Guru meditation message in any of my programs, they just
^6happen whenever the computer seems to feel like it, but you know how
^6theories go don't you?)
^7 If you want something more interesting to happen then we are going
^7to have to tell Amal to move something around for us. To do this we
^7need to tell a Bob or Sprite to ATTACH itself to your Amal program,
^7to do that we need a Channel Command ie:
^2Channel (Amal program number) to Bob (Bob number)
^7We will now include that in the above example:
^2Load "Sprites.ABK" REM: LOAD IN A SPRITE BANK HERE
^2AM$="For R01 To 200 : Let X=R0 : Let Y=R0 : Next R0"
^2Bob 1,0,0,1
^2Channel 1 To Bob 1
^2Amal 1, AM$
^2Amal On 1
^2Direct
^7 Type this in and run it. Remember that you will need to load in a
^7sprite bank!
^7 Hopefully this should move your Bob diagonally on the screen.
^7 How do we get it to move back the other way?
^6 Well I will leave you with that teaser and next issue I will tell
^6you the answer, so why not have a go yourself? Don't be afraid to
^6experiment, you cannot do any harm to your computer if you get it
^6wrong! (It may sulk and Guru, but just show it who's boss and hit
^6that left mouse button and try again!)
^2 Finally, is there anything you want to know how to do in AMOS or
^2AMAL? If so why not drop a line to Totally Amos at the usual
^2address?
^3 See you next Issue.
^3 Paul Townsend.
^4*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF
^3 T R I G S C R E E N E F F E C T S
^2 An Insight By Paul Townsend
^7*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF
^4 So you want to know how to produce those Sin and Cos generated
^4effects that keep appearing from Technical Fred Software. This short
^4introduction should give you an idea on how to get started. I get
^4the impression that many people seem to have a fear of using Sin and
^4Cos in their programs (Trigophobia ?), this is not too suprising
^4really as their seems to be very little explanation of what they
^4really do, so here I am to try to make sense of it all.
^2 First Steps
^5 When you run my programs that use Sin and Cos, if you look carefully
^5then you will realize that most of the effects are based upon the
^5circle, or multiple circles interacting with each other. The reason
^5for this is that I use Sin and Cos to produce circles, with is what
^5they are good at (They probably have many other uses, but I haven't
^5found any that are interesting enough to bother about).
^2 The Theory
^4 The circle can be split up into 360 points which can be imagined to
^4be positioned, equally spaced around the circumference. So if you
^4start at any place on the circumference and move 360 points in any
^4direction, you will end up back where you started from.
^5 What we need to know is how to work out where all these points are
^5so that we can do something at that particular point on the screen,
^5i.e plot a point, paste a bob etc.
^4 When typing in these examples, dont type in the <---- and comments
^4or the computer will spit them back at you, (You could use Rems if
^4you want, but I'm just too lazy !), Just type in the bits before them
^4and press RETURN
^5 The way to do this is to choose which points on the circle you want,
^5for our purposes we will just plot the entire circle, a program to do
^5this could be:
^7Screen Open 0,320,256,32,Lowres
^7Degree <----Tell the computer we want to work in degrees
^7For F=0 To 360 <----Set up a loop
^7X#=Sin(F) <----Work out the Co-ords
^7Y#=Cos(F) <---- " " " " "
^7Plot X#,Y# <----Plot the point
^7Next F <----Loop ?
^4If you try it, don't be surprised if you get nothing at all on
^4screen, the reason for this is that
^4 1) The co-ords are just off screen at the top left and
^4 2) the circle is only 1 pixel wide.
^5This calls for some minor changes to the above program :-
^4Firstly let's add the centre of the screen to the points plotted.
^7Screen Open 0,320,256,32,Lowres
^7Degree <----Tell the computer we want to work in degrees
^7For F=0 To 360 <----Set up a loop
^7X#=160+Sin(F) <----Work out the Co-ords
^7Y#=128+Cos(F) <---- " " " " "
^7Plot X#,Y# <----Plot the point
^7Next F <----Loop ?
^5 This program will appear to plot a point in the centre of the
^5screen, this is because the circle is still only 1 pixel wide,
^5therefore one final change is needed to get the circle to look like a
^5circle.
^7Screen Open 0,320,256,32,Lowres
^7Degree <----Tell the computer we want to work in degrees
^7For F=0 To 360 <----Set up a loop
^7X#=160+(100*Sin(F)) <----Work out the Co-ords
^7Y#=128+(100*Cos(F)) <---- " " " " "
^7Plot X#,Y# <----Plot the point
^7Next F <----Loop ?
^4 This program should now work, it should draw a circle that is 100
^4pixels wide. (Why not try other numbers other than 100 for different
^4sizes of circles)
^5 Hopefully you should now have a circle on the screen, it may not
^5look much, but if you can understand why the circle is there, then
^5that is the first hurdle over with.
^4 OK, I think we should make this program a little more interesting,
^4what about making the circle appear to move.
^5The method I will use is a palette switch, try this, don't type in
^5the comments though
^7Screen Open 0,320,256,32,Lowres
^7Flash off <----Needed for Shift Up to work
^7Degree <----Tell the computer we want to work in degrees
^7For F=0 To 360 <----Set up a loop
^7Add rgb,1,1 to 31
^7X#=160+(100*Sin(F)) <----Work out the Co-ords
^7Y#=128+(100*Cos(F)) <---- " " " " "
^7Plot X#,Y#,RGB <----Plot the point in the selected colour.
^7Next F <------Loop ?
^7Shift Up 2,1,31,1 <------set up a palette switch (or colour cycle)
^7Direct
^4 If you run this program you should have a revolving circle.
^5 You can now plot a circle, each point in a different colour, and
^5then to make it move.
^4 In the next part of this tutorial, we will try to use what we have
^4learned to produce some more interesting effects, but until then
^4please don't be afraid to experiment, try changing any of the numbers
^4in the above programs, just to see what happens. After all, that's
^4how all of the effects I have written in the past started off. (i.e.
^4see Screen Wipes in previous editions of TA) I just guess at a number
^4to change in a program run it and hope for the best. If the effect
^4looks good then I save the program, if not, I change it to something
^4else. (How's that for a structured approach to programming?)
^5 So until next time, have fun. If you have anything you would like
^5to see in these tutorials, why not drop a line to Totally Amos at the
^5usual address.
^3T T F N
^2Paul (Technical Fred) Townsend.
^7*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF
\