GL - LevelParser half way implemented.
This commit is contained in:
parent
0f5517398d
commit
aaf3bf30f9
|
@ -1,2 +1,82 @@
|
|||
#include "LevelParser.h"
|
||||
|
||||
using namespace GameLogic;
|
||||
using namespace ::LevelLoader;
|
||||
|
||||
LevelParser::LevelParser()
|
||||
{
|
||||
}
|
||||
|
||||
LevelParser::~LevelParser()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
std::vector<ObjectTypeHeader> LevelParser::Parse(std::string filename)
|
||||
{
|
||||
//Read entire level file.
|
||||
|
||||
std::vector<ObjectTypeHeader> objects;
|
||||
|
||||
unsigned int counter = 0;
|
||||
unsigned int stringSize = 0;
|
||||
while(counter < stringSize)
|
||||
{
|
||||
//Get typeID
|
||||
int typeID = 0;
|
||||
|
||||
|
||||
switch(typeID)
|
||||
{
|
||||
case TypeID_LevelHeader:
|
||||
//Call function
|
||||
counter += LevelHeaderSize;
|
||||
break;
|
||||
|
||||
case TypeID_Object:
|
||||
//Call function
|
||||
counter += ObjectHeaderSize;
|
||||
break;
|
||||
default:
|
||||
//Couldn't find typeID. FAIL!!!!!!
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return objects;
|
||||
}
|
||||
|
||||
//
|
||||
ObjectTypeHeader LevelParser::ParseHeader(std::string filename)
|
||||
{
|
||||
//Read entire level file.
|
||||
|
||||
//Find the header in the returned string.
|
||||
unsigned int counter = 0;
|
||||
unsigned int stringSize = 0;
|
||||
|
||||
ObjectTypeHeader header;
|
||||
header.typeID = ObjectType_Level;
|
||||
|
||||
while(counter < stringSize)
|
||||
{
|
||||
int typeID = 0;
|
||||
switch(typeID)
|
||||
{
|
||||
case TypeID_LevelHeader:
|
||||
//Call function
|
||||
|
||||
break;
|
||||
case TypeID_Object:
|
||||
//Call function
|
||||
counter += ObjectHeaderSize;
|
||||
break;
|
||||
|
||||
default:
|
||||
//Couldn't find typeID. FAIL!!!!!!
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return header;
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef LEVEL_PARSER_H
|
||||
#define LEVEL_PARSER_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "ObjectDefines.h"
|
||||
|
||||
|
@ -15,12 +16,34 @@ namespace GameLogic
|
|||
~LevelParser();
|
||||
|
||||
//
|
||||
std::vector<ObjectTypeHeader> Parse();
|
||||
std::vector<ObjectTypeHeader> Parse(std::string filename);
|
||||
|
||||
//
|
||||
ObjectTypeHeader ParseHeader();
|
||||
ObjectTypeHeader ParseHeader(std::string filename);
|
||||
|
||||
private:
|
||||
static const int TypeHeaderSize = 4; //Including the TypeID
|
||||
static const int ObjectHeaderSize = 10; //Including modelID, textureID, position, rotation, scale.
|
||||
static const int LevelHeaderSize = 10; //Including Format version, Name, Map version etc.
|
||||
|
||||
static const int FormatVersionMajor = 1;
|
||||
static const int FormatVersionMinor = 0;
|
||||
|
||||
/*************************************
|
||||
Question
|
||||
*************************************/
|
||||
//Could we use the IDs in "ObjectDefines.h" or do we have to use our own???
|
||||
enum TypeID
|
||||
{
|
||||
TypeID_LevelHeader,
|
||||
TypeID_Player,
|
||||
TypeID_Object,
|
||||
|
||||
|
||||
TypeID_NUM_OF_TYPES,
|
||||
|
||||
ObjectType_Unknown = -1,
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -5,13 +5,14 @@ namespace GameLogic
|
|||
{
|
||||
enum ObjectType
|
||||
{
|
||||
ObjectType_Level,
|
||||
ObjectType_Static,
|
||||
ObjectType_Dynamic,
|
||||
|
||||
|
||||
ObjectType_NUM_OF_TYPES,
|
||||
|
||||
ObjectType_Unknow = -1,
|
||||
ObjectType_Unknown = -1,
|
||||
};
|
||||
|
||||
struct ObjectTypeHeader
|
||||
|
|
Loading…
Reference in New Issue