]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
indoors, fixed npcs
authorClyne Sullivan <tullivan99@gmail.com>
Thu, 17 Dec 2015 14:25:22 +0000 (09:25 -0500)
committerClyne Sullivan <tullivan99@gmail.com>
Thu, 17 Dec 2015 14:25:22 +0000 (09:25 -0500)
12 files changed:
Changelog
assets/bgWoodTile.png
assets/maybeplayer.png
assets/sounds/ozone.wav [deleted file]
include/entities.h
include/world.h
main.cpp
src/entities.cpp
src/gameplay.cpp
src/world.cpp
xcf/bgWoodTile.xcf
xcf/maybeplayer.xcf

index f6f3ca0f8c09cd3675f92a741994d1a767862751..6d5fa3b7c5a9f64e43a4fd56d3ddf91e468d09ac 100644 (file)
--- a/Changelog
+++ b/Changelog
        - checking files for potential divide by 0 errors, due to random floating point errors
                still have floating point errors
        - restarted work on real shading (GLSL stuffs)
+
+12/17/2015:
+===========
+
+       - continued work on player sprite
+       - continued work on GLSL shaders
+       - fixed NPC spawning world location stuff
+       - messed with threads/forks
+       - re-fixed/added indoor environment; fixed indoor background
index 0c7c64bc5d26f2c59c24ff92accbd7023839c743..5b631bfbecb53de73c0393d7fbe6ef94b741b56a 100644 (file)
Binary files a/assets/bgWoodTile.png and b/assets/bgWoodTile.png differ
index ee0e49dba0e08d04605be074245bf039267fdcb2..c580ff73ef4c18392a969200ed75343ded3c7aef 100644 (file)
Binary files a/assets/maybeplayer.png and b/assets/maybeplayer.png differ
diff --git a/assets/sounds/ozone.wav b/assets/sounds/ozone.wav
deleted file mode 100644 (file)
index 60354e5..0000000
Binary files a/assets/sounds/ozone.wav and /dev/null differ
index 1abe8862c000f405d61224077153ed88ddb1032d..6d192fe2b66a89328db183d55ac2fb10da12794d 100644 (file)
@@ -44,6 +44,8 @@ enum BUILD_SUB{
        FOUNTAIN
 };
 
+class World;
+
 class Particles{
 public:
        vec2 loc;
@@ -162,14 +164,14 @@ public:
 
 class Structures : public Entity{
 public:
-       void *inWorld;
-       void *inside;
+       World *inWorld;
+       World *inside;
        BUILD_SUB bsubtype;
        
        Structures();
        ~Structures();
        
-       unsigned int spawn(_TYPE, BUILD_SUB, float, float);
+       unsigned int spawn(_TYPE, BUILD_SUB, float, float, World *);
 };
 
 class Mob : public Entity{
index 0a2396562f716d0f24c1ee82c1cef0f3a9ca51b5..4b3a8918c7200fe1f83b8041beb1127d94825bbd 100644 (file)
@@ -166,8 +166,8 @@ public:
        std::vector<Object              *>      object;
        std::vector<Particles   *>      particles;
        
-       void addStructure(_TYPE t,BUILD_SUB sub,float x,float y,World *outside,World *inside);
-       void addVillage(int bCount, int npcMin, int npcMax,_TYPE t,float x,float y,World *outside,World *inside);
+       void addStructure(_TYPE t,BUILD_SUB sub,float x,float y,World *inside);
+       void addVillage(int bCount, int npcMin, int npcMax,_TYPE t,float x,float y,World *outside);
        void addMob(int t,float x,float y);
        void addMob(int t,float x,float y,void (*hey)(Mob *));
        void addNPC(float x,float y);
index 8e154fbef293fdb65b65d5ce0a4ffe1d0afe27a8..0651077ce1432764f9acfd1d5cc0ebcea1768b55 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -4,6 +4,7 @@
 */
 
 #include <cstdio> // fopen
+#include <thread>
 
 #include <common.h>
 #include <world.h>
@@ -453,7 +454,7 @@ void mainLoop(void){
        
        if(!currentTime){                                               // Initialize currentTime if it hasn't been
                currentTime=millis();
-               prevPrevTime=currentTime;
+               //prevPrevTime=currentTime;
        }       
        
        /*
index ba0f8efc86107f892a174353d3c0cf9e0ea16631..7cd413c8dc00f2b6089ea5f32c9b02a7fff6f0b7 100644 (file)
@@ -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);
                
        }
 
index 35abca408c1a536e0dd3222e935b3bf48a79cd1f..2361029a21811a2c5edd01f1b2db67340bc5470f 100644 (file)
@@ -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);
 }
 
index d542f2ae2d571a947a79226704901859f9cb0e1b..7f9b1c0117855559877105abeda6f2c0b4eeffd5 100644 (file)
@@ -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.
index 9aa00051082fa80c4cc9145e6d2b7d0807e18028..867e556c0a3b0e3125823a02ae2a52353a3e8ba3 100644 (file)
Binary files a/xcf/bgWoodTile.xcf and b/xcf/bgWoodTile.xcf differ
index fb885fc1f914471fcfe966b23f9a05986bb979ec..c16b7c600ac066732e3300f120ec833af652b174 100644 (file)
Binary files a/xcf/maybeplayer.xcf and b/xcf/maybeplayer.xcf differ