aboutsummaryrefslogtreecommitdiffstats
path: root/src/world.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/world.cpp')
-rw-r--r--src/world.cpp56
1 files changed, 36 insertions, 20 deletions
diff --git a/src/world.cpp b/src/world.cpp
index e56720d..58606e5 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -185,8 +185,6 @@ void World::load(std::ifstream *i){
}
}
-void *NULLPTR = NULL;
-
World::World(void){
bgm = NULL;
@@ -426,11 +424,12 @@ void World::update(Player *p,unsigned int delta){
else if(e->vel.x > 0)e->left = false;
}
}
- uint oh = 0;
for(auto &pa : particles){
if(pa->kill(deltaTime)){
//delete pa;
- particles.erase(particles.begin()+oh);
+ //particles.erase(particles.begin()+oh);
+ std::cout << pa.duration;
+ std::cout << particles[oh].duration;
}else if(pa->canMove){
pa->loc.y += pa->vely * deltaTime;
pa->loc.x += pa->velx * deltaTime;
@@ -444,8 +443,8 @@ void World::update(Player *p,unsigned int delta){
}
}
}
- }oh++;
- }oh=0;
+ }
+ }
if(ui::dialogImportant){
Mix_FadeOutMusic(2000);
@@ -1049,7 +1048,7 @@ LOOOOP:
part->velx = 0;
part->canMove = false;
}else{
- if(!part->gravity && part->vely > -2)part->vely-=.003 * deltaTime;
+ if(part->gravity && part->vely > -2)part->vely-=.003 * deltaTime;
}
what++;
}what=0;
@@ -1058,22 +1057,38 @@ LOOOOP:
goto LOOOOP;
}
}
-void World::addStructure(BUILD_SUB sub, float x,float y,World *inside){
+void World::addStructure(BUILD_SUB sub, float x,float y,World **inside){//,World **outside){
build.push_back(new Structures());
build.back()->spawn(sub,x,y,this);
build.back()->inWorld=this;
- build.back()->inside = (World *)inside;
- ((IndoorWorld *)inside)->outside = this;
+ build.back()->inside = inside;
+ //std::cout<<"yo"<<std::endl;
+
+
+// void * |void ** - *|void ** | void **
+ //((IndoorWorld *)inside[0])->outside = outside;
+
+
+ //std::cout<<"yo"<<std::endl;
entity.push_back(build.back());
}
-void World::addVillage(int x, int y, int bCount, int npcMin, int npcMax,World *inside){
+void World::addVillage(int bCount, int npcMin, int npcMax,World **inside){
std::cout << npcMin << ", " << npcMax << std::endl;
- this->addStructure(TOWN_HALL, x,y, inside);
- bCount--;
- this->addStructure(LAMP_POST, x-3*HLINE,y, this);
- this->addStructure(LAMP_POST, x+53*HLINE,y, this);
+ //int xwasd;
+ for(int i = 0; i < bCount; i++){
+ addStructure(HOUSE,x_start + (i * 300),100,inside);//,(World **)&NULLPTR);
+ /*std::cout<<"1\n";
+ HERE:
+ xwasd = (rand()%(int)x+1000*HLINE);
+ for(auto &bu : build){
+ if(xwasd > bu->loc.x && xwasd < bu->loc.x+bu->width)goto HERE;
+ }
+ std::cout<<"2\n";
+ addStructure(t,HOUSE,xwasd,y,inside);
+ std::cout<<"3\n";*/
+ }
}
void World::addMob(int t,float x,float y){
mob.push_back(new Mob(t));
@@ -1189,24 +1204,25 @@ World *World::goInsideStructure(Player *p){
if(!thing.size()){
for(auto &b : build){
if(p->loc.x > b->loc.x &&
- p->loc.x + p->width < b->loc.x + b->width ){
+ p->loc.x + p->width < b->loc.x + b->width &&
+ *b->inside != this ){
thing.push_back(this);
ui::toggleBlackFast();
ui::waitForCover();
ui::toggleBlackFast();
- return (World *)b->inside;
+ return (World *)*b->inside;
}
}
}else{
for(auto &b : ((World *)thing.back())->build){
- if(b->inside == this){
- World *tmp = (World *)thing.back();
+ if(*b->inside == this){
+ //World *tmp = (World *)thing.back();
p->loc.x = b->loc.x + (b->width / 2) - (p->width / 2);
thing.erase(thing.end()-1);
ui::toggleBlackFast();
ui::waitForCover();
ui::toggleBlackFast();
- return tmp;
+ return ((IndoorWorld *)(*b->inside))->outside;
}
}
}