]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
Fixed white outline around textures :)
authordrumsetmonkey <abelleisle@roadrunner.com>
Fri, 4 Dec 2015 14:20:36 +0000 (09:20 -0500)
committerdrumsetmonkey <abelleisle@roadrunner.com>
Fri, 4 Dec 2015 14:20:36 +0000 (09:20 -0500)
1  2 
assets/house1.png
assets/items/SWORD_WOOD.png
assets/player.png
assets/player1.png
assets/player2.png
main.cpp
src/entities.cpp
src/inventory.cpp
src/ui.cpp

index 2022992a8d3acbbe925b395c8f40c2a3e3cbf587,2022992a8d3acbbe925b395c8f40c2a3e3cbf587..ce97a810d2e11a47e8c0876fd6239e8e1476232a
Binary files differ
index a6d3af32da65194a79d7e1d18e4f9467c7605ed0,0000000000000000000000000000000000000000..479eba9f9cf35edfaab8185a1a4ab79a6f64c41e
mode 100644,000000..100644
Binary files differ
index cfc327cb4b7e7b9608a52daaa5e4c1b701e4fcae,88819801d863cdeab1d28efa8629847d075b1497..39770927fb6703b0f644e8b18c1d93303fdc6012
Binary files differ
index 8204252bd8d602a76aed25b795ba422fbf9e9ca3,33e68f2d1fef7a668283ef3f083ab279035be744..edf8bf8f10bcf3bf492bcbf207d6c175a735f584
Binary files differ
index 63f4c08fa812dea612f366559d1aa56ce657ac21,20e679b647796bb5de34069f6896d12e40cbc643..cfd955f48cf89097c4fb3294c411e2ad4cc16d9f
Binary files differ
diff --cc main.cpp
index 11fc181d51595f59f32e1d5ec4592c0264530623,2203465f3e87869fc9c00ae253743edc8fb4b0dc..1fb5cb1388b4bea6a81addc318ffc25d749ed5cd
+++ b/main.cpp
@@@ -212,8 -212,10 +212,9 @@@ static unsigned int fadeIntensity = 0
   * MAIN ************************************************************************
   *******************************************************************************/
  
 -int main(int argc, char *argv[]){
 -      *argv = (char *)argc;
 +int main(/*int argc, char *argv[]*/){
++      //*argv = (char *)argc;
        gameRunning=false;
 -
        /*!
         *      (Attempt to) Initialize SDL libraries so that we can use SDL facilities and eventually
         *      make openGL calls. Exit if there was an error.
index b1a0c0956dca784b244feef82a80a4523a73e491,729bcdd37079bbcc2a43f0ba65e71376928afa84..f81291999b44584686ee2548eb2aa812f5f59d26
@@@ -205,7 -205,7 +205,7 @@@ void Entity::draw(void){           //draws the e
        if(type == PLAYERT){
                static int texState = 0;
                static bool up = true;
--              if(loops % (int)((float)5 / (float)speed) == 0){
++              if(loops % (int)((float)2 / (float)speed) == 0){
                        if(up){
                                texState+=1;
                                if(texState==2)up=false;
index e6433bbda54d9076c7e874f7d4b984151d3662b5,310a6b5ef6c1e3b03b35cd594b90d8ae2e3893cb..7d3bc6d285270c7a10a576322a86d14bcf681c38
@@@ -148,7 -140,7 +148,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.4f);
++                      glColor4f(1.0f, 1.0f, 1.0f, ((float)dfp[a]/(float)range)*0.4f);
                        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));
                                glBindTexture(GL_TEXTURE_2D, itemtex[inv[a].id]);                       
                                glColor4f(1.0f, 1.0f, 1.0f, ((float)dfp[a]/(float)range)*0.8f);
                                glBegin(GL_QUADS);
--                                      glTexCoord2i(0,1);glVertex2i(r.end.x-(itemWide/2),                      r.end.y-(itemWide/2));
--                                      glTexCoord2i(1,1);glVertex2i(r.end.x-(itemWide/2)+itemWide,     r.end.y-(itemWide/2));
--                                      glTexCoord2i(1,0);glVertex2i(r.end.x-(itemWide/2)+itemWide,     r.end.y-(itemWide/2)+itemWide);
--                                      glTexCoord2i(0,0);glVertex2i(r.end.x-(itemWide/2),                      r.end.y-(itemWide/2)+itemWide);
--                              glEnd();
++                                      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));
++                                              glTexCoord2i(1,1);glVertex2i(r.end.x+((itemWide/2)*((float)item[inv[a].id].width/(float)item[inv[a].id].height)),       r.end.y-(itemWide/2));
++                                              glTexCoord2i(1,0);glVertex2i(r.end.x+((itemWide/2)*((float)item[inv[a].id].width/(float)item[inv[a].id].height)),       r.end.y+(itemWide/2));
++                                              glTexCoord2i(0,0);glVertex2i(r.end.x-((itemWide/2)*((float)item[inv[a].id].width/(float)item[inv[a].id].height)),       r.end.y+(itemWide/2));
++                                      }else{
++                                              glTexCoord2i(0,1);glVertex2i(r.end.x-(itemWide/2),      r.end.y-(itemWide/2)*((float)item[inv[a].id].height/(float)item[inv[a].id].width));
++                                              glTexCoord2i(1,1);glVertex2i(r.end.x+(itemWide/2),      r.end.y-(itemWide/2)*((float)item[inv[a].id].height/(float)item[inv[a].id].width));
++                                              glTexCoord2i(1,0);glVertex2i(r.end.x+(itemWide/2),      r.end.y+(itemWide/2)*((float)item[inv[a].id].height/(float)item[inv[a].id].width));
++                                              glTexCoord2i(0,0);glVertex2i(r.end.x-(itemWide/2),      r.end.y+(itemWide/2)*((float)item[inv[a].id].height/(float)item[inv[a].id].width));
++                                      }                               glEnd();
                                glDisable(GL_TEXTURE_2D);
                                ui::putText(r.end.x-(itemWide/2),r.end.y-(itemWide*.9),"%s",item[inv[a].id].name);
                                ui::putText(r.end.x-(itemWide/2)+(itemWide*.85),r.end.y-(itemWide/2),"%d",inv[a].count);
                        }
                        a++;
++                      if(sel==a){
++                              glBegin(GL_LINES);
++                                      glColor4f(1.0f, 0.0f, 0.0f, 0.0f);
++                                      glVertex2i(r.start.x,r.start.y);
++                                      glColor4f(1.0f, 0.0f, 0.0f, 0.8f);
++                                      glVertex2i(r.end.x+20, r.end.y-20);
++                              glEnd();
++                      }
                }
        }else if(invHover){
                static unsigned int highlight = 0;
diff --cc src/ui.cpp
index 6f5bdbe992ca3ee72f5597eba648a312d240c2af,9e03f97009f8ed2cbeb1c6c4343976f2a671d062..c0b50044c366633187ef787bf03898faddc39f78
@@@ -511,20 -508,24 +513,24 @@@ namespace ui 
                }
                
                /*
-                * Lists all of the quests the player has
+                *      Lists all of the quests the player is currently taking.
                */
                
-               hub.y-=fontSize*1.15;
-               
-               putString(hub.x,hub.y,"Current Quests:");
-               for(auto &c : player->qh.current){
-                       hub.y-=fontSize*1.15;
-                       putString(hub.x,hub.y,c->title);
+               if(player->inv->invOpen){
 -                      hub.y = player->loc.y + fontSize * 10;
++                      hub.y = player->loc.y + fontSize * 8;
+                       hub.x = player->loc.x;
+                       
+                       putStringCentered(hub.x,hub.y,"Current Quests:");
+                       
+                       for(auto &c : player->qh.current){
+                               hub.y -= fontSize * 1.15;
+                               putString(hub.x,hub.y,c->title);
+                       }       
                }
+               
        }
        void handleEvents(void){
-               static bool left=false,right=false;
                static vec2 premouse={0,0};
                static int heyOhLetsGo = 0;
                unsigned char i;
@@@ -568,108 -570,128 +575,130 @@@ DONE
                                KEYDOWN
                        */
                        case SDL_KEYDOWN:
-                       if(SDL_KEY==SDLK_ESCAPE)gameRunning=false;                                                      // Exit the game with ESC
-                       if(!dialogBoxExists&&!fadeEnable){
-                               if(SDL_KEY==SDLK_a){                                                                                            // Move left
-                                       left=true;
-                                       player->vel.x=-.15;
-                                       player->left = true;
-                                       player->right = false;
-                                       currentWorld=currentWorld->goWorldLeft(player);
-                               }
-                               if(SDL_KEY==SDLK_d){                                                                                            // Move right
-                                       right=true;
-                                       player->vel.x=.15;
-                                       player->right = true;
-                                       player->left = false;
-                                       currentWorld=currentWorld->goWorldRight(player);
-                               }
-                               if(SDL_KEY==SDLK_s && player->ground==2){
-                                       player->ground=false;
-                                       player->loc.y-=HLINE*1.5;
-                               }
-                               if(SDL_KEY==SDLK_w){
-                                       if(inBattle){
-                                               currentWorld=((Arena *)currentWorld)->exitArena(player);
-                                       }else currentWorld=currentWorld->goInsideStructure(player);
-                               }
-                               if(SDL_KEY==SDLK_SPACE){                                                                                        // Jump
-                                       if(player->ground){
-                                               player->vel.y=.4;
-                                               player->loc.y+=HLINE*2;
-                                               player->ground=false;
-                                       }
-                               }
-                               World *tmp;
-                               if(SDL_KEY==SDLK_i){
-                                       tmp=currentWorld;
-                                       currentWorld=currentWorld->goWorldBack(player); // Go back a layer if possible  
-                                       if(tmp!=currentWorld){
-                                               currentWorld->detect(player);
-                                               player->vel.y=.2;
-                                               player->loc.y+=HLINE*5;
-                                               player->ground=false;
-                                       }
-                               }
-                               if(SDL_KEY==SDLK_k){
-                                       tmp=currentWorld;
-                                       currentWorld=currentWorld->goWorldFront(player);        // Go forward a layer if possible
-                                       if(tmp!=currentWorld){
-                                               player->loc.y=0;
-                                               currentWorld->behind->detect(player);
-                                               player->vel.y=.2;
-                                               player->ground=false;
-                                       }
-                               }
-                               if(SDL_KEY==SDLK_LSHIFT)player->speed = debug?4:3;                                                      // Sprint
-                               if(SDL_KEY==SDLK_LCTRL)player->speed = .5;
-                       }
-                               if(SDL_KEY==SDLK_p)toggleBlack();
-                               if(SDL_KEY==SDLK_F3)debug^=true;
-                               if(((SDL_KEY==SDLK_b) & (SDL_KEY==SDLK_F3)))posFlag^=true;
-                               if(SDL_KEY==SDLK_e){
-                                       edown=true;
-                                       if(heyOhLetsGo == 0){
-                                               heyOhLetsGo = loops;
-                                               player->inv->mouseSel = false;
-                                       }
-                                       if(loops - heyOhLetsGo >= 2 && !(player->inv->invOpen) && !(player->inv->selected)){
-                                               player->inv->invHover=true;
-                                               //heyOhLetsGo = 0;
+                               if(!dialogBoxExists&&!fadeEnable){
+                                       switch(SDL_KEY){
+                                       case SDLK_ESCAPE:
+                                               gameRunning=false;
+                                               break;
+                                       case SDLK_a:
+                                               player->vel.x=-.15;
+                                               player->left = true;
+                                               player->right = false;
+                                               currentWorld=currentWorld->goWorldLeft(player);
+                                               break;
+                                       case SDLK_d:
+                                               player->vel.x=.15;
+                                               player->right = true;
+                                               player->left = false;
+                                               currentWorld=currentWorld->goWorldRight(player);
+                                               break;
+                                       case SDLK_s:
+                                               if(player->ground == 2){
+                                                       player->ground=false;
+                                                       player->loc.y-=HLINE*1.5;
+                                               }
+                                               break;
+                                       case SDLK_w:
+                                               if(inBattle)
+                                                        currentWorld=((Arena *)currentWorld)->exitArena(player);
+                                               else currentWorld=currentWorld->goInsideStructure(player);
+                                               break;
+                                       case SDLK_SPACE:
+                                               if(player->ground){
+                                                       player->vel.y=.4;
+                                                       player->loc.y+=HLINE*2;
+                                                       player->ground=false;
+                                               }
+                                               break;
+                                       case SDLK_i:
+                                               tmp=currentWorld;
+                                               currentWorld=currentWorld->goWorldBack(player); // Go back a layer if possible  
+                                               if(tmp!=currentWorld){
+                                                       currentWorld->detect(player);
+                                                       player->vel.y=.2;
+                                                       player->loc.y+=HLINE*5;
+                                                       player->ground=false;
+                                               }
+                                               break;
+                                       case SDLK_k:
+                                               tmp=currentWorld;
+                                               currentWorld=currentWorld->goWorldFront(player);        // Go forward a layer if possible
+                                               if(tmp!=currentWorld){
+                                                       player->loc.y=0;
+                                                       currentWorld->behind->detect(player);
+                                                       player->vel.y=.2;
+                                                       player->ground=false;
+                                               }
+                                               break;
+                                       case SDLK_LSHIFT:
+                                               player->speed = debug ? 4 : 3;
+                                               break;
+                                       case SDLK_LCTRL:
+                                               player->speed = .5;
+                                               break;
+                                       case SDLK_p:
+                                               toggleBlack();
+                                               break;
+                                       case SDLK_F3:
+                                               debug ^= true;
+                                               break;
+                                       case SDLK_b:
+                                               if(debug)posFlag ^= true;
+                                               break;
+                                       case SDLK_e:
++                                              edown=true;
+                                               if(!heyOhLetsGo){
+                                                       heyOhLetsGo = loops;
+                                                       player->inv->mouseSel = false;
+                                               }
+                                               if(loops - heyOhLetsGo >= 2 && !(player->inv->invOpen) && !(player->inv->selected))
+                                                       player->inv->invHover=true;
+                                               break;
+                                       default:
+                                               break;
                                        }
                                }
                                break;
                        /*
-                               KEYUP
-                       */      
+                        *      KEYUP
+                       */
+                       
                        case SDL_KEYUP:
-                               if(SDL_KEY==SDLK_a){left=false;}// Stop the player if movement keys are released
-                               if(SDL_KEY==SDLK_d){right=false;}
-                               if(!left&&!right)player->vel.x=0;
-                               if(SDL_KEY==SDLK_LSHIFT)player->speed = 1;
-                               if(SDL_KEY==SDLK_LCTRL)player->speed = 1;
-                               if(SDL_KEY==SDLK_h)player->health-=5;
-                               if(SDL_KEY==SDLK_f)player->light ^= true;
-                               if(SDL_KEY==SDLK_e){
+                               switch(SDL_KEY){
+                               case SDLK_a:
+                                       player->left = false;
+                                       break;
+                               case SDLK_d:
+                                       player->right = false;
+                                       break;
+                               case SDLK_LSHIFT:
+                               case SDLK_LCTRL:
+                                       player->speed = 1;
+                                       break;
+                               case SDLK_e:
 +                                      edown=false;
                                        if(player->inv->invHover){
                                                player->inv->invHover = false;
-                                               heyOhLetsGo = 0;
                                        }else{
-                                               if(player->inv->selected == false){
-                                                       player->inv->invOpening ^= true;
-                                                       player->inv->mouseSel = false;
-                                                       heyOhLetsGo = 0;
-                                               }else{
-                                                       player->inv->selected = false;
-                                                       player->inv->mouseSel = false;
-                                                       heyOhLetsGo = 0;
-                                               }
+                                               if(!player->inv->selected)player->inv->invOpening ^= true;
+                                               else player->inv->selected = false;
+                                               player->inv->mouseSel = false;
                                        }
+                                       heyOhLetsGo = 0;
+                                       break;
+                               case SDLK_LEFT:
+                                       if(player->inv->sel)player->inv->sel--;
+                                       break;
+                               case SDLK_RIGHT:
+                                       player->inv->sel++;
+                                       break;
+                               default:
+                                       break;
                                }
-                               if(SDL_KEY==SDLK_RIGHT){player->inv->sel+=1;}
-                               if(SDL_KEY==SDLK_LEFT){if(player->inv->sel!=0)player->inv->sel-=1;}
+                               
+                               if(!player->left&&!player->right)
+                                       player->vel.x=0;
+                                       
                                break;
                        default:
                                break;