bool debug=false;
bool posFlag=false;
+ bool dialogPassive = false;
++ int dialogPassiveTime = 0;
+
/*
* Dialog stuff that needs to be 'public'.
dialogImportant = true;
//toggleBlack();
}
++ void passiveImportantText(int duration, const char *text,...){
++ va_list textArgs;
++
++ //if(!player->ground)return;
++
++ memset(dialogBoxText,0,512);
++
++ va_start(textArgs,text);
++ vsnprintf(dialogBoxText,512,text,textArgs);
++ va_end(textArgs);
++
++ dialogBoxExists = true;
++ dialogImportant = true;
++ dialogPassive = true;
++ dialogPassiveTime = duration;
++ }
++
++
void draw(void){
unsigned char i;
float x,y,tmp;
if(dialogImportant){
setFontColor(255,255,255);
- if(fadeIntensity == 255){
++ if(dialogPassive){
++ dialogPassiveTime -= deltaTime;
++ if(dialogPassiveTime < 0){
++ dialogPassive = false;
++ dialogImportant = false;
++ dialogBoxExists = false;
++ }
++ }
+ if(fadeIntensity == 255 || dialogPassive){
setFontSize(24);
putStringCentered(offset.x,offset.y,rtext);
+ setFontSize(16);
}
}else{
}
void quitGame(){
++ dialogBoxExists = false;
++ currentMenu = NULL;
++ delete[] currentMenu;
gameRunning = false;
updateConfig();
saveConfig();
for(uint i = 0; i < arrAmt(buildPaths);i++){
sTexLoc.push_back(prefix);
sTexLoc.back() += buildPaths[i];
-- std::cout << sTexLoc.back() << std::endl;
++ //std::cout << sTexLoc.back() << std::endl;
}
prefix += "bg/";
for(uint i = 0; i < arrAmt(bgPaths[0]);i++){
bgFiles.push_back(prefix);
bgFiles.back() += bgPaths[0][i];
-- std::cout << bgFiles.back() << std::endl;
++ //std::cout << bgFiles.back() << std::endl;
}
for(uint i = 0; i < arrAmt(bgPaths[1]);i++){
bgFilesIndoors.push_back(prefix);
bgFilesIndoors.back() += bgPaths[1][i];
-- std::cout << bgFilesIndoors.back() << std::endl;
++ //std::cout << bgFilesIndoors.back() << std::endl;
}
}
}
void World::detect(Player *p){
- //static std::thread villageThread;
-- World *hey = this;
/*
* Handle the player.
*/
-- singleDetect(p);
- //villageLogic(this);
- //villageThread = std::thread(villageLogic, this);
-
++ //auto pl = std::async(&World::singleDetect,this,p);
++ std::thread(&World::singleDetect,this, p).detach();
/*
* Handle all remaining entities in this world.
//LOOOOP:
static int what = 0;
-- for(auto &e : hey->entity)
-- hey->singleDetect(e);
++ for(auto &e : entity)
++ std::thread(&World::singleDetect,this,e).detach();
++ //hey->singleDetect(e);
for(auto &part : particles){
int l;
unsigned int i;
}
what++;
}what=0;
+ for(auto &b : build){
+ switch(b->bsubtype){
+ case FOUNTAIN:
+ for(int r = 0; r < (rand()%25)+10;r++){
+ addParticle( rand()%HLINE*3 + b->loc.x + b->width/2,
+ b->loc.y + b->height,
+ HLINE*1.25,
+ HLINE*1.25,
+ rand()%2 == 0?-(rand()%7)*.01:(rand()%7)*.01,
+ ((4+rand()%6)*.05),
+ {0,0,255},
+ 2500);
+
+ particles.back()->fountain = true;
+ }
+ break;
+ case FIRE_PIT:
+ for(int r = 0; r < (rand()%20)+10;r++){
+ addParticle(rand()%(int)(b->width/2) + b->loc.x+b->width/4, b->loc.y+3*HLINE, HLINE, HLINE, rand()%2 == 0?-(rand()%3)*.01:(rand()%3)*.01,((4+rand()%6)*.005), {255,0,0}, 400);
+ particles.back()->gravity = false;
+ particles.back()->behind = true;
+ }
+ break;
+ default: break;
+ }
+ }
+
++ for(auto &v : village){
++ if(p->loc.x > v.start.x && p->loc.x < v.end.x){
++ if(!v.in){
++ ui::passiveImportantText(5000,"Welcome to %s",v.name.c_str());
++ v.in = true;
++ }
++ }else{
++ v.in = false;
++ }
++ }
++
/*if(hey->infront){
hey = hey->infront;
goto LOOOOP;
}*/
- //villageThread.join();
}
++
void World::addStructure(BUILD_SUB sub, float x,float y, char *tex, const char *inside){
build.push_back(new Structures());
build.back()->inWorld = this;
extern World *currentWorld;
World *loadWorldFromXML(const char *path){
+ if(currentXML){
+ currentWorld->save();
+ delete[] currentXML;
+ }
+
+ return loadWorldFromXMLNoSave(path);
+ }
+
+ World *loadWorldFromXMLNoSave(const char *path){
XMLDocument xml;
XMLElement *wxml;
+ XMLElement *vil;
World *tmp;
-- float spawnx;
++ float spawnx, randx;
bool dialog,Indoor;
const char *ptr,*name;
tmp->addMob(MS_TRIGGER,wxml->FloatAttribute("x"),0,commonTriggerFunc);
tmp->mob.back()->heyid = wxml->Attribute("id");
}
-
+
wxml = wxml->NextSiblingElement();
}
- vil->QueryFloatAttribute("x",&spawnx) != XML_NO_ERROR ?
- getRand() % tmp->getTheWidth() / 2.0f :
- spawnx,
+
++ if(vil){
++ tmp->village.push_back(vil->Attribute("name"));
++
++ vil = vil->FirstChildElement();
++ }
++
+ while(vil){
+ name = vil->Name();
++ randx = getRand() % tmp->getTheWidth() - (tmp->getTheWidth() / 2.0f);
++
++ /**
++ * READS DATA ABOUT STRUCTURE CONTAINED IN VILLAGE
++ */
+ if(!strcmp(name,"structure")){
+ ptr = vil->Attribute("inside");
+ tmp->addStructure((BUILD_SUB)vil->UnsignedAttribute("type"),
- //tmp->village.back().build.push_back(tmp->build.back());
++ vil->QueryFloatAttribute("x", &spawnx) != XML_NO_ERROR ?
++ randx : spawnx,
+ 100,
+ (char*)vil->Attribute("texture"),
+ ptr);
+
++ tmp->village.back().build.push_back(tmp->build.back());
++ }
++ if(tmp->village.back().build.back()->loc.x < tmp->village.back().start.x){
++ tmp->village.back().start.x = tmp->village.back().build.back()->loc.x;
+ }
++ if(tmp->village.back().build.back()->loc.x + tmp->village.back().build.back()->width > tmp->village.back().end.x){
++ tmp->village.back().end.x = tmp->village.back().build.back()->loc.x + tmp->village.back().build.back()->width;
++ }
++
++ //go to the next element in the village block
+ vil = vil->NextSiblingElement();
+ }
std::ifstream dat (((std::string)currentXML + ".dat").c_str());
if(dat.good()){