CODINGLISTINGS ★ DOUBLE HEIGHT CHARACTERS ★

Graphic - Vector Graphics (The Amstrad User)Coding Listings
★ Ce texte vous est présenté dans sa version originale ★ 
 ★ This text is presented to you in its original version ★ 
 ★ Este texto se presenta en su versión original ★ 
 ★ Dieser Text wird in seiner Originalfassung präsentiert ★ 

Over the last few months, Gary Koh has introduced us to the art of animation through sprites. This month he takes a look at vector graphics.

This month we conclude our foray into animation, by looking at vector graphics or as it is commonly known, line graphics.

The majority of games produced these days use sprite graphics. However, a few games like Elite, Star Glider and Starfox use vector graphics. Vector animation allows you to add a third dimension to your picture. This is well suited to games that need to animate large objects like ships or buildings.

There are many drawbacks with using vector graphics and it has a mainly specialised use. It can animate 3D looking objects as large as the screen. It does this by making the object out of lines. It tricks you into thinking the object is solid even though it is almost empty. However, there is a price to pay for this. Vector animation requires the use of trigonometric functions and matrices. This has to be done under machine code because of the speed required to animate an object.

Vector animation can also have hidden line removal. Vector animation without hidden line removal is commonly inferred to as wireframe graphics. This is because the object is drawn so you can see all the corners of an object. Hidden line removal takes away the lines that are on the other side of the object and makes the object look far better and solid. Figure 1 shows a ship as it would look like when drawn without hidden line removal and figure 2 shows how a ship drawn with hidden line removal would look like.

As vector graphics is very hard to produce what we will be looking at arc pseudo-vector graphics or line graphics. The first problem is to make it look like an object is being animated. Of course, you cannot rotate the object (at least not in 3D) so you have to look at other ways of simulating the animation.

If you want to draw a line graphic under Basic you need to use direct draw and move statements. If you read the data in with data statements the drawing will just be too slow. Listing 1 is an example of a line graphic of a rocket. The rocket is drawn using a series of move and draw statements. The animation though is a bit flickery. (Please note: you need to run Grafex firsl before you run any of the listings this month.)

Just drawing a single picture like thatt on the screen is not much use. Another thing we can do is to scale the rocket to a different size. This is what listing 2 does. The left and right arrow keys make the rocket decrease or increase its width. The up and down arrow keys increase and decrease the height of the rocket.

From this we can extend it a bit further.

In listing 3 you can control the "ships" by using a joystick. The ship itself is a single frame. You will also notice that pentagons are coining towards you. The pentagons use scaled line graphics to draw themselves. The idea is that you arc to avoid the pentagonian stripe anti-line ship missiles. Fortunately for you they seem not to have heard of collision detection yet so they pass harmlessly over you.

However, still the movements of the ship arc a little jerky and slow. Is there any other way to speed it up? There are in fact many possible ways. Firstly ihc line drawing routine used by the firmware is a bit slow but works in all modes. It is possible to replace it with a faster routine that works in say mode 1 (I will leave that as an exercise to the machine code enthusiast). To create such a routine would take a long time and it would be very complicalted.

Secondly you can draw the ship in machine code instead of Basic. This saves a lot of time waiting for Basic to wade through all the move and draw statements and provides a reasonable increase in speed. However, the line drawing routine offers the most scope for improvement.

Listing 4 is meant to be merged with Listing 3. It replaces the Basic line graphics routines with a machine code one. This increases the speed of the graphics by about u factor of 2 or so as you can see. The machine code does not replace the line drawing routine in the firmware, it simply draws the lines in machine code.

There are also what could be termed solid vector graphics. This simply means that instead of just having a graphic made out of lines the space within the lines is filled up. I believe Starfox makes use of solid vector graphics although how they managed to do that with enough speed on the Amstrad I do not know.

That concludes our look into animation. Hopefully this has given you some insight into animation and the concepts behind producing it. Next month we will be delving into screen manipulation.

TAU

★ PUBLISHER: The Amstrad User (Australia)
★ YEARS: 1986 , 1988
★ AUTHOR: Gary Koh
 

★ AMSTRAD CPC ★ A voir aussi sur CPCrulez , les sujets suivants pourront vous intéresser...

Lien(s):
» Coding Src's » A Very Moving Experience (Sean McManus and Amstrad Computer User)
» Coding Src's » Graphic - Colour Swapping (Popular Computing Weekly)
» Coding Src's » Rainbow-Scape (Amstrad Computer User)
» Coding Src's » Rocky 2 (Amstrad Action)
» Coding Src's » Grapics (Computing With the Amstrad)
» Coding Src's » Schnell gespeichert (Happy Computer)
Je participe au site:

» Vous avez remarqué une erreur dans ce texte ?
» Aidez-nous à améliorer cette page : en nous contactant via le forum ou par email.

CPCrulez[Content Management System] v8.7-desktop/c
Page créée en 182 millisecondes et consultée 1705 fois

L'Amstrad CPC est une machine 8 bits à base d'un Z80 à 4MHz. Le premier de la gamme fut le CPC 464 en 1984, équipé d'un lecteur de cassettes intégré il se plaçait en concurrent  du Commodore C64 beaucoup plus compliqué à utiliser et plus cher. Ce fut un réel succès et sorti cette même années le CPC 664 équipé d'un lecteur de disquettes trois pouces intégré. Sa vie fut de courte durée puisqu'en 1985 il fut remplacé par le CPC 6128 qui était plus compact, plus soigné et surtout qui avait 128Ko de RAM au lieu de 64Ko.