Menu not responding to input

My roguelike game (Yeah, I've heard how the console isn't good, and system() is evil, and conio.h is old. Several times, in fact. So I don't particularly need to hear it again. This is just a little learning project for me.) has hit another snag: I can't get the menu's to change when you press keys. Here's it 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#include <iostream>
#include <cstdlib>
#include <conio.h>

using namespace std;

//screenNum == 1 - Gamescreen
//screenNum == 2 - Main Menu
//screenNum == 0 - Escape Menu

int mainBreak = 0;
int pInput;
int screenNum = 1;
int movementTimer;
int posx;
int posy;
int menuCursor;

void mainMenuFn();
void escMenuFn();
void mapFn();
void playerInput();
void menuInput();

int main()
{
    movementTimer = 0;
    posx = 1;
    posy = 1;

    for (mainBreak == 0; mainBreak == 0;)
    {
        playerInput();

    if (screenNum == 0)
        {escMenuFn();}
    if (screenNum == 1)
        {mapFn();}
    if (screenNum == 2)
        {mainMenuFn();}

        pInput = getch();

        system("CLS");
    }

    return 0;
}

void mainMenuFn()
{}

void escMenuFn()
{
    int loopBreak;

    menuCursor = 1;

    for (loopBreak == 0; loopBreak == 0;)
    {
        menuInput();

        // Cursor Checks
        if (menuCursor < 0)
        {menuCursor = 1;}
        if (menuCursor > 4)
        {menuCursor = 4;}

        // Cursor Actions
        if (menuCursor == 1)
        {cout << ">Return to Game\n";}
        else
        {cout << " Return to Game\n";}
        if (menuCursor == 2)
        {cout << ">Save Game\n";}
        else
        {cout << " Save Game\n";}
        if (menuCursor == 3)
        {cout << ">Options\n";}
        else
        {cout << " Options\n";}
        if (menuCursor == 4)
        {cout << ">Exit Game\n";}
        else
        {cout << " Exit Game\n";}

        getch();

        system("CLS");
   }
}

void mapFn()
{
    int mapArr[20][20];

    int markerX = 0;
    int markerY = 0;
    int x = 0;
    int y = 0;
    int mapTracker = 0;

    for (markerX = 0; markerX < 20; markerX++)
    {
        for (markerY = 0; markerY < 20; markerY++)
        {
            mapArr[markerX][markerY] = 2;
        }
    }

    mapArr[posx][posy] = 1;

    for (y = 0; y < 20; y++)
    {
        for (x = 0; x < 20; x++)
        {
            if (mapArr[x][y] == 2)
            {
                cout << ".";
                mapTracker++;
            }
            if (mapArr[x][y] == 1)
            {
                cout << "@";
                mapTracker++;
            }

            if (mapTracker == 20)
            {
                cout << "\n";
                mapTracker = 0;
            }
        }
    }

}

void playerInput()
{
    // Q - NW
    if (pInput == 113)
    {
        posx--;
        posy--;
    }
    // W - N
    if (pInput == 119)
    {
        posy--;
    }
    // E - NE
    if (pInput == 101)
    {
        posx++;
        posy--;
    }
    // A - W
    if (pInput == 97)
    {
        posx--;
    }
    // S - Hold
    if (pInput == 115)
    {
    }
    // D - E
    if (pInput == 100)
    {
        posx++;
    }
    // Z - SW
    if (pInput == 122)
    {
        posx--;
        posy++;
    }
    // X - S
    if (pInput == 120)
    {
        //posx++;
        posy++;
    }
    // C - SE
    if (pInput == 99)
    {
        posx++;
        posy++;
    }

    /* Sidebar
        Keys   */

    // esc - Menu
    if (pInput == 27)
    {
        screenNum = 0;
    }

    if (posx < 0)
    {posx = 0;}
    if (posy < 0)
    {posy = 0;}
    if (posx > 19)
    {posx = 19;}
    if (posy > 19)
    {posy = 19;}
}

void menuInput()
{
    // W - Up
    if (pInput == 119)
    {
        menuCursor--;
    }

    // S - Down
    if (pInput == 115)
    {
        menuCursor++;
    }
}


What's really affecting it is in the functions escMenuFn() and menuInput(). I did a test to find out what number getch() returns for each key, so I know those are accurate. If you paste that code into a compiler (I use Code::Blocks, but I don't know if which one you use makes a difference) and compile it, QWEASDZXC control the character and esc pulls up the menu. W and S should control the menus cursor, but they don't. I'm not sure why. Can anybody tell me what I'm doing wrong?
Yeah, I've heard ... [snip] This is just a little learning project for me.)


The problem is you're not really learning much by doing it that way, since what you're learning won't be applicable to future projects.
Topic archived. No new replies allowed.