aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2019-02-25 19:03:28 -0500
committerClyne Sullivan <tullivan99@gmail.com>2019-02-25 19:03:28 -0500
commit8fad6784c4316e1fe41290ae80e6a8c535de4fa1 (patch)
tree7f9c6da7bf71ce37498e097c83d4b654f407f54c
parentd7bae41fab5570bdac547a46463974adb4723f96 (diff)
goodbye indoorworld
-rw-r--r--assets/bobground.pngbin0 -> 925 bytes
-rw-r--r--include/world.hpp40
-rw-r--r--src/world.cpp67
-rw-r--r--xml/!town.xml2
-rw-r--r--xml/bobshouse.xml10
5 files changed, 25 insertions, 94 deletions
diff --git a/assets/bobground.png b/assets/bobground.png
new file mode 100644
index 0000000..971a69b
--- /dev/null
+++ b/assets/bobground.png
Binary files differ
diff --git a/include/world.hpp b/include/world.hpp
index d53a40b..12e694c 100644
--- a/include/world.hpp
+++ b/include/world.hpp
@@ -21,18 +21,6 @@ using namespace tinyxml2;
#include <vector2.hpp>
/**
- * The line structure.
- * This structure is used to store the world's ground, stored in vertical
- * lines. Dirt color and grass properties are also kept track of here.
- */
-struct WorldData {
- bool grassUnpressed; /**< squishes grass if false */
- float grassHeight[2]; /**< height of the two grass blades */
- float groundHeight; /**< height of the 'line' */
- unsigned char groundColor; /**< a value that affects the ground's color */
-};
-
-/**
* Defines how many game ticks it takes to go from day to night or vice versa.
* Technically a half day cycle...
*/
@@ -46,40 +34,18 @@ constexpr const unsigned int DAY_CYCLE = 10000;
constexpr const float GRAVITY_CONSTANT = 0.001f;
/**
- * Defines the thickness of the floor in an indoor world.
- */
-constexpr const unsigned int INDOOR_FLOOR_THICKNESS = 50;
-
-/**
- * Defines how far each floor can be from the next (height).
- */
-constexpr const unsigned int INDOOR_FLOOR_HEIGHTT = 400;
-
-/**
- * Gets a combined height of the floor and the area before it.
- * This value is commonly used for operations like moving between floors.
- */
-constexpr const unsigned int INDOOR_FLOOR_HEIGHT = (INDOOR_FLOOR_HEIGHTT + INDOOR_FLOOR_THICKNESS);
-
-/**
* World data.
* Contains all necessary data for a world. An instance of this is kept in the
* world system, and is populated through it's load() function.
*/
-struct WorldData2 {
-
+struct WorldData {
// Data variables
ObjectTexture ground;
float startX; /**< The furthest left coordinate of the world. */
- // Indoor variables
- bool indoor; /**< Set to true if this is an indoor world. */
- Texture indoorTex; /**< The house's inside texture. */
- std::string outdoor; /**< The file name of the outdoor world. */
- vec2 outdoorCoords; /**< The coordinates the player should spawn to when exiting. */
-
// World linkage
std::string toLeft, toRight; /**< File names of the worlds adjacent to this one. */
+ std::string outdoor; /**< The file name of the outdoor world. */
// Style variables
std::string styleFolder; /**< The folder to get stylized textures from. */
@@ -98,7 +64,7 @@ private:
/**
* The world's data.
*/
- static WorldData2 world;
+ static WorldData world;
/**
* SDL's object for handling the background music.
diff --git a/src/world.cpp b/src/world.cpp
index a608384..bb614d3 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -29,7 +29,7 @@ using namespace tinyxml2;
#include <weather.hpp>
#include <systems/lua.hpp>
-WorldData2 WorldSystem::world;
+WorldData WorldSystem::world;
Mix_Music* WorldSystem::bgmObj;
std::string WorldSystem::bgmCurrent;
TextureIterator WorldSystem::bgTex;
@@ -83,9 +83,6 @@ float WorldSystem::isAboveGround(const vec2& p)
bool WorldSystem::save(void)
{
- if (world.indoor)
- return false;
-
std::ofstream save (game::config::xmlFolder + currentXMLFile + ".dat");
// signature?
@@ -190,19 +187,11 @@ void WorldSystem::loader(void)
auto wxml = xmlDoc.FirstChildElement("World");
if (wxml != nullptr) {
wxml = wxml->FirstChildElement();
- world.indoor = false;
} else {
- wxml = xmlDoc.FirstChildElement("IndoorWorld");
- UserAssert(wxml != nullptr, "XML Error: Cannot find a <World> or <IndoorWorld> tag in " + xmlPath);
- wxml = wxml->FirstChildElement();
- world.indoor = true;
- if (world.outdoor.empty()) {
- world.outdoor = currentXMLFile;
- world.outdoorCoords = vec2(0, 100);
- }
+ UserAssert(0, "XML Error: Cannot find a <World> or <IndoorWorld> tag in " + xmlPath);
}
- world.toLeft = world.toRight = "";
+ world.toLeft = world.toRight = world.outdoor = "";
currentXMLFile = toLoad;
//game::entities.reset();
@@ -239,20 +228,8 @@ void WorldSystem::loader(void)
}
// world generation
- else if (tagName == "generation") {
- generate(wxml->GetText());
- }
-
- // indoor stuff
- else if (tagName == "house") {
- if (!world.indoor)
- UserError("<house> can only be used inside <IndoorWorld>");
-
- //world.indoorWidth = wxml->FloatAttribute("width");
- world.indoorTex = Texture(wxml->StrAttribute("texture")); // TODO winbloze lol
- auto str = wxml->StrAttribute("texture");
- auto tex = Texture(str);
- world.indoorTex = tex;
+ else if (tagName == "ground") {
+ generate(wxml->Attribute("path"));
}
// weather tag
@@ -262,16 +239,14 @@ void WorldSystem::loader(void)
// link tags
else if (tagName == "link") {
- auto linkTo = wxml->Attribute("left");
- if (linkTo != nullptr) {
+ if (auto linkTo = wxml->Attribute("left"); linkTo != nullptr)
world.toLeft = linkTo;
- } else {
- linkTo = wxml->Attribute("right");
- if (linkTo != nullptr)
- world.toRight = linkTo;
- else
- UserError("<link> doesn't handle left or right... huh");
- }
+ else if (auto linkTo = wxml->Attribute("right"); linkTo != nullptr)
+ world.toRight = linkTo;
+ else if (auto linkTo = wxml->Attribute("outside"); linkTo != nullptr)
+ world.outdoor = linkTo;
+ else
+ UserError("<link> tag with bad attribute");
}
// time setting
@@ -539,15 +514,8 @@ void WorldSystem::render(void)
delete[] bgItems;
}
- vec2 dim;
- if (world.indoor) {
- world.indoorTex.use();
- dim = world.indoorTex.getDim();
- } else {
- world.ground.use();
- dim = world.ground.getDim();
- }
-
+ world.ground.use();
+ auto dim = world.ground.getDim();
GLfloat verts[] = {
world.startX, 0, z, 0, 0,
world.startX + dim.x, 0, z, 1, 0,
@@ -698,18 +666,15 @@ void WorldSystem::goWorldPortal(Position& p)
{
std::string file;
- if (world.indoor) {
+ if (!world.outdoor.empty()) {
file = world.outdoor;
- p.x = world.outdoorCoords.x; // ineffective, player is regen'd
- p.y = world.outdoorCoords.y;
+ world.outdoor = "";
} else {
game::entities.each<Position, Solid, Portal>(
[&](entityx::Entity entity, Position& loc, Solid &dim, Portal &portal) {
(void)entity;
if (!(portal.toFile.empty()) && p.x > loc.x && p.x < loc.x + dim.width) {
file = portal.toFile;
- world.outdoor = currentXMLFile;
- world.outdoorCoords = vec2(loc.x + dim.width / 2, 100);
return;
}
});
diff --git a/xml/!town.xml b/xml/!town.xml
index 1b1d527..545fddf 100644
--- a/xml/!town.xml
+++ b/xml/!town.xml
@@ -12,7 +12,7 @@
<layer path="bg/dirt.png"/>
<layer path="bg/grass.png"/>
</style>
- <generation>assets/testground.png</generation>
+ <ground path="assets/testground.png"/>
<weather>Sunny</weather>
<link right="!town2.xml"/>
<spawnx>-300</spawnx>
diff --git a/xml/bobshouse.xml b/xml/bobshouse.xml
index 384af4f..a699b19 100644
--- a/xml/bobshouse.xml
+++ b/xml/bobshouse.xml
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<include file="entities.xml"/>
-<IndoorWorld>
+<World>
<style bgm="assets/music/theme_jazz.wav" folder="assets/style/indoors/">
<layer path="bg/bg.png"/>
<layer path="bg/bgFarMountain.png"/>
@@ -12,12 +12,12 @@
<layer path="bg/dirt.png"/>
<layer path="bg/carpet.png"/>
</style>
- <house width="800" texture="assets/style/classic/bg/insideWoodHouse.png"/>
- <generation>testground.png</generation>
+ <!--<house width="800" texture="assets/style/classic/bg/insideWoodHouse.png"/>-->
+ <ground path="assets/bobground.png"/>
<time>6000</time>
- <!--<link outside="town.xml"/>-->
+ <link outside="!town.xml"/>
<npc name="Bob" hasDialog="true" spawnx="30"/>
-</IndoorWorld>
+</World>
<Dialog name="Bob">
<text id="0" nextid="1">