]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
new dirt
authorClyne Sullivan <tullivan99@gmail.com>
Wed, 16 Dec 2015 13:48:51 +0000 (08:48 -0500)
committerClyne Sullivan <tullivan99@gmail.com>
Wed, 16 Dec 2015 13:48:51 +0000 (08:48 -0500)
Changelog
assets/dirt.png
assets/sounds/ozone.wav [new file with mode: 0644]
main.cpp
src/entities.cpp
src/gameplay.cpp
src/inventory.cpp
src/world.cpp
xcf/dirt.xcf

index d1fac717a36c823fb98f548a7168259c6867f533..f6f3ca0f8c09cd3675f92a741994d1a767862751 100644 (file)
--- a/Changelog
+++ b/Changelog
 
        - began/continued work on original player sprite
        - began working on dirt textures
+
+12/16/2015:
+===========
+
+       - added more soundtracks
+       - completed dirt texturizing, improved ground shading
+       - checking files for potential divide by 0 errors, due to random floating point errors
+               still have floating point errors
+       - restarted work on real shading (GLSL stuffs)
index 04c87b676db1ec49d6b863878324b8fef6463ecd..11252ac8db258588ddcbe594428e03f15dc3ba57 100644 (file)
Binary files a/assets/dirt.png and b/assets/dirt.png differ
diff --git a/assets/sounds/ozone.wav b/assets/sounds/ozone.wav
new file mode 100644 (file)
index 0000000..60354e5
Binary files /dev/null and b/assets/sounds/ozone.wav differ
index a9cc2fa969f484dfc37332da7ea7d4f84ee4e3a6..8e154fbef293fdb65b65d5ce0a4ffe1d0afe27a8 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -494,7 +494,8 @@ void mainLoop(void){
        if(++debugDiv==20){
                debugDiv=0;
                
-               fps=1000/deltaTime;
+               if(deltaTime)
+                       fps=1000/deltaTime;
        }else if(!(debugDiv%10)){
                debugY = player->loc.y;
        }
index 7ebe7447f1387260014d1500ff1fe759aa948dd7..ba0f8efc86107f892a174353d3c0cf9e0ea16631 100644 (file)
@@ -107,7 +107,7 @@ NPC::NPC(){ //sets all of the NPC specific traits on object creation
        tex = new Texturec(1,"assets/NPC.png");
        inv = new Inventory(NPC_INV_SIZE);
        
-       randDialog = rand() % 10 - 1;
+       randDialog = rand() % 12 - 1;
 }
 NPC::~NPC(){
        while(!aiFunc.empty()){
@@ -218,7 +218,7 @@ void Entity::draw(void){            //draws the entities
        case PLAYERT:
                static int texState = 0;
                static bool up = true;
-               if(loops % (int)((float)4/(float)speed) == 0){
+               if(speed && !(loops % (int)(4.0f/(float)speed))){
                        //currentWorld->addParticle(loc.x,loc.y-HLINE,HLINE,HLINE,0,0,{0.0f,.17f,0.0f},1000);
                        if(up){
                                if(++texState==2)up=false;
@@ -343,7 +343,8 @@ const char *randomDialog[] = {
        "HELP MY CAPS LOCK IS STUCK",
        "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."
+       "Frig.",
+       "The sine of theta equals the opposite over the hypotenuese."
 };
 
 void NPC::interact(){ //have the npc's interact back to the player
index 6cfc91eed7466579ceb078af4d7a1fba1542098c..35abca408c1a536e0dd3222e935b3bf48a79cd1f 100644 (file)
@@ -109,13 +109,13 @@ void initEverything(void){
        worldSpawnHill2 = new World();
        worldSpawnHill2->generate(700);
        worldSpawnHill2->setBackground(BG_FOREST);
-       worldSpawnHill2->setBGM("assets/music/embark.wav");
+       worldSpawnHill2->setBGM("assets/music/ozone.wav");
        worldSpawnHill2->addMob(MS_TRIGGER,-400,0,worldSpawnHill2_infoSprint);
 
        worldSpawnHill3 = new World();
        worldSpawnHill3->generateFunc(1000,gen_worldSpawnHill3);
        worldSpawnHill3->setBackground(BG_FOREST);
-       worldSpawnHill3->setBGM("assets/music/embark.wav");
+       worldSpawnHill3->setBGM("assets/music/ozone.wav");
        worldSpawnHill3->addMob(MS_TRIGGER,-500,0,worldSpawnHill3_itemGet);
        worldSpawnHill3->addMob(MS_TRIGGER,0,0,worldSpawnHill3_itemSee);
        worldSpawnHill3->addObject(TEST_ITEM,false,"",-200,300);
index 52ae02cb739d28a597799c957e546da21c7e3b2a..c0f416333a2ebc2f54c1fbf264f319837d704e7f 100644 (file)
@@ -107,7 +107,7 @@ int Inventory::takeItem(ITEM_ID id,unsigned char count){
 
 void Inventory::draw(void){
        static unsigned int lop = 0;
-       static unsigned int numSlot = 7;
+       const unsigned int numSlot = 7;
        static std::vector<int>dfp(numSlot);
        static std::vector<Ray>iray(numSlot);
        static std::vector<vec2>curCoord(numSlot);
@@ -153,7 +153,7 @@ void Inventory::draw(void){
                        curCoord[a].y += float((dfp[a]) * sin(angle*PI/180));
                        r.end = curCoord[a];
 
-                       glColor4f(0.0f, 0.0f, 0.0f, ((float)dfp[a]/(float)range)*0.5f);
+                       glColor4f(0.0f, 0.0f, 0.0f, ((float)dfp[a]/(float)(range?range:1))*0.5f);
                        glBegin(GL_QUADS);
                                glVertex2i(r.end.x-(itemWide/2),                        r.end.y-(itemWide/2));
                                glVertex2i(r.end.x-(itemWide/2)+itemWide,       r.end.y-(itemWide/2));
@@ -164,7 +164,7 @@ void Inventory::draw(void){
                        if(inv[a].count > 0){
                                glEnable(GL_TEXTURE_2D);
                                glBindTexture(GL_TEXTURE_2D, itemtex[inv[a].id]);                       
-                               glColor4f(1.0f, 1.0f, 1.0f, ((float)dfp[a]/(float)range)*0.8f);
+                               glColor4f(1.0f, 1.0f, 1.0f, ((float)dfp[a]/(float)(range?range:1))*0.8f);
                                glBegin(GL_QUADS);
                                        if(item[inv[a].id].height > item[inv[a].id].width){
                                                glTexCoord2i(0,1);glVertex2i(r.end.x-((itemWide/2)*((float)item[inv[a].id].width/(float)item[inv[a].id].height)),       r.end.y-(itemWide/2));
@@ -203,7 +203,7 @@ void Inventory::draw(void){
                        mouseSel=true;
                }else{
                        if((ui::mouse.x - offset.x) >= mouseStart.x){
-                               thing = ((ui::mouse.x - offset.x) - mouseStart.x)/80;
+                               thing = (ui::mouse.x - offset.x - mouseStart.x)/80;
                                highlight=sel+thing;
                                if(highlight>numSlot-1)highlight=numSlot-1;
                                if(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT)){
index 9a2b6d376d1f9bbe404a74298eae5ea22a8d0d74..d542f2ae2d571a947a79226704901859f9cb0e1b 100644 (file)
@@ -207,7 +207,7 @@ void World::generate(unsigned int width){   // Generates the world and sets all va
                 *      by setting an RGB value of color (red), color - 50 (green), color - 100 (blue).
                */
                
-               line[i].color = rand() % 20 + 100; // 100 to 120
+               line[i].color = rand() % 32 / 8; // 100 to 120
 
                /*
                 *      Each line has two 'blades' of grass, here we generate random heights for them.
@@ -551,24 +551,23 @@ LOOP2:
 
        bool hey=false;
        glEnable(GL_TEXTURE_2D);
+       bgTex->bindNext();
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); //for the s direction
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); //for the t direction
-       bgTex->bindNext();
        glBegin(GL_QUADS);
+               std::cout<<shade<<std::endl;
                for(i=is;i<(unsigned)ie-GEN_INC;i++){
                        cline[i].y+=(yoff-DRAW_Y_OFFSET);                                                                                                                       // Add the y offset
                        if(!cline[i].y){
                                cline[i].y=base;
                                hey=true;
-                               //safeSetColor(cline[i].color-100+shade,cline[i].color-150+shade,cline[i].color-200+shade);
-                       }else{
-                               //safeSetColor(cline[i].color+shade,cline[i].color-50+shade,cline[i].color-100+shade);  // Set the shaded dirt color
-                       }
-                       glColor4ub(255,255,255,255);
-                       glTexCoord2i(0,1);glVertex2i(cx_start+i*HLINE      ,cline[i].y-GRASS_HEIGHT);
-                       glTexCoord2i(1,1);glVertex2i(cx_start+i*HLINE+HLINE,cline[i].y-GRASS_HEIGHT);
-                       glTexCoord2i(1,0);glVertex2i(cx_start+i*HLINE+HLINE,0);
-                       glTexCoord2i(0,0);glVertex2i(cx_start+i*HLINE      ,0);
+                               glColor4ub(0,0,0,255);
+                       }else
+                               safeSetColorA(150+shade*2,150+shade*2,150+shade*2,255);
+                       glTexCoord2i(0,0);glVertex2i(cx_start+i*HLINE      ,cline[i].y-GRASS_HEIGHT);
+                       glTexCoord2i(1,0);glVertex2i(cx_start+i*HLINE+HLINE,cline[i].y-GRASS_HEIGHT);
+                       glTexCoord2i(1,(int)(cline[i].y/64)+cline[i].color);glVertex2i(cx_start+i*HLINE+HLINE,0);
+                       glTexCoord2i(0,(int)(cline[i].y/64)+cline[i].color);glVertex2i(cx_start+i*HLINE    ,0);
                        cline[i].y-=(yoff-DRAW_Y_OFFSET);                                                                                                                       // Restore the line's y value
                        if(hey){
                                hey=false;
@@ -610,7 +609,7 @@ LOOP2:
                        
                        cline[i].y+=(yoff-DRAW_Y_OFFSET);
                        
-                       safeSetColor(shade,150+shade,shade);
+                       safeSetColor(shade,100+shade*1.5,shade);
                        
                        glVertex2i(cx_start+i*HLINE        ,cline[i].y+cgh[0]);
                        glVertex2i(cx_start+i*HLINE+HLINE/2,cline[i].y+cgh[0]);
index 6b5098131837b28fa99caf3174b7b83e5080c464..27a6e8f1df1925ea30e8e7650c88f91cba88edb2 100644 (file)
Binary files a/xcf/dirt.xcf and b/xcf/dirt.xcf differ