#include #include #define _DEBUGGING 0 #define _NORTH 8 #define _EAST 4 #define _SOUTH 2 #define _WEST 1 #define _FORWARD 8 #define _RIGHT 4 #define _BACKWARD 2 #define _LEFT 1 #define _NEWLINE 10 #define _SPACEBAR 32 /* adv - text based adventure. See changelog for details and ideas for future work */ char *roomName[16] = {"hallen", "ett vardagsrum", "Rum 2", "Rum 3", "Rum 4", "Rum 5", "Rum 6", "Rum 7", "Rum 8", "Rum 9", "Rum 10", "Rum 11", "Rum 12", "Rum 13", "Rum 14", "Rum 15"}; char *roomDesc[16] = { "Det ligger en ful matta på golvet. \nDet luktar ättika..", "En TV står och brusar bredvid en bokhylla.\nTapeterna på väggen ramlar nästan av."}; short int roomExits[16] = {15,15,15,15, /* Binary information about available exits */ 15,15,15,15, /* 1000 - north, 0100 - east, 0010 - south, 0001 - west */ 15,15,15,15, 15,15,15,15}; short int commandParts; char command[5][16]; short int currentRoom; short int looking; /* Will hold direction in the same format as directions */ int main () { startup(); while(1) { enterRoom(); prompt(); parseCommand(); } } int startup () { printf("***************************\n"); printf("* E T T Ä V E N T Y R *\n"); printf("***************************\n\n\n"); printf("Du står utanför ett hus och sparkar in dörren.\nDen går itu och du går in...\n\n"); looking = _NORTH; /* Utgå från rum 13 och titta norrut */ currentRoom = 13; return 0; } int enterRoom () { printf("- - Du är i %s\n\n", roomName[currentRoom]); printf("%s \n\n", roomDesc[currentRoom]); } int prompt () { char input[40]; /* Hold user input */ printf("Vad vill du göra?\n"); fgets(input,40,stdin); printf("\n"); commandParts=0; int i=0; int ltr=0; /* Position marker for the word being processed */ while (i