diff options
author | drumsetmonkey <abelleisle@roadrunner.com> | 2016-02-04 09:25:25 -0500 |
---|---|---|
committer | drumsetmonkey <abelleisle@roadrunner.com> | 2016-02-04 09:25:25 -0500 |
commit | 164de60e121552d92712179d480ef1859f42127a (patch) | |
tree | ab91e0422c6fe159051149cc1e77cb7689d1f3e6 /src | |
parent | 814dab606cfeeabd4aeecba852507c3c3f1a005f (diff) | |
parent | 2cb30b167401f1785ebfa744e8612639a150deb2 (diff) |
Volume Mixer
Diffstat (limited to 'src')
-rw-r--r-- | src/gameplay.cpp | 55 | ||||
-rw-r--r-- | src/inventory.cpp | 6 | ||||
-rw-r--r-- | src/ui.cpp | 6 | ||||
-rw-r--r-- | src/world.cpp | 14 |
4 files changed, 62 insertions, 19 deletions
diff --git a/src/gameplay.cpp b/src/gameplay.cpp index 1103cfa..2b540d9 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -173,7 +173,7 @@ int commonAIFunc(NPC *speaker){ speaker->dialogIndex = 9999; return 0; }else if(exml->QueryBoolAttribute("pause",&stop) == XML_NO_ERROR && stop){ - speaker->dialogIndex = 9999; + //speaker->dialogIndex = 9999; return 1; }else return commonAIFunc(speaker); }else{ @@ -191,6 +191,38 @@ int commonAIFunc(NPC *speaker){ return 0; } +void commonTriggerFunc(Mob *callee){ + static bool lock = false; + XMLDocument xml; + XMLElement *exml; + + if(!lock){ + lock = true; + + xml.LoadFile(currentXML); + exml = xml.FirstChildElement("Trigger"); + + while(strcmp(exml->Attribute("id"),callee->heyid.c_str())) + exml = exml->NextSiblingElement(); + + player->vel.x = 0; + + std::cout<<"1\n"; + ui::toggleBlackFast(); + std::cout<<"2\n"; + ui::waitForCover(); + std::cout<<"3\n"; + ui::importantText(exml->GetText()); + std::cout<<"4\n"; + ui::waitForDialog(); + std::cout<<"5\n"; + ui::toggleBlackFast(); + + callee->alive = false; + lock = false; + } +} + void destroyEverything(void); void initEverything(void){ std::vector<std::string> xmlFiles; @@ -227,17 +259,6 @@ void initEverything(void){ } } - /* - * Spawn the player and begin the game. - */ - - player = new Player(); - player->spawn(200,100); - - currentWorld->bgmPlay(NULL); - atexit(destroyEverything); - std::cout << "Hey"; - pauseMenu.items.push_back(ui::createParentButton({-256/2,0},{256,75},{0.0f,0.0f,0.0f}, "Resume")); pauseMenu.items.push_back(ui::createChildButton({-256/2,-100},{256,75},{0.0f,0.0f,0.0f}, "Options")); pauseMenu.items.push_back(ui::createButton({-256/2,-200},{256,75},{0.0f,0.0f,0.0f}, "Save and Quit", ui::quitGame)); @@ -252,6 +273,16 @@ void initEverything(void){ optionsMenu.child = NULL; optionsMenu.parent = &pauseMenu; // optionsMenu.push_back(ui::createButton({-256/2,-200},{256,75},{0.0f,0.0f,0.0f}, (const char*)("Save and Quit"), ); + + /* + * Spawn the player and begin the game. + */ + + player = new Player(); + player->spawn(200,100); + + currentWorld->bgmPlay(NULL); + atexit(destroyEverything); } extern std::vector<int (*)(NPC *)> AIpreload; diff --git a/src/inventory.cpp b/src/inventory.cpp index de60030..93bdeb6 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -88,6 +88,12 @@ void initInventorySprites(void){ } void destroyInventory(void){ + + while(!itemMap.empty()){ + delete itemMap.front(); + itemMap.erase(itemMap.begin()); + } + Mix_FreeChunk(swordSwing); } @@ -976,7 +976,7 @@ namespace ui { fwrite(&bgr, 1,3*SCREEN_WIDTH*SCREEN_HEIGHT,bmp); delete[] pixels; - + fclose(bmp); } @@ -1000,8 +1000,10 @@ DONE: if(dialogImportant){ dialogImportant = false; setFontSize(16); - toggleBlack(); + //toggleBlack(); } + /*if(ui::fontSize != 16) + setFontSize(16);*/ dialogBoxExists = false; } diff --git a/src/world.cpp b/src/world.cpp index 7126095..6118851 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -895,10 +895,10 @@ void World::singleDetect(Entity *e){ * Insure that the entity doesn't fall off either edge of the world. */ - if(e->loc.x<x_start){ // Left bound + if(e->loc.x < x_start){ // Left bound e->vel.x=0; - e->loc.x=x_start + HLINE / 2; + e->loc.x=(float)x_start + HLINE / 2; }else if(e->loc.x + e->width + HLINE > x_start + getWidth(this)){ // Right bound @@ -1071,6 +1071,7 @@ char *World::setToRight(const char *file){ World *World::goWorldLeft(Player *p){ World *tmp; + if(toLeft && p->loc.x < x_start + HLINE * 15){ tmp = loadWorldFromXML(toLeft); @@ -1200,7 +1201,8 @@ void World::save(void){ #include <sstream> -extern int commonAIFunc(NPC *); +extern int commonAIFunc(NPC *); +extern void commonTriggerFunc(Mob *); void World::load(void){ std::string save,data,line; @@ -1449,8 +1451,6 @@ World *loadWorldFromXML(const char *path){ strcpy(currentXML,"xml/"); strcat(currentXML,path); - //std::cout<<currentXML<<std::endl; - xml.LoadFile(currentXML); wxml = xml.FirstChildElement("World"); @@ -1523,7 +1523,11 @@ World *loadWorldFromXML(const char *path){ tmp->addStructure((BUILD_SUB)wxml->UnsignedAttribute("type"),getRand() % tmp->getTheWidth() / 2.0f,100,ptr); else tmp->addStructure((BUILD_SUB)wxml->UnsignedAttribute("type"),spawnx,wxml->FloatAttribute("y"),ptr); + }else if(!strcmp(name,"trigger")){ + tmp->addMob(MS_TRIGGER,wxml->FloatAttribute("x"),0,commonTriggerFunc); + tmp->mob.back()->heyid = wxml->Attribute("id"); } + wxml = wxml->NextSiblingElement(); } |