diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2015-12-10 08:13:10 -0500 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2015-12-10 08:13:10 -0500 |
commit | 2baf10d54f1cbfdb781b9b37987e0815dbdafc3f (patch) | |
tree | e6fbe1bc77094f78811907b5fcd355ea9d6b316c /src | |
parent | ce169efec21d44b6c7b3133280d9088ba1c108a5 (diff) |
buildings stay
Diffstat (limited to 'src')
-rw-r--r-- | src/entities.cpp | 6 | ||||
-rw-r--r-- | src/gameplay.cpp | 13 | ||||
-rw-r--r-- | src/ui.cpp | 2 | ||||
-rw-r--r-- | src/world.cpp | 103 |
4 files changed, 68 insertions, 56 deletions
diff --git a/src/entities.cpp b/src/entities.cpp index fc2c316..1c36ca7 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -103,7 +103,7 @@ NPC::NPC(){ //sets all of the NPC specific traits on object creation tex = new Texturec(1,"assets/NPC.png"); inv = new Inventory(NPC_INV_SIZE); - randDialog = rand() % 10; + randDialog = rand() % 10 - 1; } NPC::~NPC(){ while(!aiFunc.empty()){ @@ -309,10 +309,10 @@ void NPC::addAIFunc(int (*func)(NPC *),bool preload){ else aiFunc.push_back(func); } -const char *randomDialog[10] = { +const char *randomDialog[] = { "What a beautiful day it is.", "Have you ever went fast? I have.", - "I heard if you complete a quest, you'll get a special reward." + "I heard if you complete a quest, you'll get a special reward.", "How much wood could a woodchuck chuck if a woodchuck could chuck wood?", "I don\'t think anyone has ever been able to climb up that hill.", "If you ever see a hole in the ground, watch out; it could mean the end for you.", diff --git a/src/gameplay.cpp b/src/gameplay.cpp index fbcc782..b9aa328 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -55,18 +55,6 @@ void story(Mob *callee){ Mix_FadeOutMusic(0); ui::importantText("It was a dark and stormy night..."); ui::waitForDialog(); - ui::importantText("...and Clyne wanted to hear what the click track sounds like."); - ui::waitForDialog(); - ui::importantText("So Clyne made a really long piece of dialog so that the sound"); - ui::waitForDialog(); - ui::importantText("plays"); - ui::waitForDialog(); - ui::importantText("multiple"); - ui::waitForDialog(); - ui::importantText("times."); - ui::waitForDialog(); - ui::importantText("Clyne is a faggot."); - ui::waitForDialog(); callee->alive = false; } @@ -129,6 +117,7 @@ void initEverything(void){ iw=new IndoorWorld(); iw->setBackground(BG_WOODHOUSE); + iw->setBGM(NULL); iw->generate(200); iw->addMob(MS_TRIGGER,0,0,CUTSCENEEE2); @@ -675,9 +675,9 @@ DONE: tmp=currentWorld; currentWorld=currentWorld->goWorldFront(player); // Go forward a layer if possible if(tmp!=currentWorld){ - player->loc.y=0; currentWorld->behind->detect(player); player->vel.y=.2; + player->loc.y+=HLINE*5; player->ground=false; } break; diff --git a/src/world.cpp b/src/world.cpp index 9674b64..3fdfa7f 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -41,7 +41,13 @@ const float bgDraw[3][3]={ }; float worldGetYBase(World *w){ - return w?GEN_MIN:0; + World *tmp = w; + float base = GEN_MIN; + while(tmp->infront){ + tmp = tmp->infront; + base -= DRAW_Y_OFFSET; + } + return base; } void World::setBackground(WORLD_BG_TYPE bgt){ @@ -298,11 +304,14 @@ void World::update(Player *p,unsigned int delta){ void World::setBGM(const char *path){ if(!bgm) delete[] bgm; - //if(!path){ + if(path != NULL){ bgm = new char[strlen(path) + 1]; strcpy(bgm,path); bgmObj = Mix_LoadMUS(bgm); - //}else std::cout<<path; + }else{ + bgm = new char[1]; + bgm[0] = '\0'; + } } static Mix_Music *bgmC; @@ -312,6 +321,8 @@ void World::bgmPlay(void){ Mix_VolumeMusic(50); Mix_PlayMusic(bgmObj,-1); // Loop infinitely bgmC = bgmObj; + }else{ + Mix_FadeOutMusic(800); } } @@ -331,38 +342,47 @@ extern unsigned int tickCount; void World::draw(Player *p){ static float yoff=DRAW_Y_OFFSET; // Initialize stuff static int shade,bgshade; - static World *current; + static World *current=this; unsigned int i; int is,ie,v_offset,cx_start,width; struct line_t *cline; + float base; bgshade = worldShade << 1; // *2 - width = (-x_start) << 1; + base = worldGetYBase(this); /* * Draw the background images in the appropriate order. */ +LLLOOP: + if(current->infront){ + current=current->infront; + goto LLLOOP; + } + cx_start = current->x_start; + width = (-x_start) << 1; + glEnable(GL_TEXTURE_2D); bgTex->bind(0); safeSetColorA(255,255,255,255 - worldShade * 4); glBegin(GL_QUADS); - glTexCoord2i(0,0);glVertex2i( x_start,SCREEN_HEIGHT); - glTexCoord2i(1,0);glVertex2i(-x_start,SCREEN_HEIGHT); - glTexCoord2i(1,1);glVertex2i(-x_start,0); - glTexCoord2i(0,1);glVertex2i( x_start,0); + glTexCoord2i(0,0);glVertex2i( cx_start,SCREEN_HEIGHT); + glTexCoord2i(1,0);glVertex2i(-cx_start,SCREEN_HEIGHT); + glTexCoord2i(1,1);glVertex2i(-cx_start,0); + glTexCoord2i(0,1);glVertex2i( cx_start,0); glEnd(); bgTex->bindNext(); safeSetColorA(255,255,255,worldShade * 4); glBegin(GL_QUADS); - glTexCoord2i(0,0);glVertex2i( x_start,SCREEN_HEIGHT); - glTexCoord2i(1,0);glVertex2i(-x_start,SCREEN_HEIGHT); - glTexCoord2i(1,1);glVertex2i(-x_start,0); - glTexCoord2i(0,1);glVertex2i( x_start,0); + glTexCoord2i(0,0);glVertex2i( cx_start,SCREEN_HEIGHT); + glTexCoord2i(1,0);glVertex2i(-cx_start,SCREEN_HEIGHT); + glTexCoord2i(1,1);glVertex2i(-cx_start,0); + glTexCoord2i(0,1);glVertex2i( cx_start,0); glEnd(); glDisable(GL_TEXTURE_2D); @@ -399,10 +419,10 @@ void World::draw(Player *p){ glBegin(GL_QUADS); for(int i = 0; i <= width/1920; i++){ - glTexCoord2i(0,1);glVertex2i(width/-2+(1920*i )+offset.x*.85,GEN_MIN); - glTexCoord2i(1,1);glVertex2i(width/-2+(1920*(i+1))+offset.x*.85,GEN_MIN); - glTexCoord2i(1,0);glVertex2i(width/-2+(1920*(i+1))+offset.x*.85,GEN_MIN+1080); - glTexCoord2i(0,0);glVertex2i(width/-2+(1920*i )+offset.x*.85,GEN_MIN+1080); + glTexCoord2i(0,1);glVertex2i(width/-2+(1920*i )+offset.x*.85,base); + glTexCoord2i(1,1);glVertex2i(width/-2+(1920*(i+1))+offset.x*.85,base); + glTexCoord2i(1,0);glVertex2i(width/-2+(1920*(i+1))+offset.x*.85,base+1080); + glTexCoord2i(0,0);glVertex2i(width/-2+(1920*i )+offset.x*.85,base+1080); } glEnd(); @@ -415,11 +435,11 @@ void World::draw(Player *p){ safeSetColorA(bgDraw[i][0]-bgshade,bgDraw[i][0]-bgshade,bgDraw[i][0]-bgshade,bgDraw[i][1]); glBegin(GL_QUADS); - for(int j = x_start; j <= -x_start; j += 600){ - glTexCoord2i(0,1);glVertex2i( j +offset.x*bgDraw[i][2],GEN_MIN); - glTexCoord2i(1,1);glVertex2i((j+600)+offset.x*bgDraw[i][2],GEN_MIN); - glTexCoord2i(1,0);glVertex2i((j+600)+offset.x*bgDraw[i][2],GEN_MIN+400); - glTexCoord2i(0,0);glVertex2i( j +offset.x*bgDraw[i][2],GEN_MIN+400); + for(int j = cx_start; j <= -cx_start; j += 600){ + glTexCoord2i(0,1);glVertex2i( j +offset.x*bgDraw[i][2],base); + glTexCoord2i(1,1);glVertex2i((j+600)+offset.x*bgDraw[i][2],base); + glTexCoord2i(1,0);glVertex2i((j+600)+offset.x*bgDraw[i][2],base+400); + glTexCoord2i(0,0);glVertex2i( j +offset.x*bgDraw[i][2],base+400); } glEnd(); } @@ -500,9 +520,10 @@ LOOP2: */ for(auto &b : current->build){ - b->loc.y+=(yoff-DRAW_Y_OFFSET); + //b->loc.y+=(yoff-DRAW_Y_OFFSET); b->draw(); - b->loc.y-=(yoff-DRAW_Y_OFFSET); + //b->loc.y-=(yoff-DRAW_Y_OFFSET); + std::cout<<b->loc.x<<" "<<b->loc.y<<std::endl; } /* @@ -514,7 +535,7 @@ LOOP2: for(i=is;i<(unsigned)ie-GEN_INC;i++){ cline[i].y+=(yoff-DRAW_Y_OFFSET); // Add the y offset if(!cline[i].y){ - cline[i].y+=50; + cline[i].y=base; hey=true; safeSetColor(cline[i].color-100+shade,cline[i].color-150+shade,cline[i].color-200+shade); }else{ @@ -788,7 +809,12 @@ void World::singleDetect(Entity *e){ }else{ - if(e->vel.y > -2)e->vel.y-=.003 * deltaTime; + if(e->type == STRUCTURET && e->loc.y > 2000){ + e->loc.y = line[i].y; + e->vel.y = 0; + e->ground = true; + return; + }else if(e->vel.y > -2)e->vel.y-=.003 * deltaTime; } @@ -811,6 +837,7 @@ void World::singleDetect(Entity *e){ } void World::detect(Player *p){ + World *hey = this; /* * Handle the player. @@ -822,8 +849,13 @@ void World::detect(Player *p){ * Handle all remaining entities in this world. */ - for(auto &e : entity) - singleDetect(e); +LOOOOP: + for(auto &e : hey->entity) + hey->singleDetect(e); + if(hey->infront){ + hey = hey->infront; + goto LOOOOP; + } } void World::addStructure(_TYPE t,float x,float y,World *outside,World *inside){ @@ -834,18 +866,6 @@ void World::addStructure(_TYPE t,float x,float y,World *outside,World *inside){ entity.push_back(build.back()); } - -/*template<class T> -void World::getEntityLocation(std::vector<T*>&vecBuf, unsigned int n){ - T bufVar = vecBuf.at(n); - unsigned int i = 0; - for(auto &e : entity){ - if(entity.at(i) == bufVar){ - entity.erase(entity.begin()+i); - } - i++; - } -}*/ void World::addMob(int t,float x,float y){ mob.push_back(new Mob(t)); @@ -892,6 +912,9 @@ void World::addLayer(unsigned int width){ behind=new World(); behind->generate(width); behind->infront=this; + behind->star=star; + behind->bgmObj=bgmObj; + behind->bgTex=bgTex; } World *World::goWorldLeft(Player *p){ |