KNIGHT FIGHT ------------ by Robert Speel from ZX Computing, April/May 1983 A book entitled "Better Programming For Your Spectrum And ZX81" hit the bookshops last month. Here we give you a sneak preview of two of the programs featured in this new publication written by Robert Speel. Although the two programs featured here are both essentially games programs, the book also contains several more serious programs. The text begins with a look at Spectrum colour and sound, with chapters on user-defined characters and the use of high resolution graphics. Program examples are provided throughout and all the techniques utilized within the longer programs are explained within the text. Programs are included for both the Spectrum and the ZX81, with a useful chapter on converting programs for the ZX81 so that they will run on the Spectrum. The following two programs are good examples of the type of programming material included within Robert Speel's new book — Knight Fight has been written for the 16K ZX Spectrum and Alien Descender requires 2.5K to run on a ZX81. Knight Fight This game involves a fight between two knights. You control a white knight, and the computer has a black knight. At the start, you have to select armour and weapons for your knight. You have 100 gold coins to spend, which means you cannot have the heaviest armour and lance and the best weapons too. A mace is the strongest attacking weapon, a sword the weakest. However, a sword is useful in defence as well as attack, whereas an axe or mace is not. Once you have chosen your weapons, the enemy's choice is announced. The fight then begins. At first, the knights joust on horseback until one knight is knocked off his horse. Apart from your choice of lance and armour, you have no control over the jousting. Once one knight is unhorsed, the other will dismount and the fight continues on foot. You attack the opponent knight by moving near to him using the keys 5 and 8 to move. You "hit" by pressing one of the keys 1, 2, 3 or 4 - the number determining the strength of hit. Each time you hit, your strength, shown at the bottom left of the screen goes down by that number. If your strength reaches zero, you die. By moving away from the enemy, you can gradually recover your strength up to your maximum. A successful hit on the enemy lowers his strength by one permanently. The enemy strikes you in exactly the same way. This means that fighting consists of rushing up to your opponent, hitting at him a few times, then retiring to recover from your exhaustion. It is essential that you keep an eye on your own strength to know when to retreat. Gradually, your maximum strength will be depleted (and so, hopefully, will your opponent's) until one or the other, with a strength of three or less, cannot strike properly. Death for the weaker usually follows quickly. Notes on the listing This is rather a long game which occupies nearly all of the basic 16K Spectrum. Due to the large numbers of user-defined graphics, the use of CHR$ 144, etc. has been dropped, and graphics characters are used in the listings. All capital letters inside quotes should be graphic letters; ie. you must go into graphics mode, then press the letter. If you forget one or two, you may see knights charging around on the backs of ABC creatures. If this occurs, BREAK the program, find the letter, and replace it with a graphic letter. Lines Action 10 GOSUB start routine, buy weapons and set up user-defined graphics. 100-110 Basic "charge on horseback" routine. Graphics ABC and LKJ are the horses, DEF/GHI and ONM/RQP are alternate sets of legs to give a galloping effect. In lines 100 and 130, the underline character is used (Symbol Shift 0) as the point of a lance; US and TU are the rest of the lance and the knight. 160 Gives a simulation of the sound of horses' hooves, which sounds very good when amplified. 170 Deals with a possible crash between the two knights. 180 Checks if the knights are about to go off screen. 200-910 Cope with what happens when the knights meet on horseback. 200-240 Is the actual hit, strengths of opponents being calculated to take in armour, lance-type and shields. 500-540 Show the left knight falling off. 600-840 Show the right knight falling off. 800-840 Check if a knight has fallen off at the end of a run. 900-910 Deal with turning at the end of a run when neither knight is knocked off his horse. 1000-1040 Turn horses round at end of run when one man is down; and dismounts other knight. 1100-1430 Foot-fighting loop. 1100 PRINTs two knights with correct weapons. 1120 Moves your knight. 1130 Moves opponent's knight, including automatic retreat when strength below 3. 1200-1260 Your knight hits opponent if in range. 1300-1320 Enemy hits you. Your hits and your opponent's depend for their success on the strength of hit (1 -4), the weapon's attack value (1-3), its defence value if it is a sword, armour and shields, if any, together with a random attack value. When all these are added, the hit is judged successful or unsuccessful. 1330-1340 If your current strength is larger than your maximum strength, then let current strength = maximum strength. 1400-1430 If knights are a distance apart, then they can gradually recover to their current maximum strength. 4000-4010 You die. 4500-4510 Enemy dies 7000-7280 Start of game. You choose your weapons and armour, from list giving prices. Note improper entries will be ignored. 7320-7460 Enemy chooses weapons. Either enemy chooses to have a strong attack or a strong defence. 8000-8500 DRAW castle in background and start fight. 9000-9130 DATA for user-defined graphics used for knights, horses and weapons.