return -1;
}
Mix_AllocateChannels(8);
+ updateConfig();
// Run Mix_Quit when main returns
atexit(Mix_Quit);
delete[] shaderSource;
glEnable(GL_MULTISAMPLE);
-
- Mix_Volume(0,VOLUME_MASTER);
/*
* Create all the worlds, entities, mobs, and the player. This function is defined in
if(player->loc.x - SCREEN_WIDTH/2 < currentWorld->getTheWidth() * -0.5f)
offset.x = ((currentWorld->getTheWidth() * -0.5f) + SCREEN_WIDTH / 2) + player->width / 2;
if(player->loc.x + player->width + SCREEN_WIDTH/2 > currentWorld->getTheWidth() * 0.5f)
- offset.x = ((currentWorld->getTheWidth() * 0.5f) - SCREEN_WIDTH / 2);// + player->width / 2;
+ offset.x = ((currentWorld->getTheWidth() * 0.5f) - SCREEN_WIDTH / 2) - player->width / 2;
}
if(player->loc.y > SCREEN_HEIGHT/2)
glMatrixMode(GL_PROJECTION);
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((offset.x-SCREEN_WIDTH/2),(offset.x+SCREEN_WIDTH/2),(offset.y-SCREEN_HEIGHT/2),(offset.y+SCREEN_HEIGHT/2),-1,1);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
}
}
}
- for(auto &b : currentWorld->build){
+ /*for(auto &b : currentWorld->build){
switch(b->bsubtype){
case FOUNTAIN:
for(int r = 0; r < (rand()%25)+10;r++){
break;
default: break;
}
- }
+ }*/
/*
* Switch between day and night (SUNNY and DARK) if necessary.
WEATHER weather = SUNNY;
-// const char *bgPaths[2][7]={
-// {"assets/bg.png", // Daytime background
-// "assets/bgn.png", // Nighttime background
-// "assets/bgFarMountain.png", // Furthest layer
-// "assets/forestTileBack.png", // Closer layer
-// "assets/forestTileMid.png", // Near layer
-// "assets/forestTileFront.png", // Closest layer
-// "assets/dirt.png"}, // Dirt
-// {"assets/bgWoodTile.png",
-// NULL,
-// NULL,
-// NULL,
-// NULL,
-// NULL}
-// };
-
-const std::string bgPaths[2][8]={
- {"bg.png", // Daytime background
- "bgn.png", // Nighttime background
- "bgFarMountain.png", // Furthest layer
- "forestTileBack.png", // Closer layer
- "forestTileMid.png", // Near layer
- "forestTileFront.png", // Closest layer
- "dirt.png", // Dirt
- "grass.png"}, // Grass
- {"bgWoodTile.png",
- "bgWoodTile.png",
- "bgWoodTile.png",
- "bgWoodTile.png",
- "bgWoodTile.png",
- "bgWoodTile.png",
- "bgWoodTile.png",
- "bgWoodTile.png"}
+
+const std::string bgPaths[2][9]={
+ {"bg.png", // Daytime background
+ "bgn.png", // Nighttime background
+ "bgFarMountain.png", // Furthest layer
+ "forestTileFar.png", // Furthest away Tree Layer
+ "forestTileBack.png", // Closer layer
+ "forestTileMid.png", // Near layer
+ "forestTileFront.png", // Closest layer
+ "dirt.png", // Dirt
+ "grass.png"}, // Grass
+ {"bgWoodTile.png",
+ "bgWoodTile.png",
+ "bgWoodTile.png",
+ "bgWoodTile.png",
+ "bgWoodTile.png",
+ "bgWoodTile.png",
+ "bgWoodTile.png",
+ "bgWoodTile.png"}
};
const std::string buildPaths[] = { "townhall.png",
"lampPost1.png",
"brazzier.png"};
-const float bgDraw[3][3]={
+const float bgDraw[4][3]={
{100,240,.6 },
{150,250,.4 },
- {255,255,.25}
+ {200,255,.25},
+ {255,255,.1}
};
float worldGetYBase(World *w){
if(e->type != STRUCTURET && e->canMove){
e->loc.x += e->vel.x * delta;
if(e->vel.x < 0)e->left = true;
- else if(e->vel.x > 0)e->left = false;
+ else if(e->vel.x > 0)e->left = false;
}
}
glEnd();
/*
- * Draw three layers of trees.
+ * Draw four layers of trees.
*/
- for(i = 0; i < 3; i++){
+ for(i = 0; i < 4; i++){
bgTex->bindNext();
safeSetColorA(bgDraw[i][0]-bgshade,bgDraw[i][0]-bgshade,bgDraw[i][0]-bgshade,bgDraw[i][1]);
}
for(auto &b : current->build){
b->draw();
- }
-
+ }
/*
* Draw the layer up until the grass portion, which is done later.
*/
o->loc.y-=(yoff-DRAW_Y_OFFSET);
}
}
-
/*
* If we're drawing the closest/last world, handle and draw the player.
}
void World::detect(Player *p){
+ //static std::thread villageThread;
World *hey = this;
/*
*/
singleDetect(p);
+ //villageLogic(this);
+ //villageThread = std::thread(villageLogic, this);
+
/*
* Handle all remaining entities in this world.
}
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;
+ }
+ }
+
/*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());
if(toRight && p->loc.x + p->width > -x_start - HLINE * 15){
tmp = loadWorldFromXML(toRight);
- p->loc.x = tmp->x_start + HLINE * 10;
+ p->loc.x = tmp->x_start + (int)HLINE * 10;
p->loc.y = tmp->line[0].y;
return tmp;
World *loadWorldFromXML(const char *path){
XMLDocument xml;
XMLElement *wxml;
+ XMLElement *vil;
World *tmp;
float spawnx;
xml.LoadFile(currentXML);
wxml = xml.FirstChildElement("World");
+ vil = xml.FirstChildElement("World")->FirstChildElement("village");
if(wxml){
wxml = wxml->FirstChildElement();
Indoor = false;
tmp = new World();
+ if(vil){
+ vil = vil->FirstChildElement();
+ //tmp->village.push_back(vil->Attribute("name"));
+
+ }
}else if((wxml = xml.FirstChildElement("IndoorWorld"))){
wxml = wxml->FirstChildElement();
Indoor = true;
while(wxml){
name = wxml->Name();
-
if(!strcmp(name,"link")){
if((ptr = wxml->Attribute("left")))
tmp->setToLeft(ptr);
tmp->addMob(MS_TRIGGER,wxml->FloatAttribute("x"),0,commonTriggerFunc);
tmp->mob.back()->heyid = wxml->Attribute("id");
}
-
+
wxml = wxml->NextSiblingElement();
}
+
+ while(vil){
+ name = vil->Name();
+ if(!strcmp(name,"structure")){
+ ptr = vil->Attribute("inside");
+ tmp->addStructure((BUILD_SUB)vil->UnsignedAttribute("type"),
+ vil->QueryFloatAttribute("x",&spawnx) != XML_NO_ERROR ?
+ getRand() % tmp->getTheWidth() / 2.0f :
+ spawnx,
+ 100,
+ (char*)vil->Attribute("texture"),
+ ptr);
+
+ //tmp->village.back().build.push_back(tmp->build.back());
+ }
+ vil = vil->NextSiblingElement();
+ }
std::ifstream dat (((std::string)currentXML + ".dat").c_str());
if(dat.good()){