Popular Computing Weekly
★ 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 ★ 
A classic beginning

A step by step implementation of a classic game for the Amstrad machines by Ian Morton Iooking through my old program listings recently, I came across a I game that I'd typed into one of my first computers. I played it on a teletype in those days and it was totally text orientated. It had to be, at a printing speed of ten characters a second. I dreamt that we might one day have screens thai can take two or three thousand characters a second as they do now. (They were certainly not the 'good old days'!) After having come back into the land of the living, I realised that I had a nice new Amstrad machine on my desk, and it was only a Basic program. I could have converted it line for line, but it seemed silly not to use the better facilities of the Amstrad.

I have written the program with the idea of showing how some of the printing facilities and the speed of the Amstrad could be used, but in the end it has turned out to be quite a challenge to play. The idea is to land, gently, on a planet surface. With only one direction of rocket to control, this might seem to be fairly easy, but with the complex equations in the program, and by starting at a different height and speed each game, the program becomes extremely testing.

Program notes

You will find the more variable parameters towards the beginning of the program, or the beginning of the individual subroutines. So. with the Amstrad having only four colours in this mode. 1 decided which they should be at the outset and the values are set in Line 90. Only pens two and three are set, since I was happy enough with the blue and yellow of the default pens zero and one. Similarly, the subroutine for scrolling a message across the screen can be taken out for use in other programs. The parameters for its position and size are all in its first line. Line 680. The variable 'minx' is the left hand column, 'widex' is the width of the display. If you set the width to two. you will see the text scrolled across a two character display, not too convenient!

The Amstrad has window facilities, and, even though the program does not need to send output to more than one screen, the facility can still be useful. By setting up window number 1. whenever we use a Cls # 1 just the area of that window will be cleared. This gives a simple way to set the background colour for the instrument panel. We can then print over the background as though it were part of the full screen. Now let us turn our attention to the printing. The Amstrad has two ways of printing text at specific locations. The first is the Locate command. This command is similar to the Print At facility on the Spectrum, or Tab on a BBC. It sets the position of the text cursor at a character location specified by the following two parameters for x and y positions. It has been used in the message scroll routine, such that parameters for x and y positions. It has been used in the message scroll routine, such that we continually reprint the text string of increasing length, while, at the same time, moving the start location from the end to the beginning of the slot. By adding a set of spaces, of equal length to the message area, we can scroll the message completely away.

The control panel print routine also uses the Locate command to print the values for the various instruments. Notice how easy it is with Amstrad Basic, to format a number for two decimal places. Other micros have used different methods to format the printing. With the Amstrad, we just need to set the number of characters for the digits that we want to be printed. This also defines the number of columns that are to be used for the integer and decimal parts of the number, so our display is exactly as we want it. The value itself is not affected in any way. Some other Basic's require the programmer to calculate how big the number is, to calculate the correct column himself and to round the number to the correct number of decimal places before printing.
The alternative method of positioning text on the screen is to use the graphics cursor. The Amstrad is similar to the BBC in having two cursors, a text cursor and a graphics cursor. The Amstrad however can also print its text characters at the graphics cursor position after using the Tag command. This means that a character can be printed to align with a pixel position, not just in a full character space. I have used this facility to bring the rocket down one line at a time.

The characters of the rocket are defined using the Symbol command. The command is followed by the ASCII value of the character, the decimal value shown with each character in appendix 3 of the Amstrad manual. The following eight values are the values for each of the rows of the character. By totalling the values for each dot in the row, we end up with the eight values that go into the Symbol command. When printing text, the operating system will look for a user defined value for any character of value 240 or more. This is the default value; if the program requires more user defined characters than 240-255 then the user can set a lower figure at which they start. The top and bottom lines are both empty of dots, so that, as the program moves the rocket down or up. this line will clear away any trailing dots from previous printing. In this program we must also print two spaces above the rocket, in case it has moved more than one line at a time. At the end of the routine to print the rocket we must reset the normal printing mode, by using the Tagoff command.

The game itself is based on the old idea of trying to land on a planet surface, by burning sufficient fuel to balance the forces of gravity. Quite simple you might think, but the older programmers among you might remember how difficult it was to balance up these forces of nature. By creating equations that axe reasonably complex, there is no simple solution to the problem. By starting each landing with a random set of circumstances, it guarantees the need for a considerable amount of thought. The older game used to allow you to sit and think for a while between each of the one second intervals. This program plays in real time, albeit slightly slowed down.

To play the game, simply press the space bar to give thrust, and start to learn how the thrust and momentum do not react immediately, but take time to build up their force. This is made slightly easier by having a logarithmic type scale where the values increase more quickly at higher values.

Success of the landing depends on the landing speed of the rocket. Landing at less than 0.5 mph is a sign of expertise. Any higher speed than this and the result will vary from a bent chassis to a large crater.

The Amstrad gives a lot of flexibility in creating graphics or printing text. I could have added a lot more to the program to give such things as crash sequences, a top ten table, a "proper" circular speedometer, flames and noise, but all this would have added to your typing.



AUTHOR: Ian Morton

★ YEAR: 1984


» Lunar  Lander    (Popular  Computing  Weekly)    LISTING    ENGLISHDATE: 2017-05-10
DL: 44 fois
SIZE: 173Ko
NOTE: Uploaded by CPCLOV ; 2 pages/PDFlib v1.6

Je participe au site:
» Newfile(s) upload/Envoye de fichier(s)


L'alinéa 8 de l'article L122-5 du Code de la propriété intellectuelle explique que « Lorsque l'œuvre a été divulguée, l'auteur ne peut interdire la reproduction d'une œuvre et sa représentation effectuées à des fins de conservation ou destinées à préserver les conditions de sa consultation à des fins de recherche ou détudes privées par des particuliers, dans les locaux de l'établissement et sur des terminaux dédiés par des bibliothèques accessibles au public, par des musées ou par des services d'archives, sous réserve que ceux-ci ne recherchent aucun avantage économique ou commercial ». Pas de problème donc pour nous!

CPCrulez[Content Management System] v8.7-desktop/cache
Page créée en 084 millisecondes et consultée 758 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.