]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
bug fixes
authorClyne Sullivan <tullivan99@gmail.com>
Mon, 22 Feb 2016 13:47:51 +0000 (08:47 -0500)
committerClyne Sullivan <tullivan99@gmail.com>
Mon, 22 Feb 2016 13:47:51 +0000 (08:47 -0500)
Changelog
include/ui.h
main.cpp
src/entities.cpp
src/world.cpp
xml/playerSpawnHill1.xml

index 0f4fdcfbf40bbb1a1369aefb5c821e4aee805cd4..f3839a8d7b4a6c3fb6ad420535ba0eb2b78e1324 100644 (file)
--- a/Changelog
+++ b/Changelog
 
        - made saving functionality for player coordinates, inventory, health and current world
        - addded structured villages
+
+2/22/2016:
+==========
+
+       - found weird memory leak bug with structure inits
+       - mob deaths are saved
+       - fixed building spawning
+       - volumes are better
+       
+       ~ 5 month Changelog anniversary!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
index ccc16af8f802b99b939ff40a2704d3e5deec20af..671a92c77f7aea8c552c30bd46a4c4a55c022918 100644 (file)
@@ -55,10 +55,10 @@ public:
        void gotoParent();
 };
 
-typedef uint8_t BYTE;
+typedef uint8_t  BYTE;
 typedef uint16_t WORD;
 typedef uint32_t DWORD;
-typedef int32_t LONG;
+typedef  int32_t LONG;
 
 typedef struct{
        WORD    bfType;
@@ -95,12 +95,14 @@ namespace ui {
        /*
         *      These flags are used elsewhere.
        */
-
+       
+       extern unsigned int fontSize;
+       
        extern bool debug;
        extern bool posFlag;
-       extern unsigned int fontSize;
-       extern bool                      dialogBoxExists;
+       
        extern unsigned char dialogOptChosen;
+       extern bool dialogBoxExists;
        extern bool dialogImportant;
 
        extern unsigned int textWrapLimit;
index 805fa000af09239faa37ba853071e4fdb3fe92ad..75bc0c384b53277cee5a596481854091d9c8a190 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -124,8 +124,6 @@ GLuint shaderProgram;
 GLuint colorIndex;
 GLuint mouseTex;
 
-Mix_Chunk *crickets;
-
 /*
  *     loops is used for texture animation. It is believed to be passed to entity
  *     draw functions, although it may be externally referenced instead.
@@ -170,27 +168,25 @@ void mainLoop(void);
 
 vec2 offset;                                                                                                                                                   /*      OFFSET!!!!!!!!!!!!!!!!!!!! */
 
-float shit = 0;
-Menu* currentMenu;
-Menu pauseMenu;
+Menu *currentMenu;
 Menu optionsMenu;
-
+Menu pauseMenu;
 
 extern WEATHER weather;
 
+extern int  fadeIntensity;
 extern bool fadeEnable;
 extern bool fadeWhite;
 extern bool fadeFast;
-extern int  fadeIntensity;
 
-unsigned int HLINE                = 3;
-unsigned int SCREEN_WIDTH  = 1280;
-unsigned int SCREEN_HEIGHT = 720;
-bool            FULLSCREEN    = false;
+unsigned int SCREEN_WIDTH;
+unsigned int SCREEN_HEIGHT;
+unsigned int HLINE;
+bool FULLSCREEN;
 
-float           VOLUME_MASTER = 50;
-float           VOLUME_MUSIC  = 25;
-float           VOLUME_SFX    = 25;
+float VOLUME_MASTER;
+float VOLUME_MUSIC;
+float VOLUME_SFX;
 
 /*******************************************************************************
  * MAIN ************************************************************************
index 71a0890aa9fae8f9ebed06913f539e8eed185bda..8c19bb0b7f96cc655715b280235f3c9159d524a3 100644 (file)
@@ -133,7 +133,7 @@ NPC::~NPC(){
 }
 
 Structures::Structures(){ //sets the structure type
-       health = maxHealth = 25;
+       health = maxHealth = 1;
        
        alive = false;
        near  = false;
@@ -450,6 +450,7 @@ unsigned int Structures::spawn(BUILD_SUB sub, float x, float y){
        type = STRUCTURET;
 
        alive = true;
+       canMove = false;
 
        bsubtype = sub;
        dim2 dim;
index 51efaf2a193c79acf80888d002947e25c60bcc4c..811ae5a8d197867d06a32376a806817d3ef7e26d 100644 (file)
@@ -95,18 +95,18 @@ void World::setStyle(const char* pre){
        for(uint i = 0; i < arrAmt(buildPaths);i++){
                sTexLoc.push_back(prefix);
                sTexLoc.back() += buildPaths[i];
-               std::cout << sTexLoc.back() << std::endl;
+               //std::cout << sTexLoc.back() << std::endl;
        }
        prefix += "bg/";
        for(uint i = 0; i < arrAmt(bgPaths[0]);i++){
                bgFiles.push_back(prefix);
                bgFiles.back() += bgPaths[0][i];
-               std::cout << bgFiles.back() << std::endl;
+               //std::cout << bgFiles.back() << std::endl;
        }
        for(uint i = 0; i < arrAmt(bgPaths[1]);i++){
                bgFilesIndoors.push_back(prefix);
                bgFilesIndoors.back() += bgPaths[1][i];
-               std::cout << bgFilesIndoors.back() << std::endl;
+               //std::cout << bgFilesIndoors.back() << std::endl;
        }
 }
 
@@ -336,10 +336,13 @@ void World::update(Player *p,unsigned int delta){
 
        for(auto &e : entity){
                e->loc.y += e->vel.y * delta;
+               
                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;
+          
                }
        }
 
@@ -372,7 +375,7 @@ void World::update(Player *p,unsigned int delta){
 }
 
 void World::setBGM(std::string path){
-       bgm = new char[path.size()];
+       bgm = new char[path.size() + 1];
        strcpy(bgm,path.c_str());
        bgmObj = Mix_LoadMUS(bgm);
 }
@@ -834,13 +837,13 @@ void World::singleDetect(Entity *e){
                                        break;
                                case MOBT:
                                        std::cout<<"Killed a mob..."<<std::endl;
-                                       for(j=0;j<mob.size();j++){
+                                       /*for(j=0;j<mob.size();j++){
                                                if(mob[j]==e){
                                                        delete mob[j];
                                                        mob.erase(mob.begin()+j);
                                                        break;
                                                }
-                                       }
+                                       }*/
                                        break;
                                case OBJECTT:
                                        std::cout<<"Killed an object..."<<std::endl;
@@ -936,7 +939,7 @@ void World::singleDetect(Entity *e){
                /*
                 *      Insure that the entity doesn't fall off either edge of the world.
                */
-               
+
                if(e->loc.x < x_start){                                                                                         // Left bound
                        
                        e->vel.x=0;
@@ -952,7 +955,6 @@ void World::singleDetect(Entity *e){
 }
 
 void World::detect(Player *p){
-       World *hey = this;
        
        /*
         *      Handle the player. 
@@ -964,10 +966,9 @@ void World::detect(Player *p){
         *      Handle all remaining entities in this world. 
        */
        
-//LOOOOP:
-       static int what = 0;
-       for(auto &e : hey->entity)
-               hey->singleDetect(e);
+       for(auto &e : entity)
+               singleDetect(e);
+               
        for(auto &part : particles){
                int l;
                unsigned int i;
@@ -983,12 +984,7 @@ void World::detect(Player *p){
                }else{
                        if(part->gravity && part->vely > -2)part->vely-=.003 * deltaTime;
                }
-               what++;
-       }what=0;
-       /*if(hey->infront){
-               hey = hey->infront;
-               goto LOOOOP;
-       }*/
+       }
 }
 void World::addStructure(BUILD_SUB sub, float x,float y, char *tex, const char *inside){
        build.push_back(new Structures());
@@ -1234,6 +1230,7 @@ void World::save(void){
        for(auto &m : mob){
                data.append(std::to_string((int)m->loc.x) + "\n");
                data.append(std::to_string((int)m->loc.y) + "\n");
+               data.append(std::to_string((int)m->alive) + "\n");
        }
        
        data.append("dOnE\0");
@@ -1287,6 +1284,9 @@ void World::load(void){
                std::getline(iss,line);
                if(line == "dOnE")return;
                m->loc.y = std::stoi(line);
+               std::getline(iss,line);
+               if(line == "dOnE")return;
+               m->alive = std::stoi(line);
        }
        
        while(std::getline(iss,line)){
@@ -1493,7 +1493,9 @@ World *loadWorldFromXMLNoSave(const char *path){
        const char *ptr,*name;
        
        unsigned int size = 5 + strlen(path);
-       
+
+       if(currentXML)
+               delete[] currentXML;
        memset((currentXML = new char[size]),0,size);
        strcpy(currentXML,"xml/");
        strcat(currentXML,path);
index c5e736b960df556e200c785357dc466b29475940..0c0fe4ccb24e5f9af0c27fee39df054a056d6d7c 100644 (file)
@@ -29,14 +29,9 @@ And it wasn't stormy.
                You should go talk to my friend Johnny. He's a pretty chill dude.
        </text>
        
-<<<<<<< HEAD
-       <text id="2" call="Johnny" callid="1">
-               what you have done it to trick Microsoft?
-=======
        <text id="2" >
                Niice.
                <quest check="Your First Quest" fail="3" />
->>>>>>> 3033594b89f23e65b6152daa6610f991307f2f67
        </text>
        
        <text id="3">