aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--assets/style/classic/bg/bgWoodTile.pngbin205428 -> 1050873 bytes
-rw-r--r--assets/style/classic/bg/insideWoodHouse.pngbin0 -> 23738 bytes
-rw-r--r--include/common.hpp2
-rw-r--r--include/entities.hpp2
-rw-r--r--include/world.hpp6
-rw-r--r--src/entities.cpp6
-rw-r--r--src/world.cpp115
-rw-r--r--xcf/insideWoodHouse.xcfbin0 -> 42953 bytes
-rw-r--r--xml/!town.xml8
-rw-r--r--xml/bobshouse.xml5
11 files changed, 88 insertions, 59 deletions
diff --git a/.gitignore b/.gitignore
index a0d0007..4398992 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,6 @@ main
doc/**
storyXML/*.dat
xml/*.dat
+brice.dat
+config/settings.xml
+setup.mk
diff --git a/assets/style/classic/bg/bgWoodTile.png b/assets/style/classic/bg/bgWoodTile.png
index 95b0667..e10dd1f 100644
--- a/assets/style/classic/bg/bgWoodTile.png
+++ b/assets/style/classic/bg/bgWoodTile.png
Binary files differ
diff --git a/assets/style/classic/bg/insideWoodHouse.png b/assets/style/classic/bg/insideWoodHouse.png
new file mode 100644
index 0000000..47d3918
--- /dev/null
+++ b/assets/style/classic/bg/insideWoodHouse.png
Binary files differ
diff --git a/include/common.hpp b/include/common.hpp
index e7ed8e1..0364b8b 100644
--- a/include/common.hpp
+++ b/include/common.hpp
@@ -56,6 +56,8 @@ typedef unsigned int uint;
*/
#define DEBUG_printf(message, ...) DEBUG_prints(__FILE__, __LINE__, message, __VA_ARGS__)
+#define BREAKPOINT __asm__("int $3")
+
/**
* Creates a coordinate of integers.
*/
diff --git a/include/entities.hpp b/include/entities.hpp
index 95cbff7..e460a27 100644
--- a/include/entities.hpp
+++ b/include/entities.hpp
@@ -343,6 +343,8 @@ public:
std::string inside;
std::string textureLoc;
+ GLuint insideTex;
+
Structures();
~Structures();
diff --git a/include/world.hpp b/include/world.hpp
index 4b25e85..dc07267 100644
--- a/include/world.hpp
+++ b/include/world.hpp
@@ -17,8 +17,7 @@
* in World::setBackground() to select the appropriate images.
*/
enum class WorldBGType : unsigned int {
- Forest = 0, /**< A forest theme. */
- WoodHouse /**< An indoor wooden house theme. */
+ Forest = 0 /**< A forest theme. */
};
/**
@@ -198,6 +197,9 @@ private:
public:
+ float HouseWidth;
+ GLuint houseTex;
+
inline bool isIndoor(void) const
{ return m_Indoor; }
diff --git a/src/entities.cpp b/src/entities.cpp
index a03b4ff..25dd379 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -163,7 +163,7 @@ void PlayerSystem::receive(const KeyDownEvent &kde)
} else if (kc == getControl(4)) {
p->speed = .5;
} else if (kc == getControl(5)) {
- static int heyOhLetsGo = 0;
+ /*static int heyOhLetsGo = 0;
//edown = true;
@@ -179,7 +179,7 @@ void PlayerSystem::receive(const KeyDownEvent &kde)
// enable action ui
ui::action::enable();
- }
+ }*/
}
} else if (kc == SDLK_DELETE) {
game::endGame();
@@ -500,6 +500,8 @@ void Structures::createFromXML(XMLElement *e, World *w)
textureLoc = e->StrAttribute("texture");
+ insideTex = Texture::loadTexture(e->StrAttribute("insideTexture"));
+
spawn(static_cast<BUILD_SUB>(e->UnsignedAttribute("type")),
e->QueryFloatAttribute("spawnx", &spawnx) == XML_NO_ERROR ? spawnx : (randGet() % w->getTheWidth() / 2.0f),
100);
diff --git a/src/world.cpp b/src/world.cpp
index 1113270..ef9969f 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -77,25 +77,20 @@ std::string currentXML;
static std::vector<WorldSwitchInfo> arenaNest;
// pathnames of images for world themes
-constexpr const unsigned int BG_PATHS_ENTRY_SIZE = 9;
-static const std::string bgPaths[][BG_PATHS_ENTRY_SIZE] = {
- {"bg.png", // Daytime background
- "bgn.png", // Nighttime background
- "bgFarMountain.png", // Furthest layer
- "forestTileFar.png", // Furthest away Tree Layer
- "forestTileBack.png", // Closer layer
- "forestTileMid.png", // Near layer
- "forestTileFront.png", // Closest layer
- "dirt.png", // Dirt
- "grass.png"}, // Grass
- {"bgWoodTile.png",
- "bgWoodTile.png",
- "bgWoodTile.png",
- "bgWoodTile.png",
- "bgWoodTile.png",
- "bgWoodTile.png",
- "bgWoodTile.png",
- "bgWoodTile.png"}
+using StyleList = std::array<std::string, 9>;
+
+static const std::vector<StyleList> bgPaths = {
+ { // Forest
+ "bg.png", // daytime background
+ "bgn.png", // nighttime background
+ "bgFarMountain.png", // layer 1 (furthest)
+ "forestTileFar.png", // layer 2
+ "forestTileBack.png", // layer 3
+ "forestTileMid.png", // layer 4
+ "forestTileFront.png", // layer 5 (closest)
+ "dirt.png", // ground texture
+ "grass.png" // grass (ground-top) texture
+ }
};
// pathnames of structure textures
@@ -195,9 +190,9 @@ generate(int width)
auto wditer = std::begin(worldData) + GROUND_HILLINESS;
if (m_Indoor) {
- for(; wditer < std::end(worldData); wditer++) {
+ for(wditer = std::begin(worldData); wditer < std::end(worldData); wditer++) {
auto w = &*(wditer);
- w->groundHeight = 100;
+ w->groundHeight = GROUND_HEIGHT_MINIMUM + 5;
w->groundColor = 4;
}
} else {
@@ -623,6 +618,7 @@ WorldSwitchInfo World::goInsideStructure(Player *p)
delete[] buf;
tmp = dynamic_cast<Structures *>(*d)->insideWorld;
+ tmp->houseTex = dynamic_cast<Structures *>(*d)->insideTex;
return std::make_pair(tmp, vec2 {0, 100});
}
@@ -646,7 +642,7 @@ WorldSwitchInfo World::goInsideStructure(Player *p)
}
if (b == nullptr)*/
- return std::make_pair(this, vec2 {0, 0});
+ return std::make_pair(currentWorld, vec2 {0, 100});
//return std::make_pair(tmp, vec2 {b->loc.x + (b->width / 2), 0});
}
@@ -961,19 +957,14 @@ loadWorldFromXMLNoSave(std::string path) {
// world generation (for outdoor areas)
else if (name == "generation") {
- // random gen.
- if (!Indoor && wxml->StrAttribute("type") == "Random")
- tmp->generate(wxml->UnsignedAttribute("width") / game::HLINE);
- else {
- if (Indoor)
- UserError("XML Error: <generation> tags can't be in <IndoorWorld> tags, use <floor> instead (in " + _currentXML + ")!");
- else
- UserError("XML Error: Invalid <generation> tag in " + _currentXML + "!");
- }
+ tmp->generate(wxml->UnsignedAttribute("width") / game::HLINE);
}
- else if (name == "floor" && tmp->isIndoor()) {
- tmp->generate(wxml->UnsignedAttribute("width") / game::HLINE);
+ else if (name == "house") {
+ if (Indoor)
+ tmp->HouseWidth = wxml->FloatAttribute("width");
+ else
+ UserError("<house> can only be used with indoor worlds");
}
// weather tags
@@ -1423,30 +1414,45 @@ void WorldSystem::render(void)
// draw the remaining layers
for (unsigned int i = 0; i < 4; i++) {
bgTex++;
- dim2 dim = bgTex.getTextureDim();
+ auto dim = bgTex.getTextureDim();
auto xcoord = offset.x * bgDraw[i][2];
bg_items.clear();
bg_tex.clear();
- for (int j = worldStart; j <= -worldStart; j += dim.x) {
- bg_items.emplace_back(j + xcoord, GROUND_HEIGHT_MINIMUM, 7-(i*.1));
- bg_items.emplace_back(j + dim.x + xcoord, GROUND_HEIGHT_MINIMUM, 7-(i*.1));
- bg_items.emplace_back(j + dim.x + xcoord, GROUND_HEIGHT_MINIMUM + dim.y, 7-(i*.1));
-
- bg_items.emplace_back(j + dim.x + xcoord, GROUND_HEIGHT_MINIMUM + dim.y, 7-(i*.1));
- bg_items.emplace_back(j + xcoord, GROUND_HEIGHT_MINIMUM + dim.y, 7-(i*.1));
- bg_items.emplace_back(j + xcoord, GROUND_HEIGHT_MINIMUM, 7-(i*.1));
+ if (world->isIndoor() && i == 3) {
+ glBindTexture(GL_TEXTURE_2D, world->houseTex);
+
+ bg_items.emplace_back(worldStart, GROUND_HEIGHT_MINIMUM, 7-(i*.1));
+ bg_items.emplace_back(worldStart + world->HouseWidth, GROUND_HEIGHT_MINIMUM, 7-(i*.1));
+ bg_items.emplace_back(worldStart + world->HouseWidth, GROUND_HEIGHT_MINIMUM + dim.y, 7-(i*.1));
+
+ bg_items.emplace_back(worldStart + world->HouseWidth, GROUND_HEIGHT_MINIMUM + dim.y, 7-(i*.1));
+ bg_items.emplace_back(worldStart, GROUND_HEIGHT_MINIMUM + dim.y, 7-(i*.1));
+ bg_items.emplace_back(worldStart, GROUND_HEIGHT_MINIMUM, 7-(i*.1));
+ } else {
+ for (int j = worldStart; j <= -worldStart; j += dim.x) {
+ bg_items.emplace_back(j + xcoord, GROUND_HEIGHT_MINIMUM, 7-(i*.1));
+ bg_items.emplace_back(j + dim.x + xcoord, GROUND_HEIGHT_MINIMUM, 7-(i*.1));
+ bg_items.emplace_back(j + dim.x + xcoord, GROUND_HEIGHT_MINIMUM + dim.y, 7-(i*.1));
+
+ bg_items.emplace_back(j + dim.x + xcoord, GROUND_HEIGHT_MINIMUM + dim.y, 7-(i*.1));
+ bg_items.emplace_back(j + xcoord, GROUND_HEIGHT_MINIMUM + dim.y, 7-(i*.1));
+ bg_items.emplace_back(j + xcoord, GROUND_HEIGHT_MINIMUM, 7-(i*.1));
+ }
}
- for (uint i = 0; i < bg_items.size()/6; i++) {
- for (auto &v : bg_tex_coord)
- bg_tex.push_back(v);
- }
+ for (uint i = 0; i < bg_items.size()/6; i++) {
+ for (auto &v : bg_tex_coord)
+ bg_tex.push_back(v);
+ }
Render::worldShader.use();
glUniform1f(Render::worldShader.uniform[WU_light_impact], 0.075f + (0.2f*i));
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+
makeWorldDrawingSimplerEvenThoughAndyDoesntThinkWeCanMakeItIntoFunctions_JustDrawThis(0, bg_items.data(), &bg_tex[0], bg_items.size());
Render::worldShader.unuse();
@@ -1572,6 +1578,14 @@ void WorldSystem::render(void)
Render::worldShader.disable();
Render::worldShader.unuse();
+ } else {
+ Render::useShader(&Render::worldShader);
+ Render::worldShader.use();
+ static const GLuint rug = Texture::genColor(Color {255, 0, 0});
+ glBindTexture(GL_TEXTURE_2D, rug);
+ vec2 ll = vec2 {worldStart, GROUND_HEIGHT_MINIMUM};
+ Render::drawRect(ll, vec2 {ll.x + world->HouseWidth, ll.y + 4}, -3);
+ Render::worldShader.unuse();
}
player->draw();
@@ -1582,8 +1596,11 @@ void WorldSystem::setWorld(World *w)
world = w;
bgFiles.clear();
- for (const auto &s : bgPaths[(int)w->bgType])
- bgFiles.push_back(w->styleFolder + s);
+
+ const auto& files = bgPaths[(int)w->bgType];
+
+ for (const auto& f : files)
+ bgFiles.push_back(w->styleFolder + f);
bgTex = TextureIterator(bgFiles);
}
@@ -1625,7 +1642,7 @@ void WorldSystem::enterWorld(World *w)
void WorldSystem::leaveWorld(void)
{
- world = outside;
+ world = currentWorld = outside;
}
void WorldSystem::singleDetect(Entity *e, entityx::TimeDelta dt)
diff --git a/xcf/insideWoodHouse.xcf b/xcf/insideWoodHouse.xcf
new file mode 100644
index 0000000..f08dff8
--- /dev/null
+++ b/xcf/insideWoodHouse.xcf
Binary files differ
diff --git a/xml/!town.xml b/xml/!town.xml
index bd0264e..e663e15 100644
--- a/xml/!town.xml
+++ b/xml/!town.xml
@@ -1,13 +1,13 @@
<?xml version="1.0"?>
<World>
<style background="0" bgm="assets/music/embark.wav" folder="assets/style/classic/"/>
- <generation type="Random" width="1600"/>
+ <generation width="1600"/>
<time>6000</time>
<spawnx>-300</spawnx>
- <npc name="Sanc" hasDialog="true" health="1" x="-208.37956" y="65.399033" dindex="9999"/>
- <npc name="Bob" hasDialog="true" spawnx="30" health="1" x="283.33429" y="67.798996" dindex="0"/>
+ <npc name="Sanc" hasDialog="true" health="1" x="-324.26083" y="64.398972" dindex="9999"/>
+ <npc name="Bob" hasDialog="true" spawnx="30" health="1" x="94.415268" y="62.398994" dindex="0"/>
<structure type="1" spawnx="300" alive="1"/>
- <structure inside="bobshouse.xml" type="1" spawnx="10" alive="1"/>
+ <structure inside="bobshouse.xml" insideTexture="assets/style/classic/bg/insideWoodHouse.png" type="1" spawnx="10" alive="1"/>
<chest alive="1"/>
</World>
diff --git a/xml/bobshouse.xml b/xml/bobshouse.xml
index 87ad9b6..f13d5ff 100644
--- a/xml/bobshouse.xml
+++ b/xml/bobshouse.xml
@@ -1,7 +1,8 @@
<?xml version="1.0"?>
<IndoorWorld>
- <style background="1" bgm="assets/music/theme_jazz.wav" folder="assets/style/classic/"/>
- <floor width="1600"/>
+ <style background="0" bgm="assets/music/theme_jazz.wav" folder="assets/style/classic/"/>
+ <house width="800" />
+ <generation width="1600" />
<link outside="town.xml"/>
<npc name="Bob" hasDialog="false" spawnx="30"/>
</IndoorWorld>