-
Notifications
You must be signed in to change notification settings - Fork 0
/
space2.cpp
77 lines (71 loc) · 2.2 KB
/
space2.cpp
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
/********************************************************
* Program Name: space2.cpp
* Author: George Lenz
* Date: 03/18/2018
* Description: Implementation file for space2 class
********************************************************/
#include <iostream>
#include <string>
#include "space2.hpp"
#include "spaces.hpp"
#include "character.hpp"
using namespace std;
void Space2::movePlayer(char& aChar)
{
if(aChar == 'w')
{
if(player->getRow() == 0)
{
return;
}
boardPtr[player->getRow()][player->getColumn()]=player->getPrevious();
player->setRow(player->getRow()-1);
player->setPrevious(boardPtr[player->getRow()][player->getColumn()]);
placeChar(player->getCharUpDown());
}
if(aChar == 's')
{
if(player->getRow() == 23)
{
return;
}
boardPtr[player->getRow()][player->getColumn()]=player->getPrevious();
player->setRow(player->getRow()+1);
player->setPrevious(boardPtr[player->getRow()][player->getColumn()]);
placeChar(player->getCharUpDown());
}
if(aChar == 'd')
{
if(player->getColumn() == 19)
{
if(player->getRow() == 12)
{
player->setColumn(0);
player->setRow(12);
player->setPrevious("||..");
nextSpace(right);
return;
}
return;
}
boardPtr[player->getRow()][player->getColumn()]=player->getPrevious();
player->setColumn(player->getColumn() + 1);
player->setPrevious(boardPtr[player->getRow()][player->getColumn()]);
placeChar(player->getCharRight());
}
if(aChar == 'a')
{
if(player->getColumn() == 0)
{
return;
}
boardPtr[player->getRow()][player->getColumn()]=player->getPrevious();
player->setColumn(player->getColumn() -1);
player->setPrevious(boardPtr[player->getRow()][player->getColumn()]);
placeChar(player->getCharLeft());
}
}
void Space2::printa(int arow, int acolumn)
{
cout << boardPtr[arow][acolumn] << endl;
}