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/_level_reader_8cpp_source.html | 161 +++++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 docs/html/_level_reader_8cpp_source.html (limited to 'docs/html/_level_reader_8cpp_source.html') diff --git a/docs/html/_level_reader_8cpp_source.html b/docs/html/_level_reader_8cpp_source.html new file mode 100644 index 0000000..f06bb16 --- /dev/null +++ b/docs/html/_level_reader_8cpp_source.html @@ -0,0 +1,161 @@ + + + + +Rally X: source/data/LevelReader.cpp Source File + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + +
+
Rally X + +
+
ELEN3009 Project by Justin Wernick and David Schneider
+
+
+ + + + + +
+
+
source/data/LevelReader.cpp
+
+
+Go to the documentation of this file.
00001 #include "LevelReader.h"
+00002 
+00003 LevelReader::LevelReader(string filename)
+00004     :_filename(filename)
+00005 {}
+00006 
+00007 void LevelReader::readLevel(Maze& maze, list<PlayerCar>& players, list<EnemyCar>& enemies, list<Checkpoint>& checkpoints, list<Rock>& rocks)
+00008 {
+00009     ifstream file(_filename.c_str());
+00010     if (!file)
+00011     {
+00012         al_show_native_message_box(NULL, "Fatal error", "Fatal error", "The requested level file could not be opened.", NULL, ALLEGRO_MESSAGEBOX_ERROR);
+00013         throw FileOpenError();
+00014     }
+00015 
+00016     int maxX = 0;
+00017     int maxY = 0;
+00018 
+00019     string line;
+00020     char element;
+00021     int y = 0;
+00022     vector <pair<int, int> > walls;
+00023 
+00024     while (!file.eof())
+00025     {
+00026         getline (file, line);
+00027 
+00028         for (int x = 0; x < static_cast<int>(line.length()); ++x)
+00029         {
+00030             element = line.at(x);
+00031             switch (element)
+00032             {
+00033                 case PLAYER_CHAR: players.push_back(PlayerCar(x,y));
+00034                 break;
+00035                 case ENEMY_CHAR: enemies.push_back (EnemyCar(x,y));
+00036                 break;
+00037                 case CHECKPOINT_CHAR: checkpoints.push_back(Checkpoint(x,y));
+00038                 break;
+00039                 case ROCK_CHAR: rocks.push_back(Rock(x,y));
+00040                 break;
+00041                 case WALL_CHAR: walls.push_back (make_pair(x,y));
+00042                 break;
+00043             }
+00044             if (maxX < x) maxX = x;
+00045             if (maxY < y) maxY = y;
+00046         }
+00047 
+00048         ++y;
+00049     }
+00050 
+00051     maze.generateMaze (walls, maxX, maxY);
+00052 
+00053     file.close();
+00054 }
+
+
+ +
+ All Classes Files Functions Variables Typedefs Enumerations Enumerator
+ + +
+ +
+ + + + + + + -- cgit v1.2.3