]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
Merchants have to stay inside the stalls
authordrumsetmonkey <abelleisle@roadrunner.com>
Mon, 28 Mar 2016 12:26:06 +0000 (08:26 -0400)
committerdrumsetmonkey <abelleisle@roadrunner.com>
Mon, 28 Mar 2016 12:26:06 +0000 (08:26 -0400)
assets/style/classic/stall.png
assets/style/classic/stallFruit.png
config/settings.xml.example
include/entities.h
main.cpp
src/entities.cpp
src/world.cpp
xml/playerSpawnHill1.xml

index 1ac9844addb947366f55d685036e07a18d1a9256..f1718b2e222ca48fa767abde1765127cc850e90a 100644 (file)
Binary files a/assets/style/classic/stall.png and b/assets/style/classic/stall.png differ
index d9378d71ae495670104e689b4f3a5d202dc52a69..5491de6918c377d32637abc2794618aab7ea0fe3 100644 (file)
Binary files a/assets/style/classic/stallFruit.png and b/assets/style/classic/stallFruit.png differ
index d9b8077b9a4bf78890d8485792cb788f62677c4f..1c8fcd96099c8ad16543c2a1ba9832f35aab8c83 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
-<screen width="1280" height="800" fullscreen="true"/>
+<screen width="1280" height="800"/>
 
 <!--
 
@@ -14,7 +14,6 @@ Available fonts:
        VCR_OSD_MONO_1.001.ttf
 
 -->
-
 <font path="ttf/FreePixel.ttf"/>
 
 <hline size="3"/>
index 3b13ce39214e4a10729f89e9e0256992106ea67b..1250708d5a55b18bc218dd3508aeaa19c755db45 100644 (file)
@@ -202,6 +202,20 @@ public:
        void sspawn(float x,float y);
 };
 
+class Structures : public Entity{
+public:
+       BUILD_SUB bsubtype;
+       World *inWorld;
+       std::string inside;
+       std::string textureLoc;
+
+       Structures();
+       ~Structures();
+
+       unsigned int spawn(BUILD_SUB, float, float);
+};
+
+
 class NPC : public Entity {
 public:
        std::vector<int (*)(NPC *)>aiFunc;
@@ -214,7 +228,7 @@ public:
        void addAIFunc(int (*func)(NPC *),bool preload);
        void clearAIFunc(void);
        virtual void interact();
-       void wander(int);
+       virtual void wander(int);
 };
 
 class Merchant : public NPC{
@@ -223,22 +237,12 @@ public:
        uint currTrade;
 
        void interact();
+       Structures *inside;
 
        Merchant();
        ~Merchant();
-};
-
-class Structures : public Entity{
-public:
-       BUILD_SUB bsubtype;
-       World *inWorld;
-       std::string inside;
-       std::string textureLoc;
 
-       Structures();
-       ~Structures();
-
-       unsigned int spawn(BUILD_SUB, float, float);
+       void wander(int);
 };
 
 class Mob : public Entity{
index 0be7256ae23ac6ce6edf1c7ff307513d16076851..f4a00054f7a1d76db3e0af4e3f55b771859fc9d9 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -325,7 +325,7 @@ int main(int argc, char *argv[]){
         */
 
        SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
-       //SDL_GL_SetSwapInterval(0);
+       SDL_GL_SetSwapInterval(0);
 
        glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
 
@@ -461,16 +461,18 @@ void mainLoop(void){
 
        if(!currentTime)                                                // Initialize currentTime if it hasn't been
                currentTime=millis();
+       if(!prevTime){
+               prevTime=currentTime;
+       }
 
        /*
         * Update timing values. This is crucial to calling logic and updating the window (basically
         * the entire game).
         */
 
-       prevTime        = currentTime;
        currentTime = millis();
        deltaTime       = currentTime - prevTime;
-
+       prevTime        = currentTime;
 
        if(currentMenu)goto MENU;
 
@@ -487,7 +489,6 @@ void mainLoop(void){
                currentWorld->bgmPlay(prev);
                ui::dialogBoxExists = false;
        }
-
        if(prevPrevTime + MSEC_PER_TICK <= currentTime){
                //pool.Enqueue(logic);
                logic();
@@ -588,7 +589,7 @@ void render(){
        glPushMatrix();
        glLoadIdentity();
        // glOrtho((offset.x-SCREEN_WIDTH/2),(offset.x+SCREEN_WIDTH/2),(offset.y-SCREEN_HEIGHT/2),(offset.y+SCREEN_HEIGHT/2),-1,1);
-       glOrtho(floor(offset.x-SCREEN_WIDTH/2),floor(offset.x+SCREEN_WIDTH/2),floor(offset.y-SCREEN_HEIGHT/2),floor(offset.y+SCREEN_HEIGHT/2),-1,1);
+       glOrtho(floor(offset.x-SCREEN_WIDTH/2),floor(offset.x+SCREEN_WIDTH/2),floor(offset.y-SCREEN_HEIGHT/2),floor(offset.y+SCREEN_HEIGHT/2),20,-20);
        glMatrixMode(GL_MODELVIEW);
        glPushMatrix();
        glLoadIdentity();
@@ -604,8 +605,8 @@ void render(){
         *                                      GL_COLOR_BUFFER_BIT allows the matrices to have color on them
         */
 
-       glPushAttrib( GL_DEPTH_BUFFER_BIT | GL_LIGHTING_BIT );
-       glClear(GL_COLOR_BUFFER_BIT);
+       glPushAttrib( GL_DEPTH_BUFFER_BIT);
+       glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
        /**************************
        **** RENDER STUFF HERE ****
@@ -636,7 +637,6 @@ void render(){
        if(ui::mouse.x > player->loc.x && ui::mouse.y < player->loc.y+player->height/2 && handAngle <= 0)
                handAngle = 360 + handAngle;
 
-
        /*
         * Draw the player's inventory.
         */
index e97464e93c3598551572b21129eca2129a64efa3..5a92c48435a817bc0e20b194272221332f57a25f 100644 (file)
@@ -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");
index cdd945b01a5a96c0aca36c71f0481e2f96b9e425..d8fd2d3a4e895518ab2b88b10cbe7bff24f2f68a 100644 (file)
@@ -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")){
index 86ee3972537ecf42d24ae50cd71540a689d7303a..d3b5db4de1bfede1d34d2f99fa958b3b1fac3d2a 100644 (file)
@@ -16,7 +16,7 @@
 
        <page x="-200" id="assets/pages/gootaGoFast.png" />
 
-       <village name="the Cranmore Tubing Park">
+       <village name="Scrub Lawd">
                <structure type="0" x="-300" inside="playerSpawnHill1_Building1.xml"/>
                <structure type="5" x="-500" inside="playerSpawnHill1_Building1.xml"/>
                <stall type="market" texture="assets/style/classic/stall.png">