★ APPLICATIONS ★ CREATION GRAPHIQUE ★ Amstrad Block Graphics ★ |
Amstrad Block Graphics (Computing with the Amstrad) | Applications Creation Graphique |
THIS program will take you into the realms of Amstrad graphics and gives quite a good 3D effect by building up a picture of a racing car in the same way as a child would build it with Lego. As with building bricks, we can build a structure several layers thick. This, together with the colour range of the Amstrad, means we can create some effective pictures. The routine is not perfect. It is meant to show what can be done and to stimulate a few ideas - and, of course, to give you a utility to incorporate in your own routines. We shall be creating a 3D picture in a similar way to that used to form 2D pictures - constructing a three dimensional combination from the standard 8x8 character matrices used when printing. Characters can be arranged together, and new ones can be redefined, so that the final size and shape of the picture is limited only by screen size. The character printing subroutine takes the normal character or a user-defined one and creates from it a set of cubes in the same positions as dots would be in the printed character. Figure I shows the transition we make in this program. The cube routine simply draws a cube of the required size in the position given to it. By drawing the cubes in a row from the deepest position to the shallowest, we eliminate the hidden edges. The routines are driven by the print string subroutine at line 1200. This will take the string in s$ and print it to the screen in block form. This section requires some variables to be set. Before we call it we need to give values to:
The subroutine will take an average of the start and end values and adjust the size of intermediate characters accordingly. The angle of the string is that at which the characters slope. The subroutine has been kept simple by only allowing for strings to be printed on a downslope from left to right. Printed cubes automatically eliminate those immediately behind them or those that cannot be seen. If you wish to use other directions you must work out which faces of the cube are showing and draw the string so that the nearest characters are drawn last. The precise angles and sizes of the strings are more a question of trial and error than theory. The small section of machine code at the end moves the character matrix to a position in store where Basic can read it. The character definitions are held in the lower ROM. The routine enables this ROM, calls a subroutine to find where the definition for the current character is, and then moves the eight byte sequence to location 42020 onwards. The main routine can then pick up each of these values to test each of the bits. If a bit is set the cube routine will draw the block. Any character can be used, as the routine prints whatever is in the string. I have redefined two characters to produce the racing car and have printed different sizes of the letter 0 to produce the wheels. This the racing car is made up of three layers -the far back wheel can still be seen over the car. Adjust the base positions and the sizes to get the required layout for your particular picture. Now that we are able to draw our picture we should consider how to put colour into it. In Mode 0 the Amstrad gives us 1 6 pens with which to paint our picture, and the pen colours can be freely selected from the palette of 27 inks. I have set up all my pen colours in the initialisation routine at line 1 700. This sets the ink of each pen. The cube drawing routine will draw cubes with the pens shown in Figure II. The variable cc holds the pen for the front face, and we increment this number for the top face and again for the side face. In the program I have used pens 1, 2 and 3 for the "Amstrad" string, face and car body, and pens 4. 5 and 6 for the car wheels. By using a number of colours, and by overprinting with user-defined or normal characters, we can build complex and attractive pictures. The routine could be extended in several ways - increasing definition, changing the cube drawing to something more exotic like a cylinder, or following a curve rather than a straight line. One idea would be to put other pen colours on to the tyres and then change these pen colours in a loop. This would give a form of colour animation and the car wheels would appear to be turning. As the program stands, it is interesting to see such lively effects from such a simple routine. Perhaps on some future computers we shall have this facility as standard in the ROM routines, maybe with a three dimensional (multi-colour?) character set. The way that computer graphics are moving using three dimensional effects, I wouldn't be surprised if it was here sooner than we think.
|