-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmove.cpp
More file actions
66 lines (55 loc) · 1.65 KB
/
move.cpp
File metadata and controls
66 lines (55 loc) · 1.65 KB
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
/** ********************************************************************************
RS_Mind
9/21/18
Overworld Movement
Receives a directional input and modifies the player's coordinates accordingly.
****************************************************************************** * **/
#include <iostream>
#include <stdlib.h>
#include "map.h"
#include <vector>
using namespace std;
twoNumbers movement(int locationX, int locationY, int scale, std::vector< vector<char> >& walls, std::vector< vector<char> >& floors)
{
char dir;
int playerY;
int playerX;
playerX = locationX;
playerY = locationY;
cout << endl << endl << "\t\t\t\t" << endl << endl << "\t\t\t\t\t\t\t\t N " << endl << "\t\t\t\t\t\t\t\t W E" << endl << "\t\t\t\t\t\t\t\t S " << endl << "\t\t\t\t\t\t\t\t ";
cin >> dir;
cin.get();
if(dir == 'n' && !(floors[playerX][playerY-1] == '-')) //move north
{
playerY -= 1;
if(playerY <= -1)
{
playerY += 1;
}
}
if(dir == 'e' && !(walls[playerX][playerY] == '|')) //move east
{
playerX += 1;
if(playerX >= scale)
{
playerX -= 1;
}
}
if(dir == 's' && !(floors[playerX][playerY] == '-')) //move south
{
playerY += 1;
if(playerY >= scale)
{
playerY -= 1;
}
}
if(dir == 'w' && !(walls[playerX-1][playerY] == '|')) //move west
{
playerX -=1 ;
if(playerX <= -1)
{
playerX += 1;
}
}
return twoNumbers{playerX,playerY};
}