GameLogic - implementation of LevelLoader

This commit is contained in:
Sam Mario Svensson 2014-01-24 10:22:18 +01:00
parent 121fd51c45
commit c84ed645f0
6 changed files with 246 additions and 150 deletions

View File

@ -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
&lt;&lt;Erik&gt;&gt;</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=&lt;&lt;&lt;&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>&lt;&lt;Interface&gt;&gt;
Parser
--
Functions:
vector&lt;struct&gt; 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=&lt;&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=-&gt;&gt;&gt;&gt;
m1=1..1
m2=1..1
&lt;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=.
&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>&lt;&lt;Interface&gt;&gt;
Loader
<panel_attributes>Collection of functions
&lt;&lt;lots of functions&gt;&gt;
--
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
&lt;&lt;Header file&gt;&gt;
--
Enum ObjectType(static, dynamic, specials);
.
Struct static;
Struct dynamic;
Struct specials</panel_attributes>
<panel_attributes>GameLogic
&lt;&lt;Erik&gt;&gt;</panel_attributes>
<additional_attributes/>
</element>
<element>
@ -169,28 +68,32 @@ Uses&gt;</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
&lt;&lt;Dennis&gt;&gt;&lt;&lt;Singleton&gt;</panel_attributes>
<panel_attributes>&lt;&lt;Interface&gt;&gt;
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
&lt;&lt;lots of functions&gt;&gt;
--
functions for creating the right structs</panel_attributes>
<additional_attributes/>
<panel_attributes>lt=&lt;&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&gt;</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
&lt;&lt;Dennis&gt;&gt;&lt;&lt;Singleton&gt;</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=&lt;&lt;&lt;&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=-&gt;&gt;&gt;&gt;
m1=1..1
m2=1..1
&lt;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
&lt;&lt;Header file&gt;&gt;
--
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=.
&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=&lt;&lt;&lt;&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&gt;</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=&lt;&lt;&lt;&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>&lt;&lt;Interface&gt;&gt;
Parser
--
Functions:
vector&lt;struct&gt; 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>

View File

@ -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" />

View File

@ -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);
}

View File

@ -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

View File

@ -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);
}

View File

@ -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;