aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordrumsetmonkey <abelleisle@roadrunner.com>2016-02-22 16:39:11 -0500
committerdrumsetmonkey <abelleisle@roadrunner.com>2016-02-22 16:39:11 -0500
commitd1ee9a1b4b4d02b564b554a30314a97c1982da22 (patch)
treea1e9348f59ac080a03d53f7c6b3949dd1acf690a
parentca1574c0dd3baf85a95b804a73a5101f77ad8261 (diff)
parent28539cb9804a2bda8a7d94ec078b1b60ac3ded06 (diff)
Merge branch 'master' of http://github.com/tcsullivan/gamedev
-rw-r--r--Changelog10
-rw-r--r--include/ui.h12
-rw-r--r--main.cpp24
-rw-r--r--src/entities.cpp3
-rw-r--r--src/world.cpp40
5 files changed, 50 insertions, 39 deletions
diff --git a/Changelog b/Changelog
index 0f4fdcf..f3839a8 100644
--- a/Changelog
+++ b/Changelog
@@ -665,3 +665,13 @@
- 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!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
diff --git a/include/ui.h b/include/ui.h
index ccc16af..671a92c 100644
--- a/include/ui.h
+++ b/include/ui.h
@@ -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;
diff --git a/main.cpp b/main.cpp
index cf277cb..4f6e4ab 100644
--- 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 ************************************************************************
diff --git a/src/entities.cpp b/src/entities.cpp
index 71a0890..8c19bb0 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -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;
diff --git a/src/world.cpp b/src/world.cpp
index a2758fa..0b1af33 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -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);