1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
#include "cworld.h"
#include <iostream>
cworld::cworld()
{
// 0 is North, 1 is East, 2 is South, 3 is West
gameWorld[0][0].setTileName("");
gameWorld[0][0].setExits(true, false, true, false);
gameWorld[0][0].setTileExamine("");
gameWorld[0][0].setExitDescription(0, "");
gameWorld[0][0].setExitDescription(1, "");
gameWorld[0][0].setExitDescription(2, "");
gameWorld[0][0].setExitDescription(3, "");
gameWorld[0][0].setTileName("");
gameWorld[0][0].setExits(true, false, true, false);
gameWorld[0][0].setTileExamine("");
gameWorld[0][0].setExitDescription(0, "");
gameWorld[0][0].setExitDescription(1, "");
gameWorld[0][0].setExitDescription(2, "");
gameWorld[0][0].setExitDescription(3, "");
gameWorld[0][0].setTileName("");
gameWorld[0][0].setExits(false, false, false, false);
gameWorld[0][0].setTileExamine("");
gameWorld[0][0].setExitDescription(0, "");
gameWorld[0][0].setExitDescription(1, "");
gameWorld[0][0].setExitDescription(2, "");
gameWorld[0][0].setExitDescription(3, "");
gameWorld[0][0].setTileName("");
gameWorld[0][0].setExits(true, false, true, false);
gameWorld[0][0].setTileExamine("");
gameWorld[0][0].setExitDescription(0, "");
gameWorld[0][0].setExitDescription(1, "");
gameWorld[0][0].setExitDescription(2, "");
gameWorld[0][0].setExitDescription(3, "");
gameWorld[0][0].setTileName("");
gameWorld[0][0].setExits(false, true, true, true);
gameWorld[0][0].setTileExamine("");
gameWorld[0][0].setExitDescription(0, "");
gameWorld[0][0].setExitDescription(1, "");
gameWorld[0][0].setExitDescription(2, "");
gameWorld[0][0].setExitDescription(3, "");
gameWorld[1][0].setTileName("");
gameWorld[1][0].setExits(false, false, false, false);
gameWorld[1][0].setTileExamine("");
gameWorld[1][0].setExitDescription(0, "");
gameWorld[1][0].setExitDescription(1, "");
gameWorld[1][0].setExitDescription(2, "");
gameWorld[1][0].setExitDescription(3, "");
//THIS PART CONTINUES UNTIL the 25 GAME TILES of a 5 by 5 array for filled!
//I REMOVED A LOT OF IT TO SHORTEN THE POST :)
playerX = 0, playerY = 0;
}
char cworld::userPrompt()
{// Displays valid moves to user and takes string input but only uses first character
const int options = 4;
const std::string choices[options] = {"[N]orth", "[E]ast", "[S]outh", "[W]est"};
std::string takeUserInput;
char extractInput;
std::cout << "\n\n" << std::endl;
for (int x = 0; x < options; x++)
{
if (gameWorld[playerX][playerY].getExit(x))
{
std::cout << choices[x] << std::endl;
}
}
std::cout << std::endl << ">";
std::cin >> takeUserInput;
extractInput = toupper(takeUserInput[0]);
return extractInput;
}
void cworld::choiceCheck(char choice)
{
switch (choice){
case 'N': if (gameWorld[playerX][playerY].getExit(0))
{
std::cout << "Test successful" << std::endl;
}
else
{
userPrompt();
}
break;
case 'E': if (gameWorld[playerX][playerY].getExit(1))
{
std::cout << "Test successful" << std::endl;
}
else
{
userPrompt();
}
break;
case 'S': if (gameWorld[playerX][playerY].getExit(2))
{
std::cout << "Test successful" << std::endl;
}
else
{
userPrompt();
}
break;
case 'W': if (gameWorld[playerX][playerY].getExit(3))
{
std::cout << "Test successful" << std::endl;
}
else
{
userPrompt();
}
break;
default: std::cout << "Unrecognized command" << std::endl;
userPrompt();
}
}
|