diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2015-12-17 09:25:22 -0500 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2015-12-17 09:25:22 -0500 |
commit | d9d66652af66fc824588176e5ce1136ea9965925 (patch) | |
tree | 0dd6d54ff2d63cd35e4c34e2e2f267573fb0d655 /src | |
parent | 15889a45b8ee37d43e248cec351e9f6882c21ff3 (diff) |
indoors, fixed npcs
Diffstat (limited to 'src')
-rw-r--r-- | src/entities.cpp | 8 | ||||
-rw-r--r-- | src/gameplay.cpp | 16 | ||||
-rw-r--r-- | src/world.cpp | 38 |
3 files changed, 38 insertions, 24 deletions
diff --git a/src/entities.cpp b/src/entities.cpp index ba0f8ef..7cd413c 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -77,7 +77,7 @@ void Entity::spawn(float x, float y){ //spawns the entity you pass to it based o Player::Player(){ //sets all of the player specific traits on object creation width = HLINE * 10; - height = HLINE * 16; + height = HLINE * 15; type = PLAYERT; //set type to player subtype = 0; @@ -393,7 +393,7 @@ void Object::interact(void){ * point to have non-normal traits so it could be invisible or invincible... */ -unsigned int Structures::spawn(_TYPE t, BUILD_SUB sub, float x, float y){ +unsigned int Structures::spawn(_TYPE t, BUILD_SUB sub, float x, float y, World *oi){ loc.x = x; loc.y = y; type = t; @@ -404,6 +404,8 @@ unsigned int Structures::spawn(_TYPE t, BUILD_SUB sub, float x, float y){ height = 40 * HLINE; bsubtype = sub; + inWorld = oi; + /* * tempN is the amount of entities that will be spawned in the village. Currently the village * will spawn bewteen 2 and 7 villagers for the starting hut. @@ -418,7 +420,7 @@ unsigned int Structures::spawn(_TYPE t, BUILD_SUB sub, float x, float y){ * with type NPC. */ - currentWorld->addNPC(loc.x + i * HLINE ,100); + inWorld->addNPC(loc.x + i * HLINE ,100); } diff --git a/src/gameplay.cpp b/src/gameplay.cpp index 35abca4..2361029 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -93,6 +93,8 @@ static World *worldSpawnHill1; static World *worldSpawnHill2; static World *worldSpawnHill3; +static IndoorWorld *worldSpawnHill2_Building1; + /* * initEverything() start */ @@ -119,7 +121,7 @@ void initEverything(void){ worldSpawnHill3->addMob(MS_TRIGGER,-500,0,worldSpawnHill3_itemGet); worldSpawnHill3->addMob(MS_TRIGGER,0,0,worldSpawnHill3_itemSee); worldSpawnHill3->addObject(TEST_ITEM,false,"",-200,300); - worldSpawnHill3->addMob(MS_TRIGGER,400,0,worldSpawnHill3_leave); + worldSpawnHill3->addMob(MS_TRIGGER,650,0,worldSpawnHill3_leave); worldSpawnHill3->addHole(800,1000); worldSpawnHill1->toRight = worldSpawnHill2; @@ -140,14 +142,18 @@ void initEverything(void){ //playerSpawnHill->addMob(MS_TRIGGER,-1300,0,CUTSCENEEE);*/ - currentWorld = worldSpawnHill1; - worldSpawnHill2->addStructure(STRUCTURET,HOUSE,(rand()%120*HLINE),100,worldSpawnHill1,worldSpawnHill2); + worldSpawnHill2_Building1 = new IndoorWorld(); + worldSpawnHill2_Building1->generate(300); + worldSpawnHill2_Building1->setBackground(BG_WOODHOUSE); + worldSpawnHill2_Building1->setBGM("assets/music/theme_jazz.wav"); + + worldSpawnHill2->addStructure(STRUCTURET,HOUSE,(rand()%120*HLINE),100,worldSpawnHill2_Building1); player = new Player(); player->spawn(200,100); - + + currentWorld = worldSpawnHill1; currentWorld->bgmPlay(NULL); - atexit(destroyEverything); } diff --git a/src/world.cpp b/src/world.cpp index d542f2a..7f9b1c0 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -555,7 +555,6 @@ LOOP2: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); //for the s direction glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); //for the t direction glBegin(GL_QUADS); - std::cout<<shade<<std::endl; for(i=is;i<(unsigned)ie-GEN_INC;i++){ cline[i].y+=(yoff-DRAW_Y_OFFSET); // Add the y offset if(!cline[i].y){ @@ -904,16 +903,17 @@ LOOOOP: goto LOOOOP; } } -void World::addStructure(_TYPE t,BUILD_SUB sub, float x,float y,World *outside,World *inside){ +void World::addStructure(_TYPE t,BUILD_SUB sub, float x,float y,World *inside){ build.push_back(new Structures()); - build.back()->spawn(t,sub,x,y); - build.back()->inWorld=outside; - build.back()->inside=(void *)inside; + build.back()->spawn(t,sub,x,y,this); + build.back()->inWorld=this; + build.back()->inside = (World *)inside; + ((IndoorWorld *)inside)->outside = this; entity.push_back(build.back()); } -void World::addVillage(int bCount, int npcMin, int npcMax,_TYPE t,float x,float y,World *outside,World *inside){ +void World::addVillage(int bCount, int npcMin, int npcMax,_TYPE t,float x,float y,World *outside){ std::cout << npcMin << ", " << npcMax << std::endl; int xwasd; for(int i = 0; i < bCount; i++){ @@ -922,7 +922,7 @@ void World::addVillage(int bCount, int npcMin, int npcMax,_TYPE t,float x,float for(auto &bu : build){ if(xwasd > bu->loc.x && xwasd < bu->loc.x+bu->width)goto HERE; } - addStructure(t,HOUSE,xwasd,y,outside,inside); + addStructure(t,HOUSE,xwasd,y,outside); } } void World::addMob(int t,float x,float y){ @@ -1095,7 +1095,8 @@ void IndoorWorld::generate(unsigned int width){ // Generates a flat area of wid void IndoorWorld::draw(Player *p){ unsigned int i,ie; - int j,x,v_offset; + //int j,x,v_offset; + int x; /* * Draw the background. @@ -1104,15 +1105,17 @@ void IndoorWorld::draw(Player *p){ glEnable(GL_TEXTURE_2D); bgTex->bind(0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); //for the s direction + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); //for the t direction glColor4ub(255,255,255,255); glBegin(GL_QUADS); - for(j = x_start - SCREEN_WIDTH / 2;j < -x_start + SCREEN_WIDTH / 2; j += 512){ - glTexCoord2i(1,1);glVertex2i(j ,0); - glTexCoord2i(0,1);glVertex2i(j+512,0); - glTexCoord2i(0,0);glVertex2i(j+512,512); - glTexCoord2i(1,0);glVertex2i(j ,512); - } + //for(j = x_start - SCREEN_WIDTH / 2;j < -x_start + SCREEN_WIDTH / 2; j += 512){ + glTexCoord2i(0,1); glVertex2i( x_start - SCREEN_WIDTH / 2,0); + glTexCoord2i((-x_start*2+SCREEN_WIDTH)/512,1);glVertex2i(-x_start + SCREEN_WIDTH / 2,0); + glTexCoord2i((-x_start*2+SCREEN_WIDTH)/512,0);glVertex2i(-x_start + SCREEN_WIDTH / 2,SCREEN_HEIGHT); + glTexCoord2i(0,0); glVertex2i( x_start - SCREEN_WIDTH / 2,SCREEN_HEIGHT); + //} glEnd(); glDisable(GL_TEXTURE_2D); @@ -1121,13 +1124,16 @@ void IndoorWorld::draw(Player *p){ * Calculate the starting and ending points to draw the ground from. */ - v_offset = (p->loc.x - x_start) / HLINE; + /*v_offset = (p->loc.x - x_start) / HLINE; j = v_offset - (SCREEN_WIDTH / 2 / HLINE) - GEN_INC; if(j < 0)j = 0; i = j; ie = v_offset + (SCREEN_WIDTH / 2 / HLINE) - GEN_INC; - if(ie > lineCount)ie = lineCount; + if(ie > lineCount)ie = lineCount;*/ + + i = 0; + ie = lineCount; /* * Draw the ground. |