diff options
-rw-r--r-- | include/SDL2/SDL_config.h | 2 | ||||
-rw-r--r-- | include/config.h | 2 | ||||
-rw-r--r-- | main.cpp | 73 | ||||
-rw-r--r-- | src/config.cpp | 15 | ||||
-rw-r--r-- | src/entities.cpp | 7 | ||||
-rw-r--r-- | src/gameplay.cpp | 10 | ||||
-rw-r--r-- | src/ui.cpp | 1 |
7 files changed, 27 insertions, 83 deletions
diff --git a/include/SDL2/SDL_config.h b/include/SDL2/SDL_config.h index 7869828..1dec727 100644 --- a/include/SDL2/SDL_config.h +++ b/include/SDL2/SDL_config.h @@ -137,7 +137,7 @@ typedef unsigned int uintptr_t; #define HAVE_SCALBN 1
#endif
#if !defined(_MSC_VER) || defined(_USE_MATH_DEFINES)
-#define HAVE_M_PI 1
+//#define HAVE_M_PI 1
#endif
#else
#define HAVE_STDARG_H 1
diff --git a/include/config.h b/include/config.h index af9d72e..b63ae06 100644 --- a/include/config.h +++ b/include/config.h @@ -9,4 +9,6 @@ void readConfig(); void updateConfig(); +void saveConfig(); + #endif //CONFIG_H
\ No newline at end of file @@ -469,7 +469,7 @@ void mainLoop(void){ currentTime = millis(); deltaTime = currentTime - prevTime; - if(currentMenu != NULL)goto MENU; + if(currentMenu)goto MENU; /* * Run the logic handler if MSEC_PER_TICK milliseconds have passed. @@ -610,10 +610,6 @@ void render(){ currentWorld->draw(player); - /* - * Apply shaders if desired. - */ - handAngle = atan((ui::mouse.y - (player->loc.y + player->height/2)) / (ui::mouse.x - player->loc.x + player->width/2))*180/PI; if(ui::mouse.x < player->loc.x){ if(handAngle <= 0) @@ -623,68 +619,6 @@ void render(){ } } if(ui::mouse.x > player->loc.x && ui::mouse.y < player->loc.y+player->height/2 && handAngle <= 0) handAngle = 360+handAngle; - //if(ui::mouse.x < player->loc.x + (player->width/2)){player->left = true;player->right=false;} - //if(ui::mouse.x >= player->loc.x + (player->width/2)){player->right = true;player->left=false;} - /*if(player->light){ - vec2 light; - int lightStr = 150; - vec2 curCoord; - - light.x = player->loc.x + player->width; - light.y = player->loc.y + player->height/2; - - std::vector<Ray>fray(60); - unsigned int a = 0; - float angle = 0; - - glColor3f(0.0f, 0.0f, 0.0f); - - for(auto &r : fray){ - r.start = light; - curCoord = r.start; - angle = .5*a + handAngle; - //for length - for(int l = 0;l<=lightStr;l++){ - //std::cout << a << ": " << curCoord.x << "," << curCoord.y << "\n"; - curCoord.x += float((HLINE) * cos(angle*PI/180)); - curCoord.y += float((HLINE) * sin(angle*PI/180)); - for(auto &en : currentWorld->entity){ - if(curCoord.x > en->loc.x && curCoord.x < en->loc.x + en->width && en->type!=STRUCTURET){ - if(curCoord.y > en->loc.y && curCoord .y < en->loc.y + en->height){ - r.end = curCoord; - l=lightStr; - } - } - } - if(curCoord.x > player->loc.x && curCoord.x < player->loc.x + player->width){ - if(curCoord.y > player->loc.y && curCoord .y < player->loc.y + player->height){ - r.end = curCoord; - l=lightStr; - } - }if(l==lightStr)r.end = curCoord; - }//end length - glBegin(GL_LINES); - glVertex2f(r.start.x,r.start.y); - glVertex2f(r.end.x, r.end.y); - glEnd(); - //std::cout << angle << "\n"; - a++; - } - - glUseProgramObjectARB(shaderProgram); - glUniform2f(glGetUniformLocation(shaderProgram, "lightLocation"), 640,300); - glUniform3f(glGetUniformLocation(shaderProgram, "lightColor"), 1,1,1); - glUniform1f(glGetUniformLocation(shaderProgram, "lightStrength"), 5); - glColor4f(1.0f, 1.0f, 1.0f, .5f); - for(unsigned int r = 0; r < fray.size(); r++){ - glBegin(GL_TRIANGLES); - glVertex2f(fray[r].start.x, fray[r].start.y); - glVertex2f(fray[r].end.x, fray[r].end.y); - r==fray.size()-1 ? glVertex2f(fray[r].end.x, fray[r].end.y) : glVertex2f(fray[r+1].end.x, fray[r+1].end.y); - glEnd(); - } - glUseProgramObjectARB(0); - }*/ player->inv->draw(); @@ -692,8 +626,6 @@ void render(){ /* * Here we draw a black overlay if it's been requested. */ - //glUseProgramObjectARB(0); - if(fadeIntensity){ if(fadeWhite) @@ -751,7 +683,7 @@ void render(){ } - if(currentMenu != NULL){ + if(currentMenu){ ui::drawMenu(currentMenu); } @@ -826,6 +758,7 @@ void logic(){ */ if(n->canMove) n->wander((rand() % 120 + 30)); + if(!player->inv->usingi) n->hit = false; if(player->inv->usingi && !n->hit && player->inv->detectCollision(vec2{n->loc.x, n->loc.y},vec2{n->loc.x+n->width,n->loc.y+n->height})){ n->health -= 25; diff --git a/src/config.cpp b/src/config.cpp index 31ce578..df15e05 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -11,10 +11,11 @@ extern float VOLUME_MASTER; extern float VOLUME_MUSIC; XMLDocument xml; +XMLElement *scr; +XMLElement *vol; + void readConfig(){ - XMLElement *scr; - XMLElement *vol; xml.LoadFile("config/settings.xml"); scr = xml.FirstChildElement("screen"); SCREEN_WIDTH = scr->UnsignedAttribute("width"); @@ -29,8 +30,14 @@ void readConfig(){ } void updateConfig(){ - XMLElement *vol = xml.FirstChildElement("volume")->FirstChildElement("master")->ToElement(); - vol->SetAttribute("volume",VOLUME_MASTER); + vol->FirstChildElement("master")->SetAttribute("volume",VOLUME_MASTER); + vol->FirstChildElement("music")->SetAttribute("volume",VOLUME_MUSIC); + Mix_Volume(0,VOLUME_MASTER); + Mix_VolumeMusic(VOLUME_MUSIC); + +} + +void saveConfig(){ xml.SaveFile("config/settings.xml", false); }
\ No newline at end of file diff --git a/src/entities.cpp b/src/entities.cpp index 4a8e6b7..3e7c743 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -20,7 +20,7 @@ std::string sTexLoc[] = { "assets/townhall.png", "assets/house1.png", "assets/fountain1.png", "assets/lampPost1.png", - "assets/brazzier.png"}; + "assets/brazier.png"}; GLuint waterTex; @@ -43,7 +43,7 @@ void getRandomName(Entity *e){ tempNum = rand() % max; names.seekg(0,names.beg); - + for(unsigned int i=0;i<tempNum;i++) names.getline(bufs,32); @@ -420,7 +420,8 @@ const char *randomDialog[] = { "You know, if anyone ever asked me who I wanted to be when I grow up, I would say Abby Ross.", "I want to have the wallpaper in our house changed. It doesn\'t really fit the environment.", "Frig.", - "The sine of theta equals the opposite over the hypotenuese." + "The sine of theta equals the opposite over the hypotenuese.", + "Did you know the developers spelt brazier as brazzier." }; void NPC::interact(){ //have the npc's interact back to the player diff --git a/src/gameplay.cpp b/src/gameplay.cpp index d9ae6b5..f184a9f 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -225,15 +225,15 @@ void initEverything(void){ atexit(destroyEverything); std::cout << "Hey"; - pauseMenu.items.push_back(ui::createParentButton({-256/2,0},{256,75},{0.0f,0.0f,0.0f}, (const char*)("Resume"))); - pauseMenu.items.push_back(ui::createChildButton({-256/2,-100},{256,75},{0.0f,0.0f,0.0f}, (const char*)("Options"))); - pauseMenu.items.push_back(ui::createButton({-256/2,-200},{256,75},{0.0f,0.0f,0.0f}, (const char*)("Save and Quit"), ui::quitGame)); - pauseMenu.items.push_back(ui::createButton({-256/2,-300},{256,75},{0.0f,0.0f,0.0f}, (const char*)("Segfault"), segFault)); + pauseMenu.items.push_back(ui::createParentButton({-256/2,0},{256,75},{0.0f,0.0f,0.0f}, "Resume")); + pauseMenu.items.push_back(ui::createChildButton({-256/2,-100},{256,75},{0.0f,0.0f,0.0f}, "Options")); + pauseMenu.items.push_back(ui::createButton({-256/2,-200},{256,75},{0.0f,0.0f,0.0f}, "Save and Quit", ui::quitGame)); + pauseMenu.items.push_back(ui::createButton({-256/2,-300},{256,75},{0.0f,0.0f,0.0f}, "Segfault", segFault)); pauseMenu.child = &optionsMenu; pauseMenu.parent = NULL; - optionsMenu.items.push_back(ui::createSlider({-512/2,100}, {512,50}, {0.0f, 0.0f, 0.0f}, 0, 100, (const char*)("Shit"), &VOLUME_MASTER)); + optionsMenu.items.push_back(ui::createSlider({-512/2,100}, {512,50}, {0.0f, 0.0f, 0.0f}, 0, 100, "Shit", &VOLUME_MASTER)); optionsMenu.child = NULL; optionsMenu.parent = &pauseMenu; // optionsMenu.push_back(ui::createButton({-256/2,-200},{256,75},{0.0f,0.0f,0.0f}, (const char*)("Save and Quit"), ); @@ -640,6 +640,7 @@ namespace ui { void quitGame(){ gameRunning = false; updateConfig(); + saveConfig(); } void quitMenu(){ |