GameLogic - implementation of LevelLoader
This commit is contained in:
parent
121fd51c45
commit
c84ed645f0
|
@ -1,61 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<diagram program="umlet" version="12.0">
|
||||
<zoom_level>8</zoom_level>
|
||||
<element>
|
||||
<type>com.umlet.element.Package</type>
|
||||
<coordinates>
|
||||
<x>552</x>
|
||||
<y>320</y>
|
||||
<w>584</w>
|
||||
<h>368</h>
|
||||
</coordinates>
|
||||
<panel_attributes>LevelLoader</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>440</x>
|
||||
<y>88</y>
|
||||
<w>128</w>
|
||||
<h>40</h>
|
||||
</coordinates>
|
||||
<panel_attributes>GameLogic
|
||||
<<Erik>></panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>768</x>
|
||||
<y>472</y>
|
||||
<w>136</w>
|
||||
<h>104</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<<<<-</panel_attributes>
|
||||
<additional_attributes>120;24;120;88;24;88</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>560</x>
|
||||
<y>544</y>
|
||||
<w>232</w>
|
||||
<h>136</h>
|
||||
</coordinates>
|
||||
<panel_attributes><<Interface>>
|
||||
Parser
|
||||
--
|
||||
Functions:
|
||||
vector<struct> Parse();
|
||||
-
|
||||
Privates:
|
||||
enum headerType;
|
||||
const int FileHeaderSize;
|
||||
const int FileVersion;
|
||||
</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
|
@ -71,85 +16,39 @@ const int FileVersion;
|
|||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>640</x>
|
||||
<x>840</x>
|
||||
<y>208</y>
|
||||
<w>40</w>
|
||||
<w>88</w>
|
||||
<h>168</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<<.</panel_attributes>
|
||||
<additional_attributes>24;24;24;152</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>384</x>
|
||||
<y>176</y>
|
||||
<w>256</w>
|
||||
<h>56</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->>>>
|
||||
m1=1..1
|
||||
m2=1..1
|
||||
<Knows about</panel_attributes>
|
||||
<additional_attributes>240;40;24;40</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Package</type>
|
||||
<coordinates>
|
||||
<x>248</x>
|
||||
<y>320</y>
|
||||
<w>248</w>
|
||||
<h>160</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Defines</panel_attributes>
|
||||
<additional_attributes/>
|
||||
<panel_attributes>lt=.
|
||||
<Uses</panel_attributes>
|
||||
<additional_attributes>24;24;24;64;72;64;72;152</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>800</x>
|
||||
<y>360</y>
|
||||
<w>208</w>
|
||||
<h>136</h>
|
||||
<x>928</x>
|
||||
<y>560</y>
|
||||
<w>200</w>
|
||||
<h>120</h>
|
||||
</coordinates>
|
||||
<panel_attributes><<Interface>>
|
||||
Loader
|
||||
<panel_attributes>Collection of functions
|
||||
<<lots of functions>>
|
||||
--
|
||||
Functions:
|
||||
wchar* LoadFile(string fileName);
|
||||
Model* LoadModel(string modelName);
|
||||
Model* LoadModel(int modelID);
|
||||
-
|
||||
Privates:</panel_attributes>
|
||||
functions for creating the right structs</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>328</x>
|
||||
<y>208</y>
|
||||
<w>80</w>
|
||||
<h>24</h>
|
||||
<x>440</x>
|
||||
<y>88</y>
|
||||
<w>128</w>
|
||||
<h>40</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Defines</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>256</x>
|
||||
<y>360</y>
|
||||
<w>232</w>
|
||||
<h>104</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Defines.h
|
||||
<<Header file>>
|
||||
--
|
||||
Enum ObjectType(static, dynamic, specials);
|
||||
.
|
||||
Struct static;
|
||||
Struct dynamic;
|
||||
Struct specials</panel_attributes>
|
||||
<panel_attributes>GameLogic
|
||||
<<Erik>></panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
|
@ -169,28 +68,32 @@ Uses></panel_attributes>
|
|||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>816</x>
|
||||
<y>192</y>
|
||||
<w>128</w>
|
||||
<h>40</h>
|
||||
<x>800</x>
|
||||
<y>360</y>
|
||||
<w>208</w>
|
||||
<h>136</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Resource Loader
|
||||
<<Dennis>><<Singleton></panel_attributes>
|
||||
<panel_attributes><<Interface>>
|
||||
Loader
|
||||
--
|
||||
Functions:
|
||||
wchar* LoadFile(string fileName);
|
||||
//Model* LoadHitBoxes(string modelName);
|
||||
//Model* LoadHitBoxes(int modelID);
|
||||
-
|
||||
Privates:</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>928</x>
|
||||
<y>560</y>
|
||||
<w>200</w>
|
||||
<h>120</h>
|
||||
<x>344</x>
|
||||
<y>208</y>
|
||||
<w>40</w>
|
||||
<h>168</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Collection of functions
|
||||
<<lots of functions>>
|
||||
--
|
||||
functions for creating the right structs</panel_attributes>
|
||||
<additional_attributes/>
|
||||
<panel_attributes>lt=<<.</panel_attributes>
|
||||
<additional_attributes>24;24;24;152</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
|
@ -206,6 +109,61 @@ m2=1..1
|
|||
Uses></panel_attributes>
|
||||
<additional_attributes>24;40;160;40</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>816</x>
|
||||
<y>192</y>
|
||||
<w>128</w>
|
||||
<h>40</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Resource Loader
|
||||
<<Dennis>><<Singleton></panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>768</x>
|
||||
<y>472</y>
|
||||
<w>136</w>
|
||||
<h>104</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<<<<-</panel_attributes>
|
||||
<additional_attributes>120;24;120;88;24;88</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>384</x>
|
||||
<y>176</y>
|
||||
<w>256</w>
|
||||
<h>56</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->>>>
|
||||
m1=1..1
|
||||
m2=1..1
|
||||
<Knows about</panel_attributes>
|
||||
<additional_attributes>240;40;24;40</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>256</x>
|
||||
<y>360</y>
|
||||
<w>232</w>
|
||||
<h>104</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Defines.h
|
||||
<<Header file>>
|
||||
--
|
||||
Enum ObjectType(static, dynamic, specials);
|
||||
.
|
||||
Struct static;
|
||||
Struct dynamic;
|
||||
Struct specials</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
|
@ -229,7 +187,7 @@ Privates:
|
|||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>344</x>
|
||||
<x>640</x>
|
||||
<y>208</y>
|
||||
<w>40</w>
|
||||
<h>168</h>
|
||||
|
@ -238,27 +196,26 @@ Privates:
|
|||
<additional_attributes>24;24;24;152</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>840</x>
|
||||
<x>328</x>
|
||||
<y>208</y>
|
||||
<w>88</w>
|
||||
<h>168</h>
|
||||
<w>80</w>
|
||||
<h>24</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=.
|
||||
<Uses</panel_attributes>
|
||||
<additional_attributes>24;24;24;64;72;64;72;152</additional_attributes>
|
||||
<panel_attributes>Defines</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<type>com.umlet.element.Package</type>
|
||||
<coordinates>
|
||||
<x>656</x>
|
||||
<y>472</y>
|
||||
<w>40</w>
|
||||
<h>88</h>
|
||||
<x>248</x>
|
||||
<y>320</y>
|
||||
<w>248</w>
|
||||
<h>160</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<<<<-</panel_attributes>
|
||||
<additional_attributes>24;72;24;24</additional_attributes>
|
||||
<panel_attributes>Defines</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
|
@ -274,4 +231,47 @@ m2=1..1
|
|||
Uses></panel_attributes>
|
||||
<additional_attributes>24;40;80;40;120;40;120;144</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>656</x>
|
||||
<y>472</y>
|
||||
<w>40</w>
|
||||
<h>88</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<<<<-</panel_attributes>
|
||||
<additional_attributes>24;72;24;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>560</x>
|
||||
<y>544</y>
|
||||
<w>232</w>
|
||||
<h>136</h>
|
||||
</coordinates>
|
||||
<panel_attributes><<Interface>>
|
||||
Parser
|
||||
--
|
||||
Functions:
|
||||
vector<struct> Parse();
|
||||
-
|
||||
Privates:
|
||||
enum headerType;
|
||||
const int FileHeaderSize;
|
||||
const int FileVersion;
|
||||
</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Package</type>
|
||||
<coordinates>
|
||||
<x>552</x>
|
||||
<y>320</y>
|
||||
<w>584</w>
|
||||
<h>368</h>
|
||||
</coordinates>
|
||||
<panel_attributes>LevelLoader</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
</diagram>
|
||||
|
|
|
@ -184,6 +184,8 @@
|
|||
<ClInclude Include="GameMode.h" />
|
||||
<ClInclude Include="IAttatchment.h" />
|
||||
<ClInclude Include="Level.h" />
|
||||
<ClInclude Include="LevelLoader.h" />
|
||||
<ClInclude Include="Loader.h" />
|
||||
<ClInclude Include="Object.h" />
|
||||
<ClInclude Include="Player.h" />
|
||||
<ClInclude Include="StaticObject.h" />
|
||||
|
@ -202,6 +204,8 @@
|
|||
<ClCompile Include="Game_PlayerData.cpp" />
|
||||
<ClCompile Include="IAttatchment.cpp" />
|
||||
<ClCompile Include="Level.cpp" />
|
||||
<ClCompile Include="LevelLoader.cpp" />
|
||||
<ClCompile Include="Loader.cpp" />
|
||||
<ClCompile Include="Object.cpp" />
|
||||
<ClCompile Include="Player.cpp" />
|
||||
<ClCompile Include="StaticObject.cpp" />
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
//////////////////////////////////
|
||||
// Created by Sam Svensson 2013 //
|
||||
//////////////////////////////////
|
||||
|
||||
#include "LevelLoader.h"
|
||||
using namespace GameLogic;
|
||||
using namespace GameLogic::LevelLoader;
|
||||
|
||||
std::vector<ObjectTypeHeader> LevelLoader::LoadLevel(std::string fileName)
|
||||
{
|
||||
Parser->parse(fileName);
|
||||
}
|
||||
|
||||
std::vector<ObjectTypeHeader> LevelLoader::LoadLevelHeader(std::string fileName)
|
||||
{
|
||||
parser->parseHeader(fileName);
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
//////////////////////////////////
|
||||
// Created by Sam Svensson 2013 //
|
||||
//////////////////////////////////
|
||||
|
||||
#ifndef LEVELLOADER_H
|
||||
#define LEVELLOADER_H
|
||||
|
||||
#include <vector>
|
||||
#include <Vector.h>
|
||||
#include "ObjectDefines.h"
|
||||
#include "LevelParser.h"
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
class LevelLoader
|
||||
{
|
||||
|
||||
public:
|
||||
LevelLoader(){this->parser = new Parser()};
|
||||
~LevelLoader(){};
|
||||
std::vector<ObjectTypeHeader> LoadLevel(std::string fileName); //loads the level and objects from file
|
||||
std::vector<ObjectTypeHeader> LoadLevelHeader(std::string fileName); //just for fast access for the meta information about the level.
|
||||
|
||||
private:
|
||||
LevelParser parser;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,18 @@
|
|||
//////////////////////////////////
|
||||
// Created by Sam Svensson 2013 //
|
||||
//////////////////////////////////
|
||||
|
||||
#include "Loader.h"
|
||||
|
||||
using namespace GameLogic::LevelLoader;
|
||||
using namespace Oyster::Resource;
|
||||
using namespace std;
|
||||
|
||||
char* Loader::LoadFile(std::string fileName)
|
||||
{
|
||||
//convert from string to wstring
|
||||
std::wstring temp(fileName.begin(), fileName.end());
|
||||
|
||||
//convert from wstring to wchar then loads the file
|
||||
return OysterResource::LoadResource(temp.c_str(), Oyster::Resource::ResourceType::ResourceType_Byte_Raw, -1 , false);
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
//////////////////////////////////
|
||||
// Created by Sam Svensson 2013 //
|
||||
//////////////////////////////////
|
||||
|
||||
#ifndef LOADER_H
|
||||
#define LOADER_H
|
||||
|
||||
#include "Resource\OysterResource.h"
|
||||
#include <string>
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
namespace LevelLoader
|
||||
{
|
||||
class Loader
|
||||
{
|
||||
public:
|
||||
Loader(){};
|
||||
~Loader(){};
|
||||
char* LoadFile(std::string fileName);
|
||||
|
||||
//TODO:
|
||||
//Add functionality to load physicsObjects (hitboxes)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif;
|
Loading…
Reference in New Issue