aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/entities.cpp8
-rw-r--r--src/texture.cpp7
-rw-r--r--src/world.cpp57
3 files changed, 40 insertions, 32 deletions
diff --git a/src/entities.cpp b/src/entities.cpp
index 60f49ee..e156ee2 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -320,6 +320,8 @@ Structures::~Structures()
{
}
+extern std::string currentXMLRaw;
+
void Structures::createFromXML(XMLElement *e, World *w)
{
float spawnx;
@@ -331,6 +333,12 @@ void Structures::createFromXML(XMLElement *e, World *w)
inWorld = w;
inside = e->StrAttribute("inside");
+
+ // edge
+ if (!inside.empty()) {
+ insideWorld = loadWorldFromXMLNoTakeover(inside);
+ }
+
textureLoc = e->StrAttribute("texture");
spawn(static_cast<BUILD_SUB>(e->UnsignedAttribute("type")),
diff --git a/src/texture.cpp b/src/texture.cpp
index 0f01c83..bdac28e 100644
--- a/src/texture.cpp
+++ b/src/texture.cpp
@@ -46,7 +46,7 @@ namespace Texture{
GLuint loadTexture(std::string fileName) {
SDL_Surface *image;
- GLuint object = 0;
+ static GLuint object = 0;
// check if texture is already loaded
for(auto &t : LoadedTexture) {
@@ -71,9 +71,8 @@ namespace Texture{
/*
* Load texture through OpenGL.
*/
-
- glGenTextures(1,&object); // Turns "object" into a texture
- glBindTexture(GL_TEXTURE_2D,object); // Binds "object" to the top of the stack
+ //glGenTextures(1,&object); // Turns "object" into a texture
+ glBindTexture(GL_TEXTURE_2D,++object); // Binds "object" to the top of the stack
glPixelStoref(GL_UNPACK_ALIGNMENT,1);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); // Sets the "min" filter
diff --git a/src/world.cpp b/src/world.cpp
index 08c788b..8969fb9 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -125,7 +125,7 @@ static const float bgDraw[4][3]={
{ 255, 255, 0.1 }
};
-static std::string currentXMLRaw;
+std::string currentXMLRaw;
XMLDocument currentXMLDoc;
/* ----------------------------------------------------------------------------
@@ -654,35 +654,22 @@ void World::draw(Player *p)
// actually draw the grass.
if (wd.groundHeight) {
- //glBegin(GL_QUADS);
- /*glTexCoord2i(0, 0); glVertex2i(worldStart + i * HLINE , wd.groundHeight + gh[0]);
- glTexCoord2i(1, 0); glVertex2i(worldStart + i * HLINE + HLINE / 2, wd.groundHeight + gh[0]);
- glTexCoord2i(1, 1); glVertex2i(worldStart + i * HLINE + HLINE / 2, wd.groundHeight - GRASS_HEIGHT);
- glTexCoord2i(0, 1); glVertex2i(worldStart + i * HLINE , wd.groundHeight - GRASS_HEIGHT);
+ c.push_back(std::make_pair(vec2(0, 0),vec3(worldStart + HLINES(i) , wd.groundHeight + gh[0], -3)));
+ c.push_back(std::make_pair(vec2(1, 0),vec3(worldStart + HLINES(i) + HLINE / 2, wd.groundHeight + gh[0], -3)));
+ c.push_back(std::make_pair(vec2(1, 1),vec3(worldStart + HLINES(i) + HLINE / 2, wd.groundHeight - GRASS_HEIGHT, -3)));
- glTexCoord2i(0, 0); glVertex2i(worldStart + i * HLINE + HLINE / 2, wd.groundHeight + gh[1]);
- glTexCoord2i(1, 0); glVertex2i(worldStart + i * HLINE + HLINE , wd.groundHeight + gh[1]);
- glTexCoord2i(1, 1); glVertex2i(worldStart + i * HLINE + HLINE , wd.groundHeight - GRASS_HEIGHT);
- glTexCoord2i(0, 1); glVertex2i(worldStart + i * HLINE + HLINE / 2, wd.groundHeight - GRASS_HEIGHT);*/
+ c.push_back(std::make_pair(vec2(1, 1),vec3(worldStart + HLINES(i) + HLINE / 2, wd.groundHeight - GRASS_HEIGHT, -3)));
+ c.push_back(std::make_pair(vec2(0, 1),vec3(worldStart + HLINES(i) , wd.groundHeight - GRASS_HEIGHT, -3)));
+ c.push_back(std::make_pair(vec2(0, 0),vec3(worldStart + HLINES(i) , wd.groundHeight + gh[0], -3)));
- c.push_back(std::make_pair(vec2(0, 0),vec3(worldStart + HLINES(i) , wd.groundHeight + gh[0], -3)));
- c.push_back(std::make_pair(vec2(1, 0),vec3(worldStart + HLINES(i) + HLINE / 2, wd.groundHeight + gh[0], -3)));
- c.push_back(std::make_pair(vec2(1, 1),vec3(worldStart + HLINES(i) + HLINE / 2, wd.groundHeight - GRASS_HEIGHT, -3)));
- c.push_back(std::make_pair(vec2(1, 1),vec3(worldStart + HLINES(i) + HLINE / 2, wd.groundHeight - GRASS_HEIGHT, -3)));
- c.push_back(std::make_pair(vec2(0, 1),vec3(worldStart + HLINES(i) , wd.groundHeight - GRASS_HEIGHT, -3)));
- c.push_back(std::make_pair(vec2(0, 0),vec3(worldStart + HLINES(i) , wd.groundHeight + gh[0], -3)));
+ c.push_back(std::make_pair(vec2(0, 0),vec3(worldStart + HLINES(i) + HLINE / 2, wd.groundHeight + gh[1], -3)));
+ c.push_back(std::make_pair(vec2(1, 0),vec3(worldStart + HLINES(i) + HLINE , wd.groundHeight + gh[1], -3)));
+ c.push_back(std::make_pair(vec2(1, 1),vec3(worldStart + HLINES(i) + HLINE , wd.groundHeight - GRASS_HEIGHT, -3)));
-
- c.push_back(std::make_pair(vec2(0, 0),vec3(worldStart + HLINES(i) + HLINE / 2, wd.groundHeight + gh[1], -3)));
- c.push_back(std::make_pair(vec2(1, 0),vec3(worldStart + HLINES(i) + HLINE , wd.groundHeight + gh[1], -3)));
- c.push_back(std::make_pair(vec2(1, 1),vec3(worldStart + HLINES(i) + HLINE , wd.groundHeight - GRASS_HEIGHT, -3)));
-
- c.push_back(std::make_pair(vec2(1, 1),vec3(worldStart + HLINES(i) + HLINE , wd.groundHeight - GRASS_HEIGHT, -3)));
- c.push_back(std::make_pair(vec2(0, 1),vec3(worldStart + HLINES(i) + HLINE / 2, wd.groundHeight - GRASS_HEIGHT, -3)));
- c.push_back(std::make_pair(vec2(0, 0),vec3(worldStart + HLINES(i) + HLINE / 2, wd.groundHeight + gh[1], -3)));
-
- //glEnd();
+ c.push_back(std::make_pair(vec2(1, 1),vec3(worldStart + HLINES(i) + HLINE , wd.groundHeight - GRASS_HEIGHT, -3)));
+ c.push_back(std::make_pair(vec2(0, 1),vec3(worldStart + HLINES(i) + HLINE / 2, wd.groundHeight - GRASS_HEIGHT, -3)));
+ c.push_back(std::make_pair(vec2(0, 0),vec3(worldStart + HLINES(i) + HLINE / 2, wd.groundHeight + gh[1], -3)));
}
}
@@ -1803,10 +1790,19 @@ World *loadWorldFromPtr(World *ptr)
*/
World *
+loadWorldFromXMLNoTakeover(std::string path)
+{
+ loadedLeft = true, loadedRight = true;
+ auto ret = loadWorldFromXMLNoSave(path);
+ loadedLeft = false, loadedRight = false;
+ return ret;
+}
+
+World *
loadWorldFromXMLNoSave(std::string path) {
XMLDocument *_currentXMLDoc;
- std::string _currentXML,
- _currentXMLRaw;
+ static std::string _currentXML,
+ _currentXMLRaw;
XMLElement *wxml;
XMLElement *vil;
@@ -2000,7 +1996,12 @@ loadWorldFromXMLNoSave(std::string path) {
break;
}
+ std::swap(currentXML, _currentXML);
+ std::swap(currentXMLRaw, _currentXMLRaw);
newEntity->createFromXML(wxml, tmp);
+ std::swap(currentXML, _currentXML);
+ std::swap(currentXMLRaw, _currentXMLRaw);
+ std::cout << currentXML << '\n';
//}
}