★ CODING ★ LISTINGS ★ A VERY MOVING EXPERIENCE (SEAN MCMANUS AND AMSTRAD COMPUTER USER) ★ |
A Very Moving Experience (Sean McManus and Amstrad Computer User) | Coding Listings |
Basic Animation is the game; Sean McManus is the name. Read on and pick up some important programming tips. London by night - this is all you need to have seen to have the tools at your disposal for fast BASIC animation. But let's start with something simpler: junior school education. Most of us have fond memories of making cartoons at school, by drawing two slightly different pictures, and then flicking rapidly between them. This is, in effect, two-frame animation - a cartoon made from two static pictures. To simulate this on the CPC we have to be able to 'flick' between two images on screen instantaneously. At this point, machine code programmers generally grin smugly, fold their arms and watch their BASIC counterparts wallow in failure. The problem is that BASIC takes too long to draw a frame. Certainly any design worth animating would take at least several seconds to draw, shattering the illusion of motion. Perhaps we're approaching the problem the wrong way... In mode 0 Oct's use this mode - the reason will become obvious later), you can have 16 different colours, including the 'background', from a possible 26, on screen at any given time. Pens are used to draw, and the pens are filled with INKS, using the INK command. If you're not familiar with these commands, now would be a very good time to reach for the manual. Pens can be made to flash by assigning two inks to them. The computer will automatically alternate the inks -changing all the occurances of the pen wherever it is on the screen. Instantaneously. Problem solved! So, we can make the computer do our 'flicking' for us, by drawing our two images in different pens, and assigning the inks to flash. For example, if we have two frames, one drawn in pen one and the other drawn in pen two, we might assign the inks as follows: INK 1,26,0:INK 2,0,26 This assumes that 0 is the background colour. Pen 1 will be 26 (bright white), while pen 2 is the background colour (hidden) .Then, pen 2 will become visible, as pen 1 is hidden. This 'flicking' between the images will continue until stopped, in the background of whatever else is happening. Try DEMO I. It shows several animated jugglers. Upon running, you will be able to see the design as it appears in the default inks. Press any key to start. Parts of the design that are common to both frames are drawn in a pen which does not flash - it remains the same colour in both frames. As the scrolling message says, once the design is drawn, the computer can get on with other business, without interrupting the animation. The speed of the animation can be altered using the SPEED INK command. Can you imagine how painful it would have been to write this fairly simple demo without colour swapping? 10 ' Juggler - colour switching DEMO IWhilst 'Roland on the Ropes' was deemed trendy in its day because thewords flashed different colours between loading blocks, we now know how to do some very interesting interblock animations, without too much effort. |
|
|