-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBanana.cpp
More file actions
26 lines (18 loc) · 720 Bytes
/
Copy pathBanana.cpp
File metadata and controls
26 lines (18 loc) · 720 Bytes
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
#include "Banana.h"
#include <iostream>
#include <string>
Banana::Banana() : Obstacle('(', "You slipped on a banana ") {
}
int Banana::touched(Maze* maze, Person* person, int keyPress) {
Obstacle* nextOb = maze->getNextObstacle(person, keyPress);
while (!(nextOb->isWall())) {
if (person->move(maze, keyPress)) { //if the player was moved involuntarily ('move' returns 1 if so)
break; //break out of the banana slide
}
nextOb = maze->getNextObstacle(person, keyPress); //get the next obstacle relative to the new position
}
Obstacle::touched(maze, person, keyPress);
return 1; //person was moved involuntarily so touched returns 1
}
Banana::~Banana() {
}