04.01.2013 Views

Amiga Computing - Commodore Is Awesome

Amiga Computing - Commodore Is Awesome

Amiga Computing - Commodore Is Awesome

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Phil South looks at<br />

plotting and<br />

drawing functions<br />

in AMOS<br />

The fun part about being your friendly<br />

local AMOS columnist is that I have<br />

absolutely no idea of your level of<br />

understanding on AMOS. This is both<br />

a blessing and a curse. Do you want machine<br />

code widgets or do you want basic code gener<br />

ation? Do you want graphics or procedures? My<br />

answer is to put a wide range of things into the<br />

column and let them find their own level. From<br />

the mail I receive via post and the Internet, this<br />

approach seems to be working, as almost<br />

everyone gets what they want eventually, and<br />

as long as it's entertaining you don't seem to<br />

mind what goes on.<br />

AMOS is one of those things which is all<br />

things to all men. Some view it as a means of<br />

putting ideas into action, others see it as per<br />

sonal development, a way to stretch them<br />

selves. Either approach is worthwhile and I'm<br />

sure you'll enjoy the bits and bobs I've got lined<br />

up for the next few months. In the meantime,<br />

thanks for all your mail - let's get going with<br />

this months AMOS curiosity.<br />

Top of the Plots<br />

Something a lot of beginners ask me about is<br />

how to make marks on the screen such as<br />

lines, dots, squares etc. The reason I get asked<br />

this has something to do with the old <strong>Amiga</strong><br />

Basic, as this was the only kind of graphics you<br />

could produce. I like to call it Etch a Sketch<br />

graphics, as it is based on lines and dots and<br />

boxes, just like the old two knob drawing toy.<br />

Ifs easy. The first instruction you should look<br />

at is PLOT. This is the easiest command of all<br />

and simply places a dot, in the currently select<br />

ed ink colour, on the screen, like so:<br />

Ink 9 : Plot 30,56<br />

This places a dot of colour 9, 30 pixels along<br />

the screen and 56 pixels down. There is a easy<br />

way to specify the colour, if you want it differ<br />

ent from the Ink colour:<br />

Plot 30,56,9<br />

This is a useful command tf you want to create<br />

a starfield in your game, like in the old classic<br />

Galaxians (which may or may not be a bit<br />

before your time...} like SO:<br />

Do<br />

Cls : Curs Off<br />

Loop<br />

Plot ,Rnd(255), Rnd(IS)<br />

Going dotty.<br />

<strong>Amiga</strong> <strong>Computing</strong><br />

MARCH 1997<br />

Plots<br />

Thicken<br />

This fills the screen with multicoloured dots. If<br />

you don't want those of colour 3 to flash, add<br />

the command:<br />

Flash Off<br />

Okay, that's dots, what about lines? We do this<br />

in pretty much the same way:<br />

Drau 30,56 To 150,200<br />

This draws a line from the first point mentioned<br />

to the last. Simple enough. You can change the<br />

look of the line by adjusting the line style:<br />

Cls : Ink 2<br />

Set Line SFOFO<br />

Box 50,100 To 150,UO<br />

Set Line 11100110011001100<br />

Box 60,110 To 160,160<br />

The line style is set using the SET LINE com<br />

mand and this allows you to set the variation of<br />

the pixels in the line. This is a nice and very<br />

underused feature, so write something that uses<br />

it, eh?<br />

The final bunch of features are the box and<br />

circle commands. To make a box, like the one<br />

we just saw in the SET LINE program, we have<br />

to set the top left and bottom right corners of<br />

the box. So:<br />

Box 10,10 To 3D,30<br />

makes a box 20 by 20 starting at 10,10 and<br />

ending at 30,30. The circle command is similar<br />

again, but this time you set the centre of the cir<br />

cle and the radius (the distance from the mid<br />

dle to the outside of the circle, for those of you<br />

who fell asleep in maths). So you can do this:<br />

Circle 100,100,50<br />

Allied to this is the POLYLINE command, which<br />

draws multiple lines. This is like drawing a line<br />

with the DRAW command, only you keep going,<br />

Polyline 10,10 To 2D,30 To 60,3D To 58,10 To<br />

200,100<br />

and so on. You can build up quite complicated<br />

pictures like this, but it would take a bit of<br />

graph paper and a lot of sweat to make a<br />

human face.<br />

There was a program once, 1 can't even<br />

remember if I printed it, but it took a drawing<br />

you made with the mouse and turned it into<br />

the code you would need to draw it from poly<br />

lines! tf anyone can find this program I'd be<br />

grateful if they would e-mail it to me.<br />

That's enough for now, I'll move on into<br />

more complicated graphics next time, until then<br />

Happy Amos!<br />

Write<br />

STUFF<br />

If you have any other AMOS pro<br />

grams or queries about AMOS,<br />

please write to the usual address,<br />

which is: Phil South, Amos Column,<br />

<strong>Amiga</strong> <strong>Computing</strong>, Media House,<br />

Adtington Park, Macclesfield, SK1O<br />

4NP. Or you can send e-mail to me<br />

on phil@webscape.co.uk, or via my<br />

home page on http://www.webscape.<br />

co.uk/phil/.<br />

Please send routines on an <strong>Amiga</strong><br />

disk with notes on how the program<br />

works on paper, not as text files on<br />

the disk. Make the routines short<br />

enough to appear in print, i.e. no<br />

more than about 30-40 lines of code.<br />

If possible make them use no exter<br />

nal graphics, if they can't be used<br />

without them, be sure to provide<br />

them on the disk in native IFF for<br />

mat, the same goes for sound files.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!