- removed old, unused and commented codes
- began working on XML'ing quests
- improved mouse
+
+2/4/2016:
+=========
+
+ - fixed world boundary glitch
+ - began work on XML'ing triggers
+ - npcs can assign quests through XML
+ - screenshots
+ - improved memory management
+ - more audio sliders
bool aggressive;
double init_y;
void (*hey)(Mob *callee);
+ std::string heyid;
Mob(int);
~Mob();
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{
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;
}
}
- /*
- * 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));
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;
}
void destroyInventory(void){
+
+ while(!itemMap.empty()){
+ delete itemMap.front();
+ itemMap.erase(itemMap.begin());
+ }
+
Mix_FreeChunk(swordSwing);
}
fwrite(&bmih, 1,sizeof(BITMAPINFOHEADER),bmp);
fwrite(&bgr, 1,3*SCREEN_WIDTH*SCREEN_HEIGHT,bmp);
+ delete[] pixels;
+ fclose(bmp);
}
void dialogAdvance(void){
if(dialogImportant){
dialogImportant = false;
setFontSize(16);
- toggleBlack();
+ //toggleBlack();
}
+ /*if(ui::fontSize != 16)
+ setFontSize(16);*/
dialogBoxExists = false;
}
break;
case SDLK_F12:
// Make the BYTE array, factor of 3 because it's RBG.
- static GLubyte* pixels = new GLubyte[ 3 * SCREEN_WIDTH * SCREEN_HEIGHT];
+ static GLubyte* pixels;
+ pixels = new GLubyte[ 3 * SCREEN_WIDTH * SCREEN_HEIGHT];
glReadPixels(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, GL_RGB, GL_UNSIGNED_BYTE, pixels);
takeScreenshot(pixels);
* 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
World *World::goWorldLeft(Player *p){
World *tmp;
+
if(toLeft && p->loc.x < x_start + HLINE * 15){
tmp = loadWorldFromXML(toLeft);
#include <sstream>
-extern int commonAIFunc(NPC *);
+extern int commonAIFunc(NPC *);
+extern void commonTriggerFunc(Mob *);
void World::load(void){
std::string save,data,line;
strcpy(currentXML,"xml/");
strcat(currentXML,path);
- //std::cout<<currentXML<<std::endl;
-
xml.LoadFile(currentXML);
wxml = xml.FirstChildElement("World");
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();
}
<link right="playerSpawnHill2.xml" />
- <mob type="1" aggressive="true" />
+ <mob type="1" aggressive="false" />
+
+ <trigger x="-300" id="Test" />
<npc name="Ralph" hasDialog="true" />
<npc name="Johnny" hasDialog="true" />
</World>
+<Trigger id="Test">It was a dark and stormy night...</Trigger>
+
<Dialog name="Ralph">
<text id="0">
</Dialog>
<Dialog name="Johnny">
- <text id="0" nextid="1" stop="true">
+ <text id="0" nextid="1" pause="true">
Sup bro!
<quest assign="Quest #1" />
</text>
- <text id="1" >
+ <text id="1" stop="true">
My name's Johnny.
<give id="Dank Maymay" count="1" />
</text>