]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
merge, particles
authorClyne Sullivan <tullivan99@gmail.com>
Wed, 20 Jan 2016 13:47:05 +0000 (08:47 -0500)
committerClyne Sullivan <tullivan99@gmail.com>
Wed, 20 Jan 2016 13:47:05 +0000 (08:47 -0500)
1  2 
Changelog
include/Texture.h
include/common.h
include/entities.h
main.cpp
src/Texture.cpp
src/entities.cpp
src/ui.cpp

diff --cc Changelog
index 8b01fe75163d7b15e41a154c2f1a1c4e01bb57f2,a4c3ede6639f47d50e6f94d3a7999d7862634f02..b88ebe44528b5a9e6629335b09e17237337b68ce
+++ b/Changelog
        - removed layers
        - switched world linking from pointers to file names, rewrote all world-linking code
        - worlds are now loaded dynamically
 +
 +1/19/2015:
 +==========
 +
 +      - memory management
 +      - began reconsidering save/load stuff
++
++1/20/2015:
++==========
++
++      - can save npc dialog positions
++      - worked on player sprite redesign
++      - greatly simplified/documented gameplay.cpp
index 03593bf6745419d945cb51836983e0e0cba3c508,7160d37886665f737fd8ad732532599b1fb3ab5f..50681bfa8c1590c0718f02ee52e56ea842c09a78
@@@ -28,8 -28,8 +28,11 @@@ namespace Texture
         */
        
        GLuint loadTexture(const char *fileName);
 +      
 +      void freeTextures(void);
++      
+       void initColorIndex();
+       vec2 getIndex(Color c);
  }
  
  /**
Simple merge
Simple merge
diff --cc main.cpp
Simple merge
diff --cc src/Texture.cpp
index 0dd1efffe31d412ff835257a82a1e542f74afea9,f688327b81e33f3ba2fdfea46f15822dd8f96882..4418a3bbf78b625f5e93a629b064f1fff0dd2cb0
@@@ -63,13 -70,65 +70,73 @@@ namespace Texture
                
                return object;
        }
 -                                      std::cout << pixels[y][x].red << "," << pixels[y][x].green << "," << pixels[y][x].blue << std::endl;
++      
 +      void freeTextures(void){
 +              for(unsigned int i=0;i<LoadedTextureCounter;i++){
 +                      glDeleteTextures(1,&LoadedTexture[i]->tex);
 +                      delete[] LoadedTexture[i]->name;
 +                      delete LoadedTexture[i];
 +              }
 +      }
+       void initColorIndex(){
+               colorIndex = loadTexture("assets/colorIndex.png");
+               glActiveTexture(GL_TEXTURE0);
+               glBindTexture(GL_TEXTURE_2D, colorIndex);
+               GLubyte* buffer = new GLubyte[8*4*3];
+               glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, buffer);
+               GLfloat* bufferf = new GLfloat[8*4*3];
+               for(uint iu = 0; iu < 8*4*3; iu++){
+                       bufferf[iu] = float(buffer[iu]) / 255.0f;
+               }
+               uint i = 0;
+               for(uint y = 0; y < 8; y++){
+                       for(uint x = 0; x < 4; x++){
+                                       if(i >= 8*4*3){
+                                               return;
+                                       }
+                                       pixels[y][x].red = buffer[i++];
+                                       pixels[y][x].green = buffer[i++];
+                                       pixels[y][x].blue = buffer[i++];
 -                              std::cout << y << "," << x << ":" << pixels[y][x].red << "," << pixels[y][x].green << "," << pixels[y][x].blue << std::endl;
++                                      //std::cout << pixels[y][x].red << "," << pixels[y][x].green << "," << pixels[y][x].blue << std::endl;
+                               //std::cout << std::endl;
+                       }
+               }
+       }
+       //sqrt((255-145)^2+(90-145)^2+(0-0)^2);
+       std::vector<index_t>ind;
+       vec2 getIndex(Color c){
+               for(auto &i : ind){
+                       if(c.red == i.color.red && c.green == i.color.green && c.blue == i.color.blue){
+                               //std::cout << float(i.indexy) << "," << float(i.indexx) << std::endl;
+                               return {float(i.indexx), float(i.indexy)};
+                       }
+               }
+               uint buf[2];
+               float buff = 999;
+               float shit = 999;
+               for(uint y = 0; y < 8; y++){
+                       for(uint x = 0; x < 4; x++){
 -              std::cout << float(buf[1]) << ", " << float(buf[0]) << std::endl;
++                              //std::cout << y << "," << x << ":" << pixels[y][x].red << "," << pixels[y][x].green << "," << pixels[y][x].blue << std::endl;
+                               buff = sqrt(pow((pixels[y][x].red-      c.red),  2)+
+                                                       pow((pixels[y][x].green-c.green),2)+
+                                                       pow((pixels[y][x].blue- c.blue), 2));
+                               //std::cout << buff << std::endl;
+                               if(buff < shit){
+                                       shit = buff;
+                                       buf[0] = y;
+                                       buf[1] = x;
+                               }
+                               //
+                               //std::cout << shit << std::endl;
+                       }
+               }
+               ind.push_back({c, (int)buf[1], (int)buf[0]});
++              //std::cout << float(buf[1]) << ", " << float(buf[0]) << std::endl;
+               return {float(buf[1]),float(buf[0])};
+       }
  }
  
  Texturec::Texturec(uint amt, ...){
Simple merge
diff --cc src/ui.cpp
Simple merge