Here's what I have so far.

Anything related in any way to game development as a whole is welcome here. Tell us about your game, grace us with your project, show us your new YouTube video, etc.

Moderator: PC Supremacists

Post Reply
HeWasLikeAGhost
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 5
Joined: Sat Jan 22, 2011 4:17 am
Current Project: Working on a MUD
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Location: Iowa
Contact:

Here's what I have so far.

Post by HeWasLikeAGhost »

Alright, my first game project is making a text adventure game. I've got the rooms linked so far. I haven't seen anyone else linking their rooms like this and it might be a horrible way but I thought it was cool that I haven't seen any other code like mine. Makes it feel like it's mine. ;]

Code: Select all

#include <iostream>
#include <string>
using namespace std;

// This is where all the rooms are created.
// Further down is a function that connects all the rooms.

class roomcreation{
  public:

    void setName(string name);
    string getName();

    void setDesc(string desc);
    string getDesc();

  private:

    string itsName;
    string itsDesc;};

void roomcreation::setName(string name){
  itsName = name;}

string roomcreation::getName(){
  return itsName;}

void roomcreation::setDesc(string desc){
  itsDesc = desc;}

string roomcreation::getDesc(){
  return itsDesc;}

int main(){

  int playerPosition = 0;
  string name;
  string choice;

  roomcreation room1;
  room1.setName("Room 1\n");
  room1.setDesc("This is a blank room.\n\n");

  roomcreation room2;
  room2.setName("Room 2\n");
  room2.setDesc("This is a blank room.\n\n");

  roomcreation room3;
  room3.setName("Room 3\n");
  room3.setDesc("This is a blank room.\n\n");

  cout << "Please enter a name: ";
  cin >> name;
  cout << "Name has been set to " << name << ".\n\n";

  while(choice != "quit"){

    if(playerPosition == 0){
      cout << room1.getName();
      cout << room1.getDesc();
      cout << ": ";
      cin >> choice;
      if(choice == "n"){
        playerPosition = 1;}}

    if(playerPosition == 1){
      cout << room2.getName();
      cout << room2.getDesc();
      cout << ": ";
      cin >> choice;
      if(choice == "n"){
        playerPosition = 2;}
      if(choice == "s"){
        playerPosition = 0;}}

    if(playerPosition == 2){
      cout << room3.getName();
      cout << room3.getDesc();
      cout << ": ";
      cin >> choice;
      if(choice == "s"){
        playerPosition = 1;}}}

return 0;}
And now I'm going to put some monsters in. I think I'll make the respawn function do something like, every time the player moves "respawn" gets a +1 to it. Whenever it is greater than equal to the respawn number the monsters in the room attack the player and also reset the respawn rate to 0.

Anyways, enjoy.

-Ghost
I'm A Scrub
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Re: Here's what I have so far.

Post by XianForce »

Just a recommendation as for how you're naming things... It'd probably be more appropriate to name "roomcreation" as just "Room". When you declare a room like: roomcreation room1; You're stating that room1 is a roomcreation... But it's not really a roomcreation it's a room?
Post Reply