Ideas For My Little RPG Game

Hey guys. So I have just finished my first semester of software engineering and Ive learned quite a bit about c++. I am trying to make a little text based rpg just for a little enjoyment as a small project and to wow some friends. I am just wanting some help with some ideas that would be interesting to implement somewhere down the road.

Right now my skill level is up to searching and sorting through arrays with the bubble/selection sort functions and linear/binary search functions along with their stl vector equivalents. I am just wondering, what could I do with the current knowledge that I have and a text based rpg game.

here is my code so far.
it gets up to the point where it lets you choose a path. After that I am not sure really where to take it. So many possibilities lol.

It is a very rough sketch beginning start with just one character and some example stats for testing and what not. Also I would like to know how I would get the input validation for the path selection to not go into an infinite loop if a user enters a character instead of a number.

edit - the do while loops says character < 1 || character > 6 because I plan to have probably 6 characters.

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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
  // Plan to use ones useless now, later on in development.
#include <iostream>
#include <cstdlib>
#include <stdlib.h>
#include <vector>
#include <fstream>
#include <string>
#include <time.h>
#include <Windows.h>
//used to maximize screen
#pragma comment(lib,"kernel32.lib")
#pragma comment(lib,"user32.lib")

using namespace std;

int main ()
{
   void clearScreen();
   int characterSelection();
   void displaySelection();
   void displayMainMenu(int, string);


   const int MAX_LEVEL = 100;
   char beginGame;
   int character, charLevel;
   string characterName;

   //tells screen to maximize
   HWND hWnd = GetConsoleWindow();
   ShowWindow(hWnd,SW_MAXIMIZE);

   cout << "Hello!\n\n"
        << "Welcome to my very own text based RPG game!\n"
        << "May we begin?\n"
        << "Enter \"Y\" to begin or enter \"N\" to exit...";

   do{

      cin >> beginGame;

      if (beginGame == 'y' || beginGame == 'Y')
      {
         clearScreen();
      }
      else if (beginGame == 'n' || beginGame == 'N')
      {
         exit(0);
      }
      else
      {
         cout << "Please choose \"y\" or \"n\"....";
      }

   }while (beginGame != 'y' && beginGame != 'Y' && beginGame != 'n' && beginGame != 'N');

   cout << "Please choose the character you would like to play\n\n";
   character = characterSelection();

   do{

      if (character < 1 || character > 6)
      {
         clearScreen();
         cout << "You made an incorrect selection!\n"
            << "Please make a correct selection...\n\n";

         character = characterSelection();
      }


   }while (character < 1 || character > 6);

   clearScreen();

   cout << "Welcome To my little adventure I have created for you.\n";
   cout << "What would you like your name to be?   ";
   cin >> characterName;
   
   clearScreen();
   displayMainMenu(character, characterName);
   clearScreen();




   system("pause");
   return 0;

}

void clearScreen()
{
   DWORD n;                         /* Number of characters written */
   DWORD size;                      /* number of visible characters */
   COORD coord = {0};               /* Top left screen position */
   CONSOLE_SCREEN_BUFFER_INFO csbi;

   /* Get a handle to the console */
   HANDLE h = GetStdHandle ( STD_OUTPUT_HANDLE );

   GetConsoleScreenBufferInfo ( h, &csbi );

   /* Find the number of characters to overwrite */
   size = csbi.dwSize.X * csbi.dwSize.Y;

   /* Overwrite the screen buffer with whitespace */
   FillConsoleOutputCharacter ( h, TEXT ( ' ' ), size, coord, &n );
   GetConsoleScreenBufferInfo ( h, &csbi );
   FillConsoleOutputAttribute ( h, csbi.wAttributes, size, coord, &n );

   /* Reset the cursor to the top left position */
   SetConsoleCursorPosition ( h, coord );
}

int characterSelection ()
{
   int character;

   cout << "******** (1)The Paladin ********\n"
      << "Attack - 25\n"
      << "Defense - 50\n\n";

   cin >> character;

   return character;
}

void displayMainMenu(int characterSelection, string name)
{
   int str, dex, intel, def, pathSelection;

   switch(characterSelection)
   {
   case 1:
      str = 25;
      def = 50;
      break;
   }

   cout << "**************************************\n"
           << "Character - " << name << endl
           << "Stats - Str = " << str << endl
           << "        Def = " << def << endl
           << "**************************************\n\n";

   cout << "Choose a correct path selection...\n\n"
        << "(1) To the battlefield\n"
        << "(2) To the armory\n";

   cin >> pathSelection;

   while (pathSelection < 1 || pathSelection > 2)
   {
      cout << "Please choose a correct path...";
      cin >> pathSelection;
   }
}
Last edited on
You could look at cin.fail() to start with for a little input validation.
Topic archived. No new replies allowed.