diff options
-rw-r--r-- | assets/style/classic/stall.png | bin | 778 -> 739 bytes | |||
-rw-r--r-- | assets/style/classic/stallFruit.png | bin | 641 -> 635 bytes | |||
-rw-r--r-- | config/settings.xml.example | 3 | ||||
-rw-r--r-- | include/entities.h | 30 | ||||
-rw-r--r-- | main.cpp | 16 | ||||
-rw-r--r-- | src/entities.cpp | 29 | ||||
-rw-r--r-- | src/world.cpp | 5 | ||||
-rw-r--r-- | xml/playerSpawnHill1.xml | 2 |
8 files changed, 56 insertions, 29 deletions
diff --git a/assets/style/classic/stall.png b/assets/style/classic/stall.png Binary files differindex 1ac9844..f1718b2 100644 --- a/assets/style/classic/stall.png +++ b/assets/style/classic/stall.png diff --git a/assets/style/classic/stallFruit.png b/assets/style/classic/stallFruit.png Binary files differindex d9378d7..5491de6 100644 --- a/assets/style/classic/stallFruit.png +++ b/assets/style/classic/stallFruit.png diff --git a/config/settings.xml.example b/config/settings.xml.example index d9b8077..1c8fcd9 100644 --- a/config/settings.xml.example +++ b/config/settings.xml.example @@ -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"/> diff --git a/include/entities.h b/include/entities.h index 3b13ce3..1250708 100644 --- a/include/entities.h +++ b/include/entities.h @@ -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{ @@ -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. */ 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")){ diff --git a/xml/playerSpawnHill1.xml b/xml/playerSpawnHill1.xml index 86ee397..d3b5db4 100644 --- a/xml/playerSpawnHill1.xml +++ b/xml/playerSpawnHill1.xml @@ -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"> |