_______________________________________________________________________________ __ __ | / \ _ __ __ ____ |__ . __ ___ | | __ | __\ | \ | \ | / \ <__ | \__/ _|_ <__| |__/ _|_ | | \__ ___> | ____ _|_ | | \ __ ___ __ ___ ___ __ | |--< / \ | \ __\ | \ / __\ | _|__/ \__/ _| | <__| _| | /__ <__| | ______________________________________________________________________________| These pretty type-ins will show just what Arnold can do when he sets his mind to it. This month's type-'em-ins are all fast, smooth animation programs . What's more, they all get their amazing speed the same way - colour-switching. If you just want to dazzle your friends with Arnold's graphic abilities then get typing. If you're a Basic buff and keen to write colour-switching classics of your own, on the other hand, then read on to see how it's done. What follows assumes a fair bit of graphics knowledge, especially about inks and colours. If you're not too hot on these, take a look at our new series on Basic programming - otherwise, read on. If you want to change the colour of a point on the screen, you can do it in two ways. The normal method is to change the ink at the point - this is the way that graphic commands like PLOT and DRAW work. In a typical animation sequence, you'll need to make many thousands of these changes every second - more than Basic can handle - so this plot/draw method isn't going to be fast enough. A quicker but more drastic way is to alter the colour in which the ink at the point is displayed, using an INK command. The problem is, this method also changes the apparent colour of every other point drawn in that ink. This is the power of colour switching - even in mode 0, it takes just sixteen commands to change the colour of every point on the screen. Colour switching doesn't change any of the shapes on the screen - straight lines in the two mini-listings and curves in Rotating Spheres - but it can still give the impression of movement by changing their colours. In the two mini-listings, the general pattern is moved by assigning colours to the inks in rotation - the individual lines, after the initial drawing period, stay exactly where they are. Rotating Spheres has a slightly different approach. Once the lines and curves have been drawn, the inks are all switched to black except the sphere-outline ink and one other - these are switched to bright white. Thus you have only the sphere outline and one set of curves/background lines visible. This set of curves and lines is then switched to black, and the next set to white - and so on, in an endless loop, until a key is pressed. All three programs use mode 0, to give as many inks as possible. More inks means more frames in each cycle, and hence smoother animation - try adapting one of the mini-listings to run in mode 1, and see how much less convincing it is. Two of them also use CALL &BD19 - the same as the 664 FRAME keyword - to stop any flicker, but Conveyor Belt does perfectly well without this. If all this sounds a bit complicated, don't worry. Compare the threelistings and then watch the programs running - you'll soon get the idea. In any case, you needn't understand a thing to enjoy the impressive graphics they produce. Conveyor Belt This amazing ultra-mini-listing from Roger Wilson of Blackburn isjust seven lines long, but it'll knock you dead. Machine code - who needs it? __________________________ | | | [Listing - CONVEYOR.BAS] | |__________________________| Swirl The name says it all, really. Paul Fairhurst's seventeen-liner draws two different shapes and they both swirl - and pretty fast, too. __________________________ | | | [Listing - SWIRL.BAS] | |__________________________| Rotating Sphere This may be the longest of the three, but it's well worth the typing time. You can make the sphere rotate or glitter, adjust its height and width, and give it a circular or straight line background. All of this courtesy of James Cadwallader - great stuff! __________________________ | | | [Listing - SPHERE.BAS] | |__________________________| [The letter below was published in the "Problem Attic" section of the "Re-Action" column in the October 1986 issue (#13). Its author raises some queries regarding Rotating Sphere and the structure of the program.] Strange commands Never having written to a magazine before I now find myself writing for the second time in a few days. Concerning the "Graphics Bonanza" on pages 92 & 93 of the May 'Amstrad Action', I have typed in all three programs and all work very nicely. However I wonder if you or James Cadwallader could explain one or two points on the Rotating Sphere program:- a. Line 335. "secondnum = ysize" appears to serve no purpose whatsoever. b. Lines 370 and 510. As line 370 sets "first" to Z it would appear that the program will always GOSUB 1840 and never GOSUB 1930. Hence lines 1930-1995 will never be used. In line 370, What purpose does "last = 15" serve as "last" doesn't appear anywhere else? Major J H A Bryden MBE Edinburgh We edited that listing for length. The commands you mention are left over from the earlier version, and should really have been excised by us.