aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authordrumsetmonkey <abelleisle@roadrunner.com>2016-03-28 08:26:06 -0400
committerdrumsetmonkey <abelleisle@roadrunner.com>2016-03-28 08:26:06 -0400
commit82c178d797b9a23c31d7dad1cc8cac29d27c6eb1 (patch)
treec96240b1cc6ab185cce1da3929a436cb8f8077bb /src
parent38bf2365e31745a5d6bfcea8f547b6263017f113 (diff)
Merchants have to stay inside the stalls
Diffstat (limited to 'src')
-rw-r--r--src/entities.cpp29
-rw-r--r--src/world.cpp5
2 files changed, 29 insertions, 5 deletions
diff --git a/src/entities.cpp b/src/entities.cpp
index e97464e..5a92c48 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -31,7 +31,7 @@ const char *randomDialog[RAND_DIALOG_COUNT] = {
"Frig.",
"The sine of theta equals the opposite over the hypotenuese.",
"Did you know the developers spelt brazier as brazzier.",
- "My dad once said to me, \"Boy, you are in a game.\" I never knew what he meant by that."
+ "What's a bagel? I don't know because I'm mormon"
};
void initEntity(){
@@ -171,6 +171,8 @@ Merchant::Merchant(){ //sets all of the Merchant specific traits on object creat
trade.reserve(100);
currTrade = 0;
+ inside = nullptr;
+
//tex = new Texturec(1,"assets/NPC.png");
//inv = new Inventory(NPC_INV_SIZE);
//inv = new Inventory(1);
@@ -183,7 +185,7 @@ Merchant::~Merchant(){
/*while(!aiFunc.empty()){
aiFunc.pop_back();
}*/
-
+ delete inside;
//delete inv;
//delete tex;
//delete[] name;
@@ -459,6 +461,29 @@ void NPC::interact(){ //have the npc's interact back to the player
}).detach();
}
+void Merchant::wander(int timeRun){
+ static int direction;
+ if ( ticksToUse == 0 ) {
+ ticksToUse = timeRun;
+
+ vel.x = .008 * HLINE;
+ direction = (getRand() % 3 - 1);
+
+ if ( direction == 0 )
+ ticksToUse *= 2;
+
+ vel.x *= direction;
+ }
+
+ if( vel.x < 0)
+ currentWorld->goWorldLeft( this );
+ if(inside != nullptr){
+ if(loc.x <= inside->loc.x)loc.x = inside->loc.x;
+ if(loc.x + width >= inside->loc.x + inside->width)loc.x = inside->loc.x + inside->width - width;
+ }
+ ticksToUse--;
+}
+
void Merchant::interact(){
std::thread([this]{
ui::merchantBox(name, trade[currTrade], ":Accept:Good-Bye", false, "Welcome to Smithy\'s. Buy your sausages here you freaking meme lording screw-face");
diff --git a/src/world.cpp b/src/world.cpp
index cdd945b..d8fd2d3 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -401,9 +401,7 @@ bgmPlay( World *prev ) const
* screen.
*/
-void World::
-draw( Player *p )
-{
+void World::draw(Player *p){
// iterators
int i, iStart, iEnd;
@@ -1631,6 +1629,7 @@ loadWorldFromXMLNoSave( std::string path ) {
vil->StrAttribute("texture"),
vil->StrAttribute("inside"));
tmp->addMerchant(0,100);
+ tmp->merchant.back()->inside = tmp->build.back();
if(vil->FirstChildElement("buy")){
std::cout << "Buy" << std::endl;
}if(vil->FirstChildElement("sell")){