aboutsummaryrefslogtreecommitdiffstats
path: root/src/world.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2016-03-24 09:22:30 -0400
committerClyne Sullivan <tullivan99@gmail.com>2016-03-24 09:22:30 -0400
commit75a3ceb61ad4816ce03e6b615de2ce9331452aaa (patch)
tree2dde42d40caeef3cba32ccb20321c6b2af494102 /src/world.cpp
parentc3cfec14cb64016b9f3b039e17d49933e54ca6a0 (diff)
npc world walking
Diffstat (limited to 'src/world.cpp')
-rw-r--r--src/world.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/world.cpp b/src/world.cpp
index a8e6e50..357e527 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -803,15 +803,11 @@ singleDetect( Entity *e )
*/
if(e->loc.x < worldStart){ // Left bound
-
e->vel.x=0;
e->loc.x=(float)worldStart + HLINE / 2;
-
}else if(e->loc.x + e->width + HLINE > worldStart + worldStart * -2){ // Right bound
-
e->vel.x=0;
e->loc.x=worldStart + worldStart * -2 - e->width - HLINE;
-
}
}
}
@@ -1010,6 +1006,24 @@ goWorldLeft( Player *p )
return this;
}
+bool World::
+goWorldLeft( NPC *e )
+{
+ // check if entity is at world edge
+ if( !toLeft.empty() && e->loc.x < worldStart + HLINE * 15.0f ) {
+
+ currentWorldToLeft->addNPC(e->loc.x,e->loc.y);
+ e->alive = false;
+
+ currentWorldToLeft->npc.back()->loc.x = 0;
+ currentWorldToLeft->npc.back()->loc.y = GROUND_HEIGHT_MAXIMUM;
+
+ return true;
+ }
+
+ return false;
+}
+
World *World::
goWorldRight( Player *p )
{
@@ -1379,6 +1393,8 @@ World *loadWorldFromPtr( World *ptr )
currentWorldToRight = loadWorldFromXML( tmp->toRight );
loadedRight = false;
+ std::cout<<tmp->npc.back()->name<<std::endl;
+
return tmp;
}