]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
Stuff
authordrumsetmonkey <abelleisle@roadrunner.com>
Wed, 3 Feb 2016 12:33:53 +0000 (07:33 -0500)
committerdrumsetmonkey <abelleisle@roadrunner.com>
Wed, 3 Feb 2016 12:33:53 +0000 (07:33 -0500)
include/SDL2/SDL_config.h
include/config.h
main.cpp
src/config.cpp
src/entities.cpp
src/gameplay.cpp
src/ui.cpp

index 78698281057fc186f054227ded64f3e321901cc3..1dec727c1116675d759aa912ca4e1814534bf1dc 100644 (file)
@@ -137,7 +137,7 @@ typedef unsigned int uintptr_t;
 #define HAVE_SCALBN 1\r
 #endif\r
 #if !defined(_MSC_VER) || defined(_USE_MATH_DEFINES)\r
-#define HAVE_M_PI 1\r
+//#define HAVE_M_PI 1\r
 #endif\r
 #else\r
 #define HAVE_STDARG_H   1\r
index af9d72e4fe58991be1e674cd6b635aa21b097b23..b63ae06f59d7a81d2ef4844b55aff3a7e6a19215 100644 (file)
@@ -9,4 +9,6 @@ void readConfig();
 
 void updateConfig();
 
+void saveConfig();
+
 #endif //CONFIG_H
\ No newline at end of file
index e80661279e7f7750ba484c7ddcd9838b015ccb7e..9d7f3e085f3c8a64e4162a8e563a71e217c4550f 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -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;
index 31ce5784f68be086f20729298c592fbee629657e..df15e058cdea699ed22906ea7237f21d90c10836 100644 (file)
@@ -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
index 4a8e6b76850674dea585aee2766e2d537c0f7af9..3e7c743242f30d01c89a36897d22c4121952357e 100644 (file)
@@ -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
index d9ae6b5bceb79eedcd375aec00788fae7d453fe0..f184a9f6e437c26ddd8332476c74cc2ed9b3df1a 100644 (file)
@@ -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"), );
index 2118022785b534024fabedf26430ceb21e0d030c..56ce6516e87a08249476348f81b397e31cdc9620 100644 (file)
@@ -640,6 +640,7 @@ namespace ui {
        void quitGame(){
                gameRunning = false;
                updateConfig();
+               saveConfig();
        }
 
        void quitMenu(){