Can anyone assist me with my C++ game?

Hey, I'm making a somewhat RPG game for fun, I'm in a 10th grade CS class so don't make fun of it's horrendous code, and I am using elements that we have not learned yet in the class (Functions), so yeah, can anyone help me with this? For some reason when I choose a "move", it doesn't want to increment or decrement my x or y coordinate. (You'll see if you compile the code, respond with any questions and I'll try to respond.) NEW: I have tried several nested if statements, and certain things that just don't want to work.

Also, I need the game to not increment turn or the coordinate of the player if they move off of the board in either direction.

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
#include <iostream>
#include <stdlib.h> 
#include <time.h>  

//uses the std for the following
using std::cout;
using std::cin;
using std::endl;

void battleScene();

//declares character enemyOne to be used
char enemyOne()
{
     //pulls a random number from 1-10 for the x and y coordinates.
	int enemyOneX = rand() % 10 + 1;
	int enemyOneY = rand() % 10 + 1;
	//declares the enemyOne x and y coordinates.
	int enemyOneXCoord = enemyOneX;
	int enemyOneYCoord = enemyOneY;
	 
}
//declares character enemyTwo to be used.
char enemyTwo()
{
     //pulls a random number from 1-10 for the x and y coordinates.
	int enemyTwoX = rand() % 10 + 1;
	int enemyTwoY = rand() % 10 + 1;
	//declares the enemyTwo x and y coordinates.
	int enemyTwoXCoord = enemyTwoX;
	int enemyTwoYCoord = enemyTwoY;
	 
}
//declares character enemyThree to be used
char enemyThree()
{
     //pulls a random number from 1-10 for the x and y coordinates.
	int enemyThreeX = rand() % 10 + 1;
	int enemyThreeY = rand() % 10 + 1;
	 //declares the enemyTwo x and y coordinates.
	int enemyThreeXCoord = enemyThreeX;
	int enemyThreeYCoord = enemyThreeY;
	 
}
//begins main function
int main()
{
    //declares srand statement so rand can be used.
	srand (time(NULL));
	//declares the character Hero. (May not be needed)
	char Hero;
	//sets integer resume to one
	int resume=1;
	//below is the title screen.
	cout<<"              xxxxxxxxx    xxxxxxxxx    xx        xx   xxxxxx  "<<endl;
	cout<<"              x            x       x    xx        xx   x       "<<endl;
	cout<<"              x            xxxxxxxxx    xx        xx   xxxxxx  "<<endl;
	cout<<"              x            x       x      x      x     x       "<<endl;
	cout<<"              xxxxxxxxx    x       x       xxxxxx      xxxxxx  "<<endl;
	
	cout<<"\n";
	cout<<"\n";
	
	cout<<"       xxxxxxxxx    xxxxxxx      xxxxxxxxxxx     x   x   x    x         "<<endl;
	cout<<"       x            x      x     xx       xx     x   x   x    x         "<<endl;
	cout<<"       x            xxxxxxxxx    xxxxxxxxxxx     x   x   x    x         "<<endl;
	cout<<"       x            x       x    xx       xx     x   x   x    x         "<<endl;
	cout<<"       xxxxxxxxx    x       x    xx       xx     xxxxxxxxx    xxxxxxxxx "<<endl;  
	
	cout<<"\n";
	cout<<"\n";
	
	//user enters 1 to start the game, Q at any time to quit.
    cout<<"		Press 1 To Play.		Press Q to quit.			  "<<endl;
	cin>>resume;
	while(resume == 1)
	//basically, this while loop controls the game.
	{
		int move;
		int xCoord = 0;          //declares the x and y position for char Hero.
		int yCoord = 0;
		int spawn;               /*declares spawn so user can spawn the enemies and stuff, 
                                 *basically, this is what controls the players position.
                                 *and also controls where everything is spawned*/
                                 
		cout<<"Press 2 to spawn your enemies, treasure, and yourself!\n";
		cin>>spawn;
		
		/*this while loop is for controlling a turn, every time the player moves,
		*it counts as a turn. AI is supposed to move during this time too, but
		*the AI has not been added yet.
		*/
		
		while(spawn == 2)
		{
            //if statements are not breaking if one statement is false?
			int turn=0;
			while(turn < 20)
			{
			 cout<<"Turn:"<<turn<<"\n";
			 cout<<"You are a caver who is exploring the ruins! Your coords are: X:"<<xCoord<<", Y: "<<yCoord<<"\n";
             cout<<"To move, choose 8 for Up, 7 for Left, 5 for Down, and 9 For Right.\n";
			 cin>>move;
			 
			 //this if statement is for if a player enters an invalid turn direction.
             if(xCoord < 0 || yCoord < 0)
             {
                       cout<<"You cannot move there, that is off the board\n";
                       break;
             }
             if(move==8)
             {
                 yCoord++;
                 turn++;
                 cout<<"Y Coordinate Increased.\n";
             }
                 else if(move==7)
                 {
                      xCoord--;
                      turn++;
                      cout<<"X Coordinate Decreased.\n";
                 }
                      else if(move==5)
                      {
                           yCoord--;
                           turn++;
                           cout<<"Y Coordinate Decreased.\n";
                      }
                           else if(move==9)
                           {
                                xCoord++;
                                turn++;
                                cout<<"X Coordinate Increased.\n";
                           }       
                             
                      /*redeclares the if statement for x OR y coords being negative. may or may not 
                      *be needed.*/
                      if(xCoord < 0 || yCoord < 0)
                      {
                         cout<<"You cannot move there. That is off the board.\n";
                      }
             //ends the while loop "turn"
             }
          //ends spawn while loop
	      }
		
		
	system("PAUSE");
	return 0;
	//ends game while loop
  }
  //ends program
}

//no syntax errors
//only errors that occur during the while loop and if statements
//to do: ADD ENEMY AI!!!!!!!!!!!
//to do: ADD TREASURE AND GOAL

//ignore this for now
void battleScene()
{
	cout<<"You have encountered an enemy! What will you do?"<<endl;
	cout<<"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
	cout<<"x               xx               x";
	cout<<"x Attack (1 HP) xx   Use Item    x";
	cout<<"x               xx               x";
	cout<<"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
	cout<<"x               xx               x";
	cout<<"x               xx     Flee      x";
	cout<<"x               xx               x";
	cout<<"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
This code shouldn't even compile. Your functions don't return any values.
The BattleScene function shouldnt be in there right now I know, and I'll void the other enemy functions, but yeah it still compiles...
Does anyone have an idea?
Can you try to narrow it down to specific functions?
Topic archived. No new replies allowed.