![]() We now define some handy boolean functions which tell us if a given object is being carried, is in the room, is is here (meaing carried or in the room). The locations are: -1: being carried, 0: nowhere, room number: lying in that room. For example object is the location of the lamp. In our game we use an array, object, to contain the current location of each object. An object can either be carried, lying around somewhere, or nonexistent. To add more rooms to our game we merely have to add their descriptions to describeroom, and make provision for getting to and from them in the movement procedures.Ī lot of the fun in adventure games is finding “objects” (such as lamps and rods) and discovering a use for them. Movement can be conditional - in the above example the player can only move from room 19 to 18 if carrying the statue. The movement procedures handle all movement in a single case statement (per verb) - invalid directions are caught by the else clause of the case. When the player enters a movement command such as NORTH, SOUTH, UP, DOWN and so on, the verb procedure calls the appropriate movement procedure. A rocky path to the west curves north.") ĭescriberoom also prints a description of all objects in the same room as the player: for i := 0 to maxobj do A rocky path leads south.") Ģ: writeln ("on a rocky path leading north and curving to the east.",chr(newline),ģ: writeln ("at the entrance to a dark cave. write ("You are ") ġ: writeln ("at a plateau near a cliff. If room and oldroom differ the program prints a description of the current location by using a case statement in describeroom. Their previous location is stored in oldroom. The player’s current location is stored in room. Our adventure player can take one of five general categories of actions: Move (for example, GO NORTH) take something (TAKE ROD) drop something (DROP LAMP) use something (WAVE RING) and other (SCORE, QUIT, INVENTORY). getword also keeps track of where the whole word starts and ends, so if you take TAKE ANTELOPE it can reply I SEE NO ANTELOPE HERE rather than I SEE NO ANT HERE. Getword may seem a bit obscure, but it pasically “packs” the first three letters of the next word on the input line into a single integer (G-Pascal uses 3-byte integers so this is a neat way of storing a three-letter word).Ī side-effect of this is that our game only regards the first three characters of the word as significant. ![]() You could easily accept more than two words by changing the constant maxwords. If getline finds more than two words it asks the player to try again. This calls getword twice to decode the text into two words. For the sake of brevity commands such as GO NORTH can be abbreviated to the direction only: NORTH (for example).Ĭommands are accepted from the player by getline which reads a line of text from the player. Our game expects commands to consist of a verb, followed in some cases by a noun. Because of its size you need to make the hardware modification described here, to give yourself 24kB of RAM rather than 16kB.Īdventure games generally accept commands from the player in the form of two-word sentences, for example GET ROD or WALK NORTH. Its strong structure makes it easy to debug and enhance.The case statement is very useful for decision-making.Its long data names make the program self-documenting. ![]() Have you not wanted to write your own game? To design a dungeon, place treasures, make mazes, and generally be in control? With G-Pascal you can do that with a minimum of fuss. ![]() These days, of course, you can play in highly sophisticated immersive 3D worlds, such as World of Warcraft, and Final Fantasy XIV. Ever since Will Crowther and Don Woods wrote in 1976 the “original” Adventure game, known as Colossal Cave Adventure, computerised fantasy games have become very popular. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |