Any comments on my text based game

My game is not finished but I would just like people to give their comments on it and I will gladly take into mind any criticism.

Here's all the code so far:
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
159
160
161
162
163
#include <iostream>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<ctime>
using namespace std;

int main()
{
    char name[10];

    cout << "Welcome, hope you enjoy this game!\n\n";
    cout << "What is your name?\n";
    cin >> name;
    cout << "Hello, " << name << "!!\n\n";

    cout << "What is your race?\n" << endl;
    cout << "1- Human\n" << "2- Dwarf\n" << "3- Orc\n" << "4- Elf\n" << endl;
    int pickRace;

    cout << "Pick your race: ";
    cin >> pickRace;

    switch (pickRace)
    {
    case 1:
        cout << "You picked the Human race.\n" << endl;
    break;

    case 2:
        cout << "You picked the Dwarf race.\n" << endl;
    break;

    case 3:
        cout << "You picked the Orc race.\n" << endl;
    break;

    case 4:
        cout << "You picked the Elf race.\n" << endl;
    break;

    default:
        cout << "Error - Invalid input; only 1, 2, 3, or 4 allowed.\n" << endl;
    }

    cout << "====================" << endl;

    cout << "[C] = you\n" << "The 4 ~ lines is the door" << endl;
    cout << "M = Monster\n" << "The 4 t's is the table" << endl;
    cout << "H = human\n" << "The 2 c's is the chest" << endl;

    cout << "-------------------------------" << endl;
    cout << "| M           [C]         tt   |" << endl;
    cout << "|                         tt   |" << endl;
    cout << "| c                            |" << endl;
    cout << "| c                            |" << endl;
    cout << "|                              |" << endl;
    cout << "|                              |" << endl;
    cout << "|                              |" << endl;
    cout << "|                            H |" << endl;
    cout << "---------------~~--------------" << endl;
    cout << "               ~~              " << endl;

    cout << "You can move by typing in..." << endl;
    cout << "1- Down... 2- Left... 3- Right" << endl;
    int o2;
    cin >> o2;

    switch(o2)
    {
    case 1:
    cout << "-------------------------------" << endl;
    cout << "| M                       tt   |" << endl;
    cout << "|             [C]         tt   |" << endl;
    cout << "| c                            |" << endl;
    cout << "| c                            |" << endl;
    cout << "|                              |" << endl;
    cout << "|                              |" << endl;
    cout << "|                              |" << endl;
    cout << "|                            H |" << endl;
    cout << "---------------~~--------------" << endl;
    cout << "               ~~              " << endl;
    break;

    case 2:
    cout << "-------------------------------" << endl;
    cout << "| M        [C]            tt   |" << endl;
    cout << "|                         tt   |" << endl;
    cout << "| c                            |" << endl;
    cout << "| c                            |" << endl;
    cout << "|                              |" << endl;
    cout << "|                              |" << endl;
    cout << "|                              |" << endl;
    cout << "|                            H |" << endl;
    cout << "---------------~~--------------" << endl;
    cout << "               ~~              " << endl;
    break;

    case 3:
    cout << "-------------------------------" << endl;
    cout << "| M              [C]      tt   |" << endl;
    cout << "|                         tt   |" << endl;
    cout << "| c                            |" << endl;
    cout << "| c                            |" << endl;
    cout << "|                              |" << endl;
    cout << "|                              |" << endl;
    cout << "|                              |" << endl;
    cout << "|                            H |" << endl;
    cout << "---------------~~--------------" << endl;
    cout << "               ~~              " << endl;
    break;
    }

cout << "You can move by typing in..." << endl;
    cout << "1- Down... 2- Left... 3- Right" << endl;
    cin >> o2;

    switch(o2)
    {
    case 1:
    cout << "-------------------------------" << endl;
    cout << "| M                       tt   |" << endl;
    cout << "|                         tt   |" << endl;
    cout << "| c           [C]              |" << endl;
    cout << "| c                            |" << endl;
    cout << "|                              |" << endl;
    cout << "|                              |" << endl;
    cout << "|                              |" << endl;
    cout << "|                            H |" << endl;
    cout << "---------------~~--------------" << endl;
    cout << "               ~~              " << endl;
    break;

    case 2:
    cout << "-------------------------------" << endl;
    cout << "| M     [C]               tt   |" << endl;
    cout << "|                         tt   |" << endl;
    cout << "| c                            |" << endl;
    cout << "| c                            |" << endl;
    cout << "|                              |" << endl;
    cout << "|                              |" << endl;
    cout << "|                              |" << endl;
    cout << "|                            H |" << endl;
    cout << "---------------~~--------------" << endl;
    cout << "               ~~              " << endl;
    break;

    case 3:
    cout << "-------------------------------" << endl;
    cout << "| M                 [C]   tt   |" << endl;
    cout << "|                         tt   |" << endl;
    cout << "| c                            |" << endl;
    cout << "| c                            |" << endl;
    cout << "|                              |" << endl;
    cout << "|                              |" << endl;
    cout << "|                              |" << endl;
    cout << "|                            H |" << endl;
    cout << "---------------~~--------------" << endl;
    cout << "               ~~              " << endl;
    break;
    }
}
Hi, just a quick comment. Those switch statements are going to get very long very quickly to take into account all cases of the player moving. You might consider keeping track of the player's position with a 2d array and then printing it (using a loop) to the screen whenever the game state is updated. That way you'll only need 1 of these (adjusted) map printouts:

1
2
3
4
5
6
7
8
9
10
11
    cout << "-------------------------------" << endl;
    cout << "| M                 [C]   tt   |" << endl;
    cout << "|                         tt   |" << endl;
    cout << "| c                            |" << endl;
    cout << "| c                            |" << endl;
    cout << "|                              |" << endl;
    cout << "|                              |" << endl;
    cout << "|                              |" << endl;
    cout << "|                            H |" << endl;
    cout << "---------------~~--------------" << endl;
    cout << "               ~~              " << endl;


The trick is figuring out how to convert the user's position heroPosition[3][4] to a desired dot on the map. Keep at it :)
Instead of using 1234, use WASD as most players are used to that format.

Use a single character to represent the player, and instead of using a switch-case function, try using a virtual function or class for the map generator. Then you can set the player's position with a code number and draw the map using a 2-D array and FOR loops. You can then build functions that take the WASD inputs and add to or subtract from the player's position. This might save you time from redrawing the map over and over again. You can probably also set Boolean variables for the items in the room.

Using the tildes for the doors might be impractical for times when you want the door to be on the side.
You should also keep in mind when making the 2D array to not let the player go off the game board. This will make your program crash.
Good luck! :)
Hi, I strongly recommend this tutorial to get you started on ascii roguelikes. Once you have finished, it should give you a much more broad understanding on the concept, and from there you should be able to design your own code. That's what I did!

http://www.kathekonta.com/rlguide/index.html
Thanks all you guys this helped a lot
I will try to update it an show you guys again if you want me to
Topic archived. No new replies allowed.