I've shortened the code I've written to just the class, instance, and function with the if statement that's calling the data from the class instance.
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;
class room //The class for all the diffrent rooms in the game
{
public:
int level;//Shows which level the room is in.
int type;//Filled with water, or fire, or other obstacal that requires a magical cape to get by.
bool north;//The directions that the player can travel in.
bool south;
bool east;
bool west;
bool teleport;//Allows player to teleport to levels that he has been to.
bool nextFloor;//Route to the next level.
bool start;//the starting location for the level.
bool monster1;//Monsters of lowest levelThe game randomly chooses between the monsters from 1 of three diffrent levels.
bool monster2;//Monsters of medium level
bool monster3;//Monsters of high level
}
//The function that currently only tells you if you can travel west or not. (Will be expanded later when it starts working.)
//This is where the data from the class instance is being called at
int castleRoom(){
if (startTest::west == true){cout<<'You can travel west.';}
else {cout<<'You can't travel west';}
};
int main(int argc, char *argv[])
{
// This is the instance that the function is calling data from
room startTest; // The instance from the class 'room', it has the characteristics of the starting room.
startTest.level = 1;
startTest.type = 1;
startTest.north = false;
startTest.south = false;
startTest.east = false;
startTest.west = true;
startTest.teleport = false;
startTest.nextFloor = false;
startTest.start = true;
startTest.monster1 = false;
startTest.monster2 = false;
startTest.monster3 = false;
castleRoom(); //Calls the function
system('PAUSE');
return 0;
}
There also seem to be some other problems in the code that I havn't gotton out yet. Or maybe it's relevant to the problem that I'm asking about.

New Topic/Question
Reply




MultiQuote




|