aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/entities.cpp43
-rw-r--r--src/ui.cpp20
-rw-r--r--src/world.cpp85
3 files changed, 95 insertions, 53 deletions
diff --git a/src/entities.cpp b/src/entities.cpp
index 5084fd6..dc1a45a 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -79,6 +79,7 @@ Entity::Entity(void)
height = 0;
health = 0;
maxHealth = 0;
+ outnabout = 0;
z = 1.0f;
targetx = 0.9112001f;
@@ -374,18 +375,19 @@ void Entity::draw(void)
case PLAYERT:
static int texState = 0;
if (speed && !(game::time::getTickCount() % ((2.0f/speed) < 1 ? 1 : (int)((float)2.0f/(float)speed)))) {
- if (++texState==9)texState=1;
+ if (++texState == 9)
+ texState = 1;
glActiveTexture(GL_TEXTURE0);
tex(texState);
}
if (!ground) {
- glActiveTexture(GL_TEXTURE0 + 0);
+ glActiveTexture(GL_TEXTURE0);
tex(0);
- }else if (vel.x) {
- glActiveTexture(GL_TEXTURE0 + 0);
+ } else if (vel.x) {
+ glActiveTexture(GL_TEXTURE0);
tex(texState);
- }else{
- glActiveTexture(GL_TEXTURE0 + 0);
+ } else {
+ glActiveTexture(GL_TEXTURE0);
tex(0);
}
break;
@@ -427,13 +429,13 @@ if (health != maxHealth) {
glUniform1i(worldShader_uniform_texture, 0);
GLfloat coord_back[] = {
- loc.x, loc.y + height, z,
- loc.x + width, loc.y + height, z,
- loc.x + width, loc.y + height + game::HLINE * 2,z,
+ loc.x, loc.y + height, z,
+ loc.x + width, loc.y + height, z,
+ loc.x + width, loc.y + height + game::HLINE * 2, z,
- loc.x + width, loc.y + height + game::HLINE * 2,z,
- loc.x, loc.y + height + game::HLINE * 2,z,
- loc.x, loc.y + height, z,
+ loc.x + width, loc.y + height + game::HLINE * 2, z,
+ loc.x, loc.y + height + game::HLINE * 2, z,
+ loc.x, loc.y + height, z,
};
GLfloat coord_front[] = {
@@ -550,7 +552,12 @@ void NPC::interact() { //have the npc's interact back to the player
if (dialogCount && dialogIndex != 9999) {
// load the XML file and find the dialog tags
- xml.LoadFile(currentXML.c_str());
+ if (outnabout == 0)
+ xml.LoadFile(currentXML.c_str());
+ else if (outnabout < 0)
+ xml.LoadFile((xmlFolder + currentWorld->getToLeft()).c_str());
+ else
+ xml.LoadFile((xmlFolder + currentWorld->getToRight()).c_str());
COMMONAIFUNC:
idx = 0;
stop = false;
@@ -608,6 +615,10 @@ COMMONAIFUNC:
if ((oxml = exml->FirstChildElement("gotox")))
moveTo(std::stoi(oxml->GetText()));
+ // asdlfkj
+ auto ptr = exml->GetText() - 1;
+ while (isspace(*++ptr));
+
// handle dialog options
if ((oxml = exml->FirstChildElement("option"))) {
std::string optstr;
@@ -620,9 +631,9 @@ COMMONAIFUNC:
// save the associated XMLElement
dopt.push_back(oxml);
} while ((oxml = oxml->NextSiblingElement()));
-
+
// run the dialog stuff
- ui::dialogBox(name, optstr, false, exml->GetText() + 2);
+ ui::dialogBox(name, optstr, false, ptr);
ui::waitForDialog();
if (ui::dialogOptChosen)
@@ -633,7 +644,7 @@ COMMONAIFUNC:
// optionless dialog
else {
- ui::dialogBox(name, "", false, exml->GetText());
+ ui::dialogBox(name, "", false, ptr);
ui::waitForDialog();
}
diff --git a/src/ui.cpp b/src/ui.cpp
index 64e18fe..51edb86 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -442,7 +442,7 @@ namespace ui {
std::string ret;
std::string typeOut(std::string str) {
- static unsigned int tadv = TICKS_PER_SEC / 12;
+ static unsigned int tadv = 1;
static unsigned int tickk,
linc=0, // Contains the number of letters that should be drawn.
size=0; // Contains the full size of the current string.
@@ -467,9 +467,21 @@ namespace ui {
tickk = tickCount + tadv;
ret += str[linc];
- if (linc < size)
- linc++;
- else
+ if (linc < size) {
+ switch (str[++linc]) {
+ case '!':
+ case '?':
+ case '.':
+ tadv = 10;
+ break;
+ case ',':
+ tadv = 5;
+ break;
+ default:
+ tadv = 1;
+ break;
+ }
+ } else
typeOutDone = true;
}
diff --git a/src/world.cpp b/src/world.cpp
index 88ef57a..327a787 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -1089,8 +1089,7 @@ void World::load(void){
* Toggle play/stop of the background music.
* If new music is to be played a crossfade will occur, otherwise... uhm.
*/
-void World::
-bgmPlay(World *prev) const
+void World::bgmPlay(World *prev) const
{
if (prev == nullptr || bgm != prev->bgm) {
Mix_FadeOutMusic(800);
@@ -1103,8 +1102,7 @@ bgmPlay(World *prev) const
* This will load a sound file to be played while the player is in this world.
* If no file is found, no music should play.
*/
-void World::
-setBGM(std::string path)
+void World::setBGM(std::string path)
{
if (!path.empty())
bgmObj = Mix_LoadMUS((bgm = path).c_str());
@@ -1115,8 +1113,7 @@ setBGM(std::string path)
* The images chosen for the background layers are selected depending on the
* world's background type.
*/
-void World::
-setBackground(WorldBGType bgt)
+void World::setBackground(WorldBGType bgt)
{
// load textures with a limit check
switch ((bgType = bgt)) {
@@ -1137,8 +1134,7 @@ setBackground(WorldBGType bgt)
* The world's style will determine what sprites are used for things like\
* generic structures.
*/
-void World::
-setStyle(std::string pre)
+void World::setStyle(std::string pre)
{
// get folder prefix
std::string prefix = pre.empty() ? "assets/style/classic/" : pre;
@@ -1157,8 +1153,7 @@ setStyle(std::string pre)
/**
* Pretty self-explanatory.
*/
-std::string World::
-getWeatherStr(void) const
+std::string World::getWeatherStr(void) const
{
switch (weather) {
case WorldWeather::Sunny:
@@ -1177,8 +1172,7 @@ getWeatherStr(void) const
return "???";
}
-const WorldWeather& World::
-getWeatherId(void) const
+const WorldWeather& World::getWeatherId(void) const
{
return weather;
}
@@ -1186,8 +1180,7 @@ getWeatherId(void) const
/**
* Pretty self-explanatory.
*/
-std::string World::
-setToLeft(std::string file)
+std::string World::setToLeft(std::string file)
{
return (toLeft = file);
}
@@ -1195,8 +1188,7 @@ setToLeft(std::string file)
/**
* Pretty self-explanatory.
*/
-std::string World::
-setToRight(std::string file)
+std::string World::setToRight(std::string file)
{
return (toRight = file);
}
@@ -1204,8 +1196,7 @@ setToRight(std::string file)
/**
* Pretty self-explanatory.
*/
-std::string World::
-getToLeft(void) const
+std::string World::getToLeft(void) const
{
return toLeft;
}
@@ -1213,8 +1204,7 @@ getToLeft(void) const
/**
* Pretty self-explanatory.
*/
-std::string World::
-getToRight(void) const
+std::string World::getToRight(void) const
{
return toRight;
}
@@ -1222,8 +1212,7 @@ getToRight(void) const
/**
* Attempts to go to the left world, returning either that world or itself.
*/
-WorldSwitchInfo World::
-goWorldLeft(Player *p)
+WorldSwitchInfo World::goWorldLeft(Player *p)
{
World *tmp;
@@ -1243,8 +1232,7 @@ goWorldLeft(Player *p)
/**
* Attempts to go to the right world, returning either that world or itself.
*/
-WorldSwitchInfo World::
-goWorldRight(Player *p)
+WorldSwitchInfo World::goWorldRight(Player *p)
{
World *tmp;
@@ -1256,19 +1244,51 @@ goWorldRight(Player *p)
return std::make_pair(this, vec2 {0, 0});
}
+void World::adoptNPC(NPC *e)
+{
+ entity.push_back(e);
+ npc.push_back(e);
+}
+
+void World::adoptMob(Mob *e)
+{
+ entity.push_back(e);
+ mob.push_back(e);
+}
+
/**
* Acts like goWorldLeft(), but takes an NPC; returning true on success.
*/
-bool World::
-goWorldLeft(NPC *e)
+bool World::goWorldLeft(NPC *e)
{
// check if entity is at world edge
- if(!toLeft.empty() && e->loc.x < worldStart + HLINES(15)) {
- currentWorldToLeft->addNPC(e->loc.x,e->loc.y);
- e->die();
+ if (!toLeft.empty() && e->loc.x < worldStart + HLINES(15)) {
+ currentWorldToLeft->adoptNPC(e);
+
+ npc.erase(std::find(std::begin(npc), std::end(npc), e));
+ entity.erase(std::find(std::begin(entity), std::end(entity), e));
+
+ e->loc.x = currentWorldToLeft->worldStart + currentWorldToLeft->getTheWidth() - HLINES(15);
+ e->loc.y = GROUND_HEIGHT_MAXIMUM;
+ ++e->outnabout;
+
+ return true;
+ }
+
+ return false;
+}
+
+bool World::goWorldRight(NPC *e)
+{
+ if (!toRight.empty() && e->loc.x + e->width > -worldStart - HLINES(15)) {
+ currentWorldToRight->adoptNPC(e);
- currentWorldToLeft->npc.back()->loc.x = currentWorldToLeft->worldStart + currentWorldToLeft->getTheWidth() - HLINES(15);
- currentWorldToLeft->npc.back()->loc.y = GROUND_HEIGHT_MAXIMUM;
+ npc.erase(std::find(std::begin(npc), std::end(npc), e));
+ entity.erase(std::find(std::begin(entity), std::end(entity), e));
+
+ e->loc.x = currentWorldToRight->worldStart + HLINES(15);
+ e->loc.y = GROUND_HEIGHT_MINIMUM;
+ --e->outnabout;
return true;
}
@@ -1279,8 +1299,7 @@ goWorldLeft(NPC *e)
/**
* Attempts to enter a building that the player is standing in front of.
*/
-WorldSwitchInfo World::
-goInsideStructure(Player *p)
+WorldSwitchInfo World::goInsideStructure(Player *p)
{
World *tmp;