From 98ba22e7064db57316dfff1ae127feb3dceeb73e Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Thu, 31 Jul 2014 13:58:22 +0200 Subject: Initial commit --- docs/html/_maze_8cpp_source.html | 184 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 docs/html/_maze_8cpp_source.html (limited to 'docs/html/_maze_8cpp_source.html') diff --git a/docs/html/_maze_8cpp_source.html b/docs/html/_maze_8cpp_source.html new file mode 100644 index 0000000..fa9de73 --- /dev/null +++ b/docs/html/_maze_8cpp_source.html @@ -0,0 +1,184 @@ + + + + +Rally X: source/logic/Maze.cpp Source File + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + +
+
Rally X + +
+
ELEN3009 Project by Justin Wernick and David Schneider
+
+
+ + + + + +
+
+
source/logic/Maze.cpp
+
+
+Go to the documentation of this file.
00001 #include "Maze.h"
+00002 
+00003 Maze::Maze()
+00004     :_width(0),
+00005     _height(0)
+00006 {
+00007 }
+00008 
+00009 void Maze::generateMaze(const vector<pair<int,int> >& walls, int maxObjectX, int maxObjectY)
+00010 {
+00011     //find bounds so that rectangular vector can be generated
+00012     int maxX = maxObjectX;
+00013     int maxY = maxObjectY;
+00014     for (vector<pair<int,int> >::const_iterator iter = walls.begin(); iter!=walls.end(); ++iter)
+00015     {
+00016         if (iter->first > maxX) maxX = iter->first;
+00017         if (iter->second > maxY) maxY = iter->second;
+00018     }
+00019     _width = maxX+1; //need to convert from highest index to required size
+00020     _height = maxY+1;
+00021 
+00022 
+00023     _wallLocations.clear();
+00024 
+00025     for (int x=0; x<_width; ++x)
+00026     {
+00027         _wallLocations.push_back(vector<bool>());
+00028         for (int y=0; y<_height; ++y)
+00029         {
+00030             _wallLocations.back().push_back(false);
+00031         }
+00032     }
+00033 
+00034     for (vector<pair<int,int> >::const_iterator iter = walls.begin(); iter!=walls.end(); ++iter)
+00035     {
+00036         _wallLocations.at(iter->first).at(iter->second) = true;
+00037     }
+00038 }
+00039 
+00040 bool Maze::getSolid(const int& x, const int& y) const
+00041 {
+00042     if (x<0 || y<0) return true;
+00043     if (x>=width() || y>=height()) return true;
+00044     //bounds have already been checked, can use more efficient, less safe, indexing
+00045     return _wallLocations[x][y];
+00046 }
+00047 
+00048 int Maze::width() const
+00049 {
+00050     return _width;
+00051 }
+00052 int Maze::height() const
+00053 {
+00054     return _height;
+00055 }
+00056 
+00057 Maze::Direction Maze::backwards(Direction forwards)
+00058 {
+00059     Direction backwards;
+00060     switch (forwards)
+00061     {
+00062         case LEFT:
+00063             backwards = RIGHT;
+00064             break;
+00065         case RIGHT:
+00066             backwards = LEFT;
+00067             break;
+00068         case UP:
+00069             backwards = DOWN;
+00070             break;
+00071         case DOWN:
+00072             backwards = UP;
+00073             break;
+00074     }
+00075 
+00076     return backwards;
+00077 }
+
+
+ +
+ All Classes Files Functions Variables Typedefs Enumerations Enumerator
+ + +
+ +
+ + + + + + + -- cgit v1.2.3