]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
Work on merchants and yer mum
authordrumsetmonkey <abelleisle@roadrunner.com>
Tue, 1 Mar 2016 13:43:11 +0000 (08:43 -0500)
committerdrumsetmonkey <abelleisle@roadrunner.com>
Tue, 1 Mar 2016 13:43:11 +0000 (08:43 -0500)
include/inventory.h
src/entities.cpp
src/inventory.cpp
src/ui.cpp

index 8225ab27ce941e7da702c15a525b1dc8c8db6e8b..cf6e4807004abc15a816d94723a5f9f1885f4b67 100644 (file)
@@ -62,6 +62,7 @@ void initInventorySprites(void);
 void destroyInventory(void);
 
 const char *getItemTexturePath(std::string name);
+Texturec *getItemTexture(std::string name);
 float getItemWidth(std::string name);
 float getItemHeight(std::string name);
 
index 5e8d51ca6f652be551e43fdb5b3ce6710b2c4ad8..b0013d2ad189437c0bd157ebdb01e0d7a582ac2c 100644 (file)
@@ -459,8 +459,12 @@ void NPC::interact(){ //have the npc's interact back to the player
 
 void Merchant::interact(){
        ui::merchantBox(name, &bsinv, ":Accept:Good-Bye", false, "Welcome to Smithy\'s. Buy your sausages here you freaking meme lording screw-face");
-       //ui::merchantBox();
        ui::waitForDialog();
+       if(ui::dialogOptChosen == 1){
+               std::cout << "Gimme ye' munny" << std::endl;
+       }else{
+               std::cout << "See ye!" << std::endl;
+       }
 }
 
 void Object::interact(void){
index b32b56fd76762010ffdd31567a1ff14ccbaa4607..92cce75d56635521a94e22f2412f074fb57a2fdc 100644 (file)
@@ -142,6 +142,14 @@ const char *getItemTexturePath(std::string name){
        return NULL;
 }
 
+Texturec *getItemTexture(std::string name){
+       for(auto &i : itemMap){
+               if(i->name == name)
+                       return i->tex;
+       }
+       return NULL;
+}
+
 float getItemWidth(std::string name){
        for(auto &i : itemMap){
                if(i->name == name)
index 89e4805a7f7eb4d10ec4e7d9aa28eb7745b3b058..d5e21394a78931a40c82a769b23fe47737c47ecc 100644 (file)
@@ -773,6 +773,8 @@ namespace ui {
                                        setFontSize(16);
                                }
                        }else if(dialogMerchant){
+                               static int dispItem;
+
                                x=offset.x-SCREEN_WIDTH/6;
                                y=(offset.y+SCREEN_HEIGHT/2)-HLINE*8;
                        
@@ -792,30 +794,32 @@ namespace ui {
                                // draw typeOut'd text
                                putString(x + HLINE, y - fontSize - HLINE, (rtext = typeOut(dialogBoxText)));
                                merchAOptLoc[0][0] = offset.x - (SCREEN_WIDTH / 6.5) - 16;
-                               merchAOptLoc[0][1] = offset.x + (SCREEN_WIDTH / 6.5);
-                               merchAOptLoc[1][0] = offset.y + (SCREEN_HEIGHT *.25);
+                               merchAOptLoc[1][0] = offset.x + (SCREEN_WIDTH / 6.5);
+                               merchAOptLoc[0][1] = offset.y + (SCREEN_HEIGHT *.25);
                                merchAOptLoc[1][1] = offset.y + (SCREEN_HEIGHT *.25);
-                               merchAOptLoc[2][0] = offset.x - (SCREEN_WIDTH / 6.5);
-                               merchAOptLoc[2][1] = offset.x + (SCREEN_WIDTH / 6.5) + 16;
+                               merchAOptLoc[0][2] = offset.x - (SCREEN_WIDTH / 6.5);
+                               merchAOptLoc[1][2] = offset.x + (SCREEN_WIDTH / 6.5) + 16;
 
                                for(i = 0; i < 2; i++){
-                                       if(mouse.x > merchAOptLoc[0][i] && mouse.x < merchAOptLoc[2][i] &&
-                                          mouse.y > merchAOptLoc[1][i] - 8 && mouse.y < merchAOptLoc[1][i] + 8){
-                                               glColor3ub(255, 255, 0);
+                                       if(mouse.x > merchAOptLoc[i][0] && mouse.x < merchAOptLoc[i][2] &&
+                                          mouse.y > merchAOptLoc[i][1] - 8 && mouse.y < merchAOptLoc[i][1] + 8){
+                                               dispItem++;
+                                               glColor3ub(255,255,  0);
                                        }else{
                                                glColor3ub(255,255,255);
                                        }
                                }
 
                                glBegin(GL_TRIANGLES);
-                                       glVertex2f(merchAOptLoc[0][0],merchAOptLoc[1][0]);
-                                       glVertex2f(merchAOptLoc[2][0],merchAOptLoc[1][0]-8);
-                                       glVertex2f(merchAOptLoc[2][0],merchAOptLoc[1][0]+8);
+                                       glVertex2f(merchAOptLoc[0][0],merchAOptLoc[0][1]);
+                                       glVertex2f(merchAOptLoc[0][2],merchAOptLoc[0][1]-8);
+                                       glVertex2f(merchAOptLoc[0][2],merchAOptLoc[0][1]+8);
 
-                                       glVertex2f(merchAOptLoc[2][1],merchAOptLoc[1][1]);
-                                       glVertex2f(merchAOptLoc[0][1],merchAOptLoc[1][1]-8);
-                                       glVertex2f(merchAOptLoc[0][1],merchAOptLoc[1][1]+8);
+                                       glVertex2f(merchAOptLoc[1][2],merchAOptLoc[1][1]);
+                                       glVertex2f(merchAOptLoc[1][0],merchAOptLoc[1][1]-8);
+                                       glVertex2f(merchAOptLoc[1][0],merchAOptLoc[1][1]+8);
                                glEnd();
+
                        
                                // draw / handle dialog options if they exist
                                for(i = 0; i < dialogOptCount; i++){