Sign in to follow this  
Josip Mati?

Games by younger me

Recommended Posts

slicer4ever    6760

ah, if only i had the code from some of my very earliest games, they were travesty's to say the least. (i once wrote risk in lua, with no concept of loops, and functions....the file was well over several megs big, had multiple repeated sections of code, and was so incredibly bloated, it only partially functioned, but overall was just....terrible...*shudders*)

 

is this game based on some existing game, or is it an original construction?

 

edit: i should re-phase, because i do think i may have had an understanding of functions at the time, but not how to utilize them correctly, which lead to me re-writing massive portions of the game, that could have been neatly summed into functions.  also, combined with no real knowledge of for-loops i was hand-writing massive loops, and hard-coding country borders.

Edited by slicer4ever

Share this post


Link to post
Share on other sites
Josip Mati?    1304

It's pure copy of Nine Men's Morris board game. It was easier for me (and still is; there is still long way to go for me to design new games) to use existing games as a core or entire project. It should've been easy to "convert" it into digital format due to its simple board and rules. I just had to use that thing in my head called "brain".

 

Oh well, everybody has to start from somewhere, right? XD

 

EDIT: Even today, I still find myself not utilizing what C# has to offer and instead rewriting massive pieces of code. I passed several times over the code of Battle City and found numerous situations where I could (and did) eliminate copies of code and replace them with one or two methods which do the same job, but better. In the above code, all that placement could easily be summarized into 1 void method with 2 to 4 parameters, instead of doing massive if...then...else if.. tree which is insanely hard to read.

Edited by Aurioch

Share this post


Link to post
Share on other sites

This is gonna be hard to beat, but look at my first games Menu.h file :P This was written about 3 years ago as well :P The funny part, game works perfectly fine here is a video of it http://www.youtube.com/watch?v=4y-5io98vys

int CampControls()
{
  if ( CharacterMenuOpen == false)
  {
  if (EnterShop == false)
  {
  if ( MapMenuOpen == false)
  {    
  if (menu == 1) 
  {
   if (Battle == false)
   {
       if (key[SDLK_DOWN])
       {
        if (campDownKey == 1)
        {
          if (CampCursorCord.y != 544)
          {
             CampCursorCord.y = CampCursorCord.y + 39;
             campDownKey = 2;
               Mix_PlayChannel(2, MenuChoice, 0);
          }  
          }
       }
       if (!key[SDLK_DOWN])
       {
           campDownKey = 1;
       }
       
       if (key[SDLK_UP])
       {
        if(campUpKey == 1)
        {
          if (CampCursorCord.y != 388) 
          {           
             CampCursorCord.y = CampCursorCord.y - 39;
                Mix_PlayChannel(2, MenuChoice, 0);
          }
          campUpKey = 2;
          }
        }
        if (!key[SDLK_UP])
        {
           campUpKey =1;
        }
        
        
       if (key[SDLK_RETURN])
       {
                if (campEnterKey == 1)
             {
        if (active == false)
        {
           if (CampCursorCord.y == 388)
           {
              Find1 = true;
               Mix_PlayChannel(2, MenuChoice, 0);
               MapMenuOpen = true;
                 campEnterKey = 2; 
              CampCursorCord.y = 542;
           }
           if (CampCursorCord.y == 427)
           {//char  stats
                 Mix_PlayChannel(2, MenuChoice, 0);
             CharacterMenuOpen = true;
             CampCursorCord.y = 494;
             campEnterKey = 2;
           }
           if (CampCursorCord.y == 466)
           {
                  Mix_PlayChannel(2, MenuChoice, 0);
                  CampCursorCord.y = 503;
           //Shop
           EnterShop = true;
             campEnterKey = 2;
           }
           if (CampCursorCord.y == 505)
           {
              RestCheck = gold - RestCost;
              if (RestCheck >= 0)
              {
              StopCampM = true;
               Mix_PlayChannel(-1, NightToDay, 0);
            // Mix_HaltMusic();
              active = true;
              campEnterKey = 2;
              }
              else
              Mix_PlayChannel(2, MenuChoice, 0);
           }
           if (CampCursorCord.y == 544)
           {
              Mix_PlayChannel(2, MenuChoice, 0);
              CampCursorCord.y = 495;
              menu = 2;
              campEnterKey = 2;
           }
           }

           }
         }
                     if (!key[SDLK_RETURN])
         {
            campEnterKey = 1;
         }
       }
       }
   }   
}
}

if ((EnterBuy == false) && (EnterSell == false))
{
if (EnterShop == true)
{
   SDL_BlitSurface (BuySellChoice, NULL, screen, &BuySellChoiceCord);
   SDL_BlitSurface (CampCursor, NULL, screen, &CampCursorCord);
         if (campUpKey == 1)
         {
           if (key[SDLK_UP])
           {
              if (CampCursorCord.y > 423)
              {
              Mix_PlayChannel(2, MenuChoice, 0);
              CampCursorCord.y = CampCursorCord.y - 40;
              campUpKey = 2;
              }
           }
         }
         if (!key[SDLK_UP])
         {
            campUpKey = 1;
         }
         
         if (campDownKey == 1)
         {
           if (key[SDLK_DOWN])
           {
             if (CampCursorCord.y < 503)
             {
              Mix_PlayChannel(2, MenuChoice, 0);
              CampCursorCord.y = CampCursorCord.y + 40;
              campDownKey = 2;
              }
           }
         }
         if (!key[SDLK_DOWN])
         {
            campDownKey = 1;
         }
         
         if (campEnterKey == 1)
         {
           if (key[SDLK_RETURN])
           {
             if (CampCursorCord.y == 423)
             {
              //buy
              EnterBuy = true;
              CampCursorCord.y = 507;
              Mix_PlayChannel(2, MenuChoice, 0);
              campEnterKey = 2;
             }
             if (CampCursorCord.y ==463)
             {
             //sell
             EnterSell = true;
             CampCursorCord.y = 507;
               Mix_PlayChannel(2, MenuChoice, 0);
              campEnterKey = 2;                  
             }
             if( CampCursorCord.y == 503)
             {
             //back
             Mix_PlayChannel(2, MenuChoice, 0);
             CampCursorCord.y = 466;
             EnterShop = false;                    
             campEnterKey = 2;
            }
           }
         }
         if (!key[SDLK_RETURN])
         {
            campEnterKey = 1;
         }
}
}

if (EnterBuyEquipment == false)
{
if (EnterBuy == true)
{
   SDL_BlitSurface (EquipmentItemsChoice, NULL, screen, &EquipmentItemsChoiceCord);
   SDL_BlitSurface (CampCursor, NULL, screen, &CampCursorCord);
    BuyTxt = TTF_RenderText_Solid(MinionProBold2, "Buy", NormalColor);
    SDL_BlitSurface(BuyTxt,NULL,screen, &BuyTxtCord);

       if (campUpKey == 1)
       {
         if (key[SDLK_UP])
         {
             if (CampCursorCord.y > 429)
             {
              Mix_PlayChannel(2, MenuChoice, 0);
             CampCursorCord.y = CampCursorCord.y - 39;
             campUpKey = 2;
             }
         }
       }
       if (!key[SDLK_UP])
       {
        campUpKey = 1;
       }
       
       if (campDownKey == 1)
       {
         if (key[SDLK_DOWN])
         {   
             if (CampCursorCord.y < 507)
             {
              Mix_PlayChannel(2, MenuChoice, 0);
             CampCursorCord.y = CampCursorCord.y + 39;
             campDownKey = 2;
             }
         }
       }
       if (!key[SDLK_DOWN])
       {
        campDownKey = 1;
       }
       
         if (campEnterKey == 1)
         {
           if (key[SDLK_RETURN])
           {         
                   if (CampCursorCord.y == 429)
                  {
                  // buy equipment
                  EnterBuyEquipment = true;
                 CampCursorCord.y = 501;
                   CampCursorCord.x = 96;
                  Mix_PlayChannel(2, MenuChoice, 0);
                  campEnterKey = 2;                 
             }
             if (CampCursorCord.y == 468)
             {
                 //buy items
                  Mix_PlayChannel(2, MenuChoice, 0);
                  campEnterKey = 2;    
             }
             if (CampCursorCord.y == 507)
             {
             //back
             Mix_PlayChannel(2, MenuChoice, 0);
             CampCursorCord.y = 423;
             EnterBuy = false;
             EnterShop = true;                    
             campEnterKey = 2;
             }
           }
         }
         if (!key[SDLK_RETURN])
         {
            campEnterKey = 1;
         }
}
}

if (EnterSellEquipment == false)
{
if (EnterSell == true)
{
   SDL_BlitSurface (EquipmentItemsChoice, NULL, screen, &EquipmentItemsChoiceCord);
   SDL_BlitSurface (CampCursor, NULL, screen, &CampCursorCord);
   SellTxt = TTF_RenderText_Solid(MinionProBold2, "Sell", NormalColor);
   SDL_BlitSurface(SellTxt,NULL,screen, &SellTxtCord);
    if (campUpKey == 1)
       {
         if (key[SDLK_UP])
         {
             if (CampCursorCord.y > 429)
             {
              Mix_PlayChannel(2, MenuChoice, 0);
             CampCursorCord.y = CampCursorCord.y - 39;
             campUpKey = 2;
             }
         }
       }
       if (!key[SDLK_UP])
       {
        campUpKey = 1;
       }
       
       if (campDownKey == 1)
       {
         if (key[SDLK_DOWN])
         {   
             if (CampCursorCord.y < 507)
             {
              Mix_PlayChannel(2, MenuChoice, 0);
             CampCursorCord.y = CampCursorCord.y + 39;
             campDownKey = 2;
             }
         }
       }
       if (!key[SDLK_DOWN])
       {
        campDownKey = 1;
       }
            if (campEnterKey == 1)
         {
           if (key[SDLK_RETURN])
           {
             if (CampCursorCord.y == 429)
             {
                  // sell equipment
                   EnterSellEquipment = true;
                   CampCursorCord.y = 501;
                   CampCursorCord.x = 96;
                  Mix_PlayChannel(2, MenuChoice, 0);
                  campEnterKey = 2;                 
             }
             if (CampCursorCord.y == 468)
             {
                 //sell items
                  Mix_PlayChannel(2, MenuChoice, 0);
                  campEnterKey = 2;  
             }
              if (CampCursorCord.y == 507)
             {
             //back
             Mix_PlayChannel(2, MenuChoice, 0);
             CampCursorCord.y = 463;
             EnterSell = false;
             EnterShop = true;                    
             campEnterKey = 2;
           }
           }
         }
         if (!key[SDLK_RETURN])
         {
            campEnterKey = 1;
         }
}
}

if (EnterBuyEquipment == true)
{
   SDL_BlitSurface (BuyEquipment, NULL, screen, &BuySellEquipmentCord);
   SDL_BlitSurface (CampCursor, NULL, screen, &CampCursorCord);
   BuyTxt = TTF_RenderText_Solid(MinionProBold, "Buy", NormalColor);
   SDL_BlitSurface(BuyTxt,NULL,screen, &SellTxt2Cord);
    if (CampCursorCord.y == 467)
    { //Beginner gear 
      BackTxt = TTF_RenderText_Solid(MinionProBold, "Back", NormalColor);   
      SDL_BlitSurface(BackTxt, NULL, screen, &BackTxtCord);
      
      LeatherSetFound = TTF_RenderText_Solid(MinionPro, "Leather Set", NormalColor);
      SDL_BlitSurface(LeatherSetFound,NULL,screen, &Buy1Cord);
      
      LeatherPrice = TTF_RenderText_Solid(MinionPro, "30", GoldColor);
      SDL_BlitSurface(LeatherPrice,NULL,screen, &Price1Cord);
       
      RustyDaggerFound =TTF_RenderText_Solid(MinionPro, "Rusty Dagger", NormalColor);
      SDL_BlitSurface(RustyDaggerFound, NULL, screen, &Buy2Cord);
      
      RustyDaggerPrice = TTF_RenderText_Solid(MinionPro, "20", GoldColor);
      SDL_BlitSurface(RustyDaggerPrice,NULL,screen, &Price2Cord);
      
      DaggerFound =TTF_RenderText_Solid(MinionPro, "Dagger", NormalColor);
      SDL_BlitSurface(DaggerFound, NULL, screen, &Buy3Cord);
      
      DaggerPrice =TTF_RenderText_Solid(MinionPro, "50", GoldColor);
      SDL_BlitSurface(DaggerPrice, NULL, screen, &Price3Cord);
    } 
    if (CampCursorCord.y == 433)
    { 
    if (CurrentLevel >= 5)
    {
                         // apprentice
     PoisonSwordFound =TTF_RenderText_Solid(MinionPro, "Poison Sword", NormalColor);
     SDL_BlitSurface(PoisonSwordFound, NULL, screen, &Buy3Cord);
          
      PoisonSwordPrice =TTF_RenderText_Solid(MinionPro, "250", GoldColor);
      SDL_BlitSurface(PoisonSwordPrice, NULL, screen, &Price3Cord);
      
     ShadowRobeFound =TTF_RenderText_Solid(MinionPro, "Shadow Robe", NormalColor);
     SDL_BlitSurface(ShadowRobeFound, NULL, screen, &Buy2Cord);
          
     ShadowRobePrice =TTF_RenderText_Solid(MinionPro, "300", GoldColor);
      SDL_BlitSurface(ShadowRobePrice, NULL, screen, &Price2Cord);
      
     RockPlateFound =TTF_RenderText_Solid(MinionPro, "Rock Plate", NormalColor);
     SDL_BlitSurface(RockPlateFound, NULL, screen, &Buy1Cord);
     
          RockPlatePrice =TTF_RenderText_Solid(MinionPro, "250", GoldColor);
      SDL_BlitSurface(RockPlatePrice, NULL, screen, &Price1Cord);     
     
     
     BackTxt = TTF_RenderText_Solid(MinionProBold, "Back", NormalColor);   
     SDL_BlitSurface(BackTxt, NULL, screen, &BackTxtCord);
     }
     if (CurrentLevel < 5)
     {
     TooLowTxt = TTF_RenderText_Solid(MinionProBold, "Too low level.", BossColor);   
     SDL_BlitSurface(TooLowTxt, NULL, screen, &TooLowCord);
     }
    }
    
    
    if (CampCursorCord.y == 399)
    {
    if (CurrentLevel >= 15)
    {
     BackTxt = TTF_RenderText_Solid(MinionProBold, "Back", NormalColor);   
      SDL_BlitSurface(BackTxt, NULL, screen, &BackTxtCord);
      }
      if (CurrentLevel < 15)
     {
     TooLowTxt = TTF_RenderText_Solid(MinionProBold, "Too low level.", BossColor);   
     SDL_BlitSurface(TooLowTxt, NULL, screen, &TooLowCord);
     }
    }
    
    
    if (CampCursorCord.y == 365)
    {
    if (CurrentLevel >=20)
    {
     BackTxt = TTF_RenderText_Solid(MinionProBold, "Back", NormalColor);   
      SDL_BlitSurface(BackTxt, NULL, screen, &BackTxtCord);
    }
         if (CurrentLevel < 20)
     {
     TooLowTxt = TTF_RenderText_Solid(MinionProBold, "Too low level.", BossColor);   
     SDL_BlitSurface(TooLowTxt, NULL, screen, &TooLowCord);
     }
   }

    if (CampCursorCord.y == 331)
    {
        if (CurrentLevel >=25)
    {
    BackTxt = TTF_RenderText_Solid(MinionProBold, "Back", NormalColor);   
      SDL_BlitSurface(BackTxt, NULL, screen, &BackTxtCord);
      }
      if (CurrentLevel < 25)
     {
     TooLowTxt = TTF_RenderText_Solid(MinionProBold, "Too low level.", BossColor);   
     SDL_BlitSurface(TooLowTxt, NULL, screen, &TooLowCord);
     }
    }
    
    
    if (CampCursorCord.y == 297)
    {
      if (CurrentLevel >=30)
      {
        BackTxt = TTF_RenderText_Solid(MinionProBold, "Back", NormalColor);   
        SDL_BlitSurface(BackTxt, NULL, screen, &BackTxtCord);
      }
      if (CurrentLevel < 30)
     {
     TooLowTxt = TTF_RenderText_Solid(MinionProBold, "Too low level.", BossColor);   
     SDL_BlitSurface(TooLowTxt, NULL, screen, &TooLowCord);
     }
    }
    
    if (CampCursorCord.y == 263)
    {
    if (CurrentLevel >= 35)
    {
     BackTxt = TTF_RenderText_Solid(MinionProBold, "Back", NormalColor);   
      SDL_BlitSurface(BackTxt, NULL, screen, &BackTxtCord);
      }
      if (CurrentLevel < 35)
     {
     TooLowTxt = TTF_RenderText_Solid(MinionProBold, "Too low level.", BossColor);   
     SDL_BlitSurface(TooLowTxt, NULL, screen, &TooLowCord);
     }
    }
    
    if ((EnterApprentice == false) && (EnterBeginner == false))
    {
    
     if (campUpKey == 1)
     {
       if (key[SDLK_UP])
       {
          if (CampCursorCord.y > 263)
          {
           Mix_PlayChannel(2, MenuChoice, 0);
          CampCursorCord.y = CampCursorCord.y - 34;
          campUpKey = 2;
          }
       }
     }
     if (!key[SDLK_UP])
     {
       campUpKey = 1;
     }
     if (campDownKey == 1)
     {
        if (key[SDLK_DOWN])
        {
           if (CampCursorCord.y < 501)
           {
            Mix_PlayChannel(2, MenuChoice, 0);
           CampCursorCord.y = CampCursorCord.y + 34;
           campDownKey = 2;
           }
        }
     }
     if (!key[SDLK_DOWN])
     {
      campDownKey = 1;
     }
     
     if (campEnterKey == 1)
     {
       if (key[SDLK_RETURN])
       {
                   if (CampCursorCord.y == 433)
                   {
                    if (CurrentLevel >= 5)
                    {
                    EnterApprentice = true;
                    Cursor5Cord.x = 290;
                    Cursor5Cord.y = 453;
                    campEnterKey = 2;
                    Mix_PlayChannel(2, MenuChoice, 0);
                    }
                   }
                   if (CampCursorCord.y == 467)
                   {
                      //beginner
                      EnterBeginner = true;
                      campEnterKey = 2;
                      Cursor5Cord.x = 290;
                      Cursor5Cord.y = 453;
                      Mix_PlayChannel(2, MenuChoice, 0);
                   }   
                   
        if (CampCursorCord.y == 501)
        {
        CampCursorCord.x = 278;
        CampCursorCord.y = 429;
        EnterBuyEquipment = false;
        campEnterKey = 2;
        }
       }
     }
     if (!key[SDLK_RETURN])
     {
       campEnterKey = 1;
     }
     }
}

if (EnterBeginner == true)
{
   SDL_BlitSurface (Cursor3, NULL, screen, &Cursor5Cord); 
   if (campUpKey == 1)
   {
      if (key[SDLK_UP])
      {
         if (Cursor5Cord.y > 231)
         {
          Mix_PlayChannel(2, MenuChoice, 0);
          Cursor5Cord.y = Cursor5Cord.y - 37;
          campUpKey = 2;
         }
      }
   }
   if (!key[SDLK_UP])
   {
   campUpKey = 1;
   }
   
   if (campDownKey == 1)
   {
      if (key[SDLK_DOWN])
      {
         if (Cursor5Cord.y < 453)
         {
          Mix_PlayChannel(2, MenuChoice, 0);
         Cursor5Cord.y = Cursor5Cord.y +37;
         campDownKey = 2;
         }
      }
   }
   if (!key[SDLK_DOWN])
   {
      campDownKey = 1;
   }
   
   if (campEnterKey == 1)
   {
     if(key[SDLK_RETURN])
     {
       if (Cursor5Cord.y == 342)
       {
         //dagger
         Price = gold - 50;
         if (Price >=0)
         {
         gold = gold - 50;
         FoundDagger++;
         campEnterKey = 2;
         Mix_PlayChannel(3, MoneySound, 0);
         }
       }
       if (Cursor5Cord.y == 379)
       {
         // rusty dagger
         Price = gold - 20;
         if (Price >=0)
         {
         gold = gold - 20;
         FoundRustyDagger++;
         campEnterKey = 2;
         Mix_PlayChannel(3, MoneySound, 0);
         }
       }
       if (Cursor5Cord.y == 416)
       {
        // Leather Set
        Price = gold - 30;
        if (Price >= 0)
        {
        gold = gold - 30;
        FoundLeather++;
        campEnterKey = 2;
        Mix_PlayChannel(3, MoneySound, 0);
        }
       }
       if (Cursor5Cord.y == 453)
       {
         EnterBeginner = false;
         campEnterKey = 2;
       }
     }
   }
   if (!key[SDLK_RETURN])
   {
    campEnterKey = 1;
   }
}

if (EnterApprentice == true)
{
   SDL_BlitSurface (Cursor3, NULL, screen, &Cursor5Cord); 
   if (campUpKey == 1)
   {
      if (key[SDLK_UP])
      {
         if (Cursor5Cord.y > 231)
         {
          Mix_PlayChannel(2, MenuChoice, 0);
          Cursor5Cord.y = Cursor5Cord.y - 37;
          campUpKey = 2;
         }
      }
   }
   if (!key[SDLK_UP])
   {
   campUpKey = 1;
   }
   
   if (campDownKey == 1)
   {
      if (key[SDLK_DOWN])
      {
         if (Cursor5Cord.y < 453)
         {
          Mix_PlayChannel(2, MenuChoice, 0);
         Cursor5Cord.y = Cursor5Cord.y +37;
         campDownKey = 2;
         }
      }
   }
   if (!key[SDLK_DOWN])
   {
      campDownKey = 1;
   }
   
   if (campEnterKey == 1)
   {
     if(key[SDLK_RETURN])
     {
               if (Cursor5Cord.y == 342)
       {
         // Poison Sword
         Price = gold - 250;
         if (Price >=0)
         {
         gold = gold - 250;
         FoundPoisonSword++;
         campEnterKey = 2;
         Mix_PlayChannel(3, MoneySound, 0);
         }
       }
       if (Cursor5Cord.y == 379)
       {
         // ShadowRobe
         Price = gold - 300;
         if (Price >=0)
         {
         gold = gold - 300;
         FoundShadowRobe++;
         campEnterKey = 2;
         Mix_PlayChannel(3, MoneySound, 0);
         }
       }            
        if (Cursor5Cord.y == 416)
       {
        // Rock Plate
        Price = gold - 250;
        if (Price >= 0)
        {
        gold = gold - 250;
        FoundRockPlate++;
        campEnterKey = 2;
        Mix_PlayChannel(3, MoneySound, 0);
        }
       }                  
                         
       if (Cursor5Cord.y == 453)
       {
         EnterApprentice = false;
         campEnterKey = 2;
       }
     }
   }
   if (!key[SDLK_RETURN])
   {
    campEnterKey = 1;
   }
}



if (EnterSellEquipment == true)
{
   SDL_BlitSurface (BuyEquipment, NULL, screen, &BuySellEquipmentCord);
   SDL_BlitSurface (CampCursor, NULL, screen, &CampCursorCord);   
   SellTxt = TTF_RenderText_Solid(MinionProBold, "Sell", NormalColor);
   SDL_BlitSurface(SellTxt,NULL,screen, &SellTxt2Cord);
    if (CampCursorCord.y == 467)
    { //SELL Beginner gear 
      BackTxt = TTF_RenderText_Solid(MinionProBold, "Back", NormalColor);   
      SDL_BlitSurface(BackTxt, NULL, screen, &BackTxtCord);
      if (FoundLeather > 0)
      {
      LeatherSetFound = TTF_RenderText_Solid(MinionPro, "Leather Set", NormalColor);
      SDL_BlitSurface(LeatherSetFound,NULL,screen, &Buy1Cord);
      LeatherPrice = TTF_RenderText_Solid(MinionPro, "15", GoldColor);
      SDL_BlitSurface(LeatherPrice,NULL,screen, &Price1Cord);

 ostringstream Leatherconvert2;
 Leatherconvert2 << FoundLeather;
 LeatherTotalTxt = Leatherconvert2.str(); 
 const char * LeatherTotalConst = LeatherTotalTxt.c_str();
 delete[] LeatherTotalConst;
 LeatherTotalImg = TTF_RenderText_Solid(MinionPro, LeatherTotalConst ,NormalColor);
 SDL_BlitSurface(LeatherTotalImg,NULL,screen,&Quan1Cord); 
      }
      if (FoundRustyDagger > 0)
      {
      RustyDaggerFound =TTF_RenderText_Solid(MinionPro, "Rusty Dagger", NormalColor);
      SDL_BlitSurface(RustyDaggerFound, NULL, screen, &Buy2Cord);
      RustyDaggerPrice = TTF_RenderText_Solid(MinionPro, "7", GoldColor);
      SDL_BlitSurface(RustyDaggerPrice,NULL,screen, &Price2Cord);
 
     ostringstream  RustyDaggerTotal2Convert;
 RustyDaggerTotal2Convert <<   FoundRustyDagger;
 RustyDaggerTotalTxt = RustyDaggerTotal2Convert.str(); 
 const char * RustyDaggerTotalConst = RustyDaggerTotalTxt.c_str();
 delete[] RustyDaggerTotalConst;
 RustyDaggerTotalImg = TTF_RenderText_Solid(MinionPro, RustyDaggerTotalConst ,NormalColor);
 SDL_BlitSurface(RustyDaggerTotalImg,NULL,screen,&Quan2Cord);  
}
      if (FoundDagger > 0)
      {
      DaggerFound =TTF_RenderText_Solid(MinionPro, "Dagger", NormalColor);
      SDL_BlitSurface(DaggerFound, NULL, screen, &Buy3Cord);
      DaggerPrice =TTF_RenderText_Solid(MinionPro, "20", GoldColor);
      SDL_BlitSurface(DaggerPrice, NULL, screen, &Price3Cord);

      ostringstream  DaggerTotal2Convert;
 DaggerTotal2Convert <<   FoundDagger;
 DaggerTotalTxt = DaggerTotal2Convert.str(); 
 const char * DaggerTotalConst = DaggerTotalTxt.c_str();
 delete[] DaggerTotalConst;
 DaggerTotalImg = TTF_RenderText_Solid(MinionPro, DaggerTotalConst ,NormalColor);
 SDL_BlitSurface(DaggerTotalImg,NULL,screen,&Quan3Cord); 
      }
      if (FoundGoberion > 0)
      {
      GoberionFound = TTF_RenderText_Solid(MinionPro, "Goberion's Set", UniqueColor);   
      SDL_BlitSurface(GoberionFound, NULL, screen, &Buy4Cord);
      GoberionPrice =TTF_RenderText_Solid(MinionPro, "50", GoldColor);
      SDL_BlitSurface(GoberionPrice, NULL, screen, &Price4Cord);
      
   ostringstream Goberion3Convert;
 Goberion3Convert << FoundGoberion;
 GoberionTotalTxt = Goberion3Convert.str(); 
 const char * GoberionTotalConst = GoberionTotalTxt.c_str();
 delete[] GoberionTotalConst;
 GoberionTotalImg = TTF_RenderText_Solid(MinionPro, GoberionTotalConst ,NormalColor);
 SDL_BlitSurface(GoberionTotalImg,NULL,screen,&Quan4Cord); 
      }
      if (FoundGoldenFang > 0)
      {
      GoldenFangFound2 = TTF_RenderText_Solid(MinionPro, "Golden Fang", UniqueColor);   
      SDL_BlitSurface(GoldenFangFound2, NULL, screen, &Buy5Cord);
      GoldenFangPrice =TTF_RenderText_Solid(MinionPro, "60", GoldColor);
      SDL_BlitSurface(GoldenFangPrice, NULL, screen, &Price5Cord);

    ostringstream  GoldenFangTotal2Convert;
 GoldenFangTotal2Convert <<   FoundGoldenFang;
 GoldenFangTotalTxt = GoldenFangTotal2Convert.str(); 
 const char * GoldenFangTotalConst = GoldenFangTotalTxt.c_str();
 delete[] GoldenFangTotalConst;
 GoldenFangTotalImg = TTF_RenderText_Solid(MinionPro, GoldenFangTotalConst ,NormalColor);
 SDL_BlitSurface(GoldenFangTotalImg,NULL,screen,&Quan5Cord); 
      }
    } 
    if (CampCursorCord.y == 433)
    { 
     if (CurrentLevel >= 5)
    {
                         // apprentice
      if (FoundQuickBlade > 0)
      {
      QuickBladeFound2 = TTF_RenderText_Solid(MinionPro, "Quick Blade", UniqueColor);   
      SDL_BlitSurface(QuickBladeFound2, NULL, screen, &Buy5Cord);
      QuickBladePrice =TTF_RenderText_Solid(MinionPro, "170", GoldColor);
      SDL_BlitSurface(QuickBladePrice, NULL, screen, &Price5Cord);
 
  ostringstream  QuickBladeTotal2Convert;
QuickBladeTotal2Convert <<   FoundQuickBlade;
 QuickBladeTotalTxt = QuickBladeTotal2Convert.str(); 
 const char * QuickBladeTotalConst = QuickBladeTotalTxt.c_str();
 delete[] QuickBladeTotalConst;
 QuickBladeTotalImg = TTF_RenderText_Solid(MinionPro, QuickBladeTotalConst ,NormalColor);
 SDL_BlitSurface(QuickBladeTotalImg,NULL,screen,&Quan5Cord); 
      }
      if ( FoundRockiansPlate > 0)
      {
      RockiansPlateFound = TTF_RenderText_Solid(MinionPro, "Rockians Plate", UniqueColor);   
      SDL_BlitSurface(RockiansPlateFound, NULL, screen, &Buy4Cord);
      RockiansPlatePrice =TTF_RenderText_Solid(MinionPro, "150", GoldColor);
      SDL_BlitSurface(RockiansPlatePrice, NULL, screen, &Price4Cord);
      
      ostringstream RockianPlateTotal2Convert;
 RockianPlateTotal2Convert <<  FoundRockiansPlate;
 RockianPlateTotalTxt = RockianPlateTotal2Convert.str(); 
 const char * RockianPlateTotalConst = RockianPlateTotalTxt.c_str();
 delete[] RockianPlateTotalConst;
 RockianPlateTotalImg = TTF_RenderText_Solid(MinionPro, RockianPlateTotalConst ,NormalColor);
 SDL_BlitSurface(RockianPlateTotalImg,NULL,screen,&Quan4Cord);  
      }
     if (FoundPoisonSword > 0 )
     {
     PoisonSwordFound =TTF_RenderText_Solid(MinionPro, "Poison Sword", NormalColor);
     SDL_BlitSurface(PoisonSwordFound, NULL, screen, &Buy3Cord);
      PoisonSwordPrice =TTF_RenderText_Solid(MinionPro, "70", GoldColor);
      SDL_BlitSurface(PoisonSwordPrice, NULL, screen, &Price3Cord);
      
     ostringstream  PoisonSwordTotal2Convert;
 PoisonSwordTotal2Convert <<   FoundPoisonSword;
 PoisonSwordTotalTxt = PoisonSwordTotal2Convert.str(); 
 const char * PoisonSwordTotalConst = PoisonSwordTotalTxt.c_str();
 delete[] PoisonSwordTotalConst;
 PoisonSwordTotalImg = TTF_RenderText_Solid(MinionPro, PoisonSwordTotalConst ,NormalColor);
 SDL_BlitSurface(PoisonSwordTotalImg,NULL,screen,&Quan3Cord); 
      }
      if (FoundShadowRobe > 0)
      {
     ShadowRobeFound =TTF_RenderText_Solid(MinionPro, "Shadow Robe", NormalColor);
     SDL_BlitSurface(ShadowRobeFound, NULL, screen, &Buy2Cord);
     ShadowRobePrice =TTF_RenderText_Solid(MinionPro, "100", GoldColor);
      SDL_BlitSurface(ShadowRobePrice, NULL, screen, &Price2Cord);
      
      ostringstream  ShadowRobeTotal2Convert;
 ShadowRobeTotal2Convert <<   FoundShadowRobe;
 ShadowRobeTotalTxt = ShadowRobeTotal2Convert.str(); 
 const char * ShadowRobeTotalConst = ShadowRobeTotalTxt.c_str();
 delete[] ShadowRobeTotalConst;
 ShadowRobeTotalImg = TTF_RenderText_Solid(MinionPro, ShadowRobeTotalConst ,NormalColor);
 SDL_BlitSurface(ShadowRobeTotalImg,NULL,screen,&Quan2Cord);  
      }
      if (FoundRockPlate > 0)
      {
     RockPlateFound =TTF_RenderText_Solid(MinionPro, "Rock Plate", NormalColor);
     SDL_BlitSurface(RockPlateFound, NULL, screen, &Buy1Cord);
          RockPlatePrice =TTF_RenderText_Solid(MinionPro, "70", GoldColor);
      SDL_BlitSurface(RockPlatePrice, NULL, screen, &Price1Cord);  
 
    ostringstream RockPlateTotal2Convert;
 RockPlateTotal2Convert << FoundRockPlate;
 RockPlateTotalTxt = RockPlateTotal2Convert.str(); 
 const char * RockPlateTotalConst = RockPlateTotalTxt.c_str();
 delete[] RockPlateTotalConst;
 RockPlateTotalImg = TTF_RenderText_Solid(MinionPro, RockPlateTotalConst ,NormalColor);
 SDL_BlitSurface(RockPlateTotalImg,NULL,screen,&Quan1Cord);     
      }
     
     BackTxt = TTF_RenderText_Solid(MinionProBold, "Back", NormalColor);   
     SDL_BlitSurface(BackTxt, NULL, screen, &BackTxtCord);
      }
     if (CurrentLevel < 5)
     {
     TooLowTxt = TTF_RenderText_Solid(MinionProBold, "Too low level.", BossColor);   
     SDL_BlitSurface(TooLowTxt, NULL, screen, &TooLowCord);
    }
    }
    
    
      if (CampCursorCord.y == 399)
    {
    if (CurrentLevel >= 15)
    {
     BackTxt = TTF_RenderText_Solid(MinionProBold, "Back", NormalColor);   
      SDL_BlitSurface(BackTxt, NULL, screen, &BackTxtCord);
      }
      if (CurrentLevel < 15)
     {
     TooLowTxt = TTF_RenderText_Solid(MinionProBold, "Too low level.", BossColor);   
     SDL_BlitSurface(TooLowTxt, NULL, screen, &TooLowCord);
     }
    }
    
    
    if (CampCursorCord.y == 365)
    {
    if (CurrentLevel >=20)
    {
     BackTxt = TTF_RenderText_Solid(MinionProBold, "Back", NormalColor);   
      SDL_BlitSurface(BackTxt, NULL, screen, &BackTxtCord);
    }
         if (CurrentLevel < 20)
     {
     TooLowTxt = TTF_RenderText_Solid(MinionProBold, "Too low level.", BossColor);   
     SDL_BlitSurface(TooLowTxt, NULL, screen, &TooLowCord);
     }
   }

    if (CampCursorCord.y == 331)
    {
        if (CurrentLevel >=25)
    {
    BackTxt = TTF_RenderText_Solid(MinionProBold, "Back", NormalColor);   
      SDL_BlitSurface(BackTxt, NULL, screen, &BackTxtCord);
      }
      if (CurrentLevel < 25)
     {
     TooLowTxt = TTF_RenderText_Solid(MinionProBold, "Too low level.", BossColor);   
     SDL_BlitSurface(TooLowTxt, NULL, screen, &TooLowCord);
     }
    }
    
    
    if (CampCursorCord.y == 297)
    {
      if (CurrentLevel >=30)
      {
        BackTxt = TTF_RenderText_Solid(MinionProBold, "Back", NormalColor);   
        SDL_BlitSurface(BackTxt, NULL, screen, &BackTxtCord);
      }
      if (CurrentLevel < 30)
     {
     TooLowTxt = TTF_RenderText_Solid(MinionProBold, "Too low level.", BossColor);   
     SDL_BlitSurface(TooLowTxt, NULL, screen, &TooLowCord);
     }
    }
    
    if (CampCursorCord.y == 263)
    {
    if (CurrentLevel >= 35)
    {
     BackTxt = TTF_RenderText_Solid(MinionProBold, "Back", NormalColor);   
      SDL_BlitSurface(BackTxt, NULL, screen, &BackTxtCord);
      }
      if (CurrentLevel < 35)
     {
     TooLowTxt = TTF_RenderText_Solid(MinionProBold, "Too low level.", BossColor);   
     SDL_BlitSurface(TooLowTxt, NULL, screen, &TooLowCord);
     }
    }
    
    
   if ((SellBeginner == false) && (SellApprentice == false))
   {
     if (campUpKey == 1)
     {
       if (key[SDLK_UP])
       {
          if (CampCursorCord.y > 263)
          {
           Mix_PlayChannel(2, MenuChoice, 0);
          CampCursorCord.y = CampCursorCord.y - 34;
          campUpKey = 2;
          }
       }
     }
     if (!key[SDLK_UP])
     {
       campUpKey = 1;
     }
     if (campDownKey == 1)
     {
        if (key[SDLK_DOWN])
        {
           if (CampCursorCord.y < 501)
           {
            Mix_PlayChannel(2, MenuChoice, 0);
           CampCursorCord.y = CampCursorCord.y + 34;
           campDownKey = 2;
           }
        }
     }
     if (!key[SDLK_DOWN])
     {
      campDownKey = 1;
     }
     
        if (campEnterKey == 1)
     {
       if (key[SDLK_RETURN])
       {
                            if (CampCursorCord.y == 433)
                   {
                    if (CurrentLevel >= 5)
                    {
                    SellApprentice = true;
                    Cursor5Cord.x = 290;
                    Cursor5Cord.y = 453;
                    campEnterKey = 2;
                    Mix_PlayChannel(2, MenuChoice, 0);
                    }
                   }
                   if (CampCursorCord.y == 467)
                   {
                      //sell beginner
                      SellBeginner = true;
                      campEnterKey = 2;
                      Cursor5Cord.x = 290;
                      Cursor5Cord.y = 453;
                      Mix_PlayChannel(2, MenuChoice, 0);
                   }   
                   
         if (CampCursorCord.y == 501)
         {
         CampCursorCord.x = 278;
         CampCursorCord.y = 429;
         EnterSellEquipment = false;
         campEnterKey = 2;
         }
       }
     }
     if (!key[SDLK_RETURN])
     {
       campEnterKey = 1;
     }       
     }        
}

if (SellBeginner == true)
{
 SDL_BlitSurface (Cursor3, NULL, screen, &Cursor5Cord); 
   if (campUpKey == 1)
   {
      if (key[SDLK_UP])
      {
         if (Cursor5Cord.y > 231)
         {
          Mix_PlayChannel(2, MenuChoice, 0);
          Cursor5Cord.y = Cursor5Cord.y - 37;
          campUpKey = 2;
         }
      }
   }
   if (!key[SDLK_UP])
   {
   campUpKey = 1;
   }
   
   if (campDownKey == 1)
   {
      if (key[SDLK_DOWN])
      {
         if (Cursor5Cord.y < 453)
         {
          Mix_PlayChannel(2, MenuChoice, 0);
         Cursor5Cord.y = Cursor5Cord.y +37;
         campDownKey = 2;
         }
      }
   }
   if (!key[SDLK_DOWN])
   {
      campDownKey = 1;
   }
   
   if (campEnterKey == 1)
   {
     if(key[SDLK_RETURN])
     {
         if (Cursor5Cord.y == 268)
         {
           if (FoundGoldenFang > 0)
           {
             if ((EquipGoldenFang == true) || (FoundGoldenFang > 1))
             {
               gold = gold + 60;
               FoundGoldenFang--;
               campEnterKey = 2;
               Mix_PlayChannel(3, MoneySound, 0);
             }
           }
         }
         if (Cursor5Cord.y == 305)
         {
           if (FoundGoberion > 0)
           {
             if ((EquipGoberion == true) || (FoundGoberion > 1))
             {
                gold = gold + 50;
                FoundGoberion--;
                campEnterKey = 2;
                Mix_PlayChannel(3, MoneySound, 0);
             }     
            }
         }
         if (Cursor5Cord.y == 342)
         {
         //dagger
         if (FoundDagger > 0)
        {
        if ((EquipDagger == true) || (FoundDagger > 1))
        {
          gold = gold + 20;
          FoundDagger--;
          campEnterKey = 2;
          Mix_PlayChannel(3, MoneySound, 0);
        }
        }
       }
       if (Cursor5Cord.y == 379)
       {
         // rusty dagger
         if (FoundRustyDagger > 0)
        {
          if ((EquipRustyDagger == true) || (FoundRustyDagger > 1))
          {
           gold = gold + 7;
           FoundRustyDagger--;
           campEnterKey = 2;
          Mix_PlayChannel(3, MoneySound, 0);
          }
        }
       }
       if (Cursor5Cord.y == 416)
       {
        // Leather Set
        if (FoundLeather > 0)
        {
          if ((EquipLeather == true) || (FoundLeather > 1))
          {
            gold = gold + 15;
            FoundLeather--;
            campEnterKey = 2;
            Mix_PlayChannel(3, MoneySound, 0);
          }
        }
       }
       if (Cursor5Cord.y == 453)
       {
       SellBeginner = false;
       campEnterKey = 2;
       }
     }
   }
   if (!key[SDLK_RETURN])
   {
     campEnterKey = 1;
   }
   
}

if (SellApprentice == true)
{
 SDL_BlitSurface (Cursor3, NULL, screen, &Cursor5Cord); 
   if (campUpKey == 1)
   {
      if (key[SDLK_UP])
      {
         if (Cursor5Cord.y > 231)
         {
          Mix_PlayChannel(2, MenuChoice, 0);
          Cursor5Cord.y = Cursor5Cord.y - 37;
          campUpKey = 2;
         }
      }
   }
   if (!key[SDLK_UP])
   {
   campUpKey = 1;
   }
   
   if (campDownKey == 1)
   {
      if (key[SDLK_DOWN])
      {
         if (Cursor5Cord.y < 453)
         {
          Mix_PlayChannel(2, MenuChoice, 0);
         Cursor5Cord.y = Cursor5Cord.y +37;
         campDownKey = 2;
         }
      }
   }
   if (!key[SDLK_DOWN])
   {
      campDownKey = 1;
   }
   
   if (campEnterKey == 1)
   {
     if(key[SDLK_RETURN])
     {
          if (Cursor5Cord.y == 268)
         {
           if (FoundQuickBlade > 0)
           {
             if ((EquipQuickBlade == true) || (FoundQuickBlade > 1))
             {
               gold = gold + 170;
               FoundQuickBlade--;
               campEnterKey = 2;
               Mix_PlayChannel(3, MoneySound, 0);
             }
           }
         }
         if (Cursor5Cord.y == 305)
         {
           if (FoundRockiansPlate > 0)
           {
             if ((EquipRockianPlate == true) || (FoundRockiansPlate > 1))
             {
                gold = gold + 150;
                FoundRockiansPlate--;
                campEnterKey = 2;
                Mix_PlayChannel(3, MoneySound, 0);
             }     
            }
         }
       
        if (Cursor5Cord.y == 342)
       {
         //dagger
         if (FoundPoisonSword > 0)
        {
        if ((EquipPoisonSword == true) || (FoundPoisonSword > 1))
        {
        gold = gold + 70;
        FoundPoisonSword--;
        campEnterKey = 2;
        Mix_PlayChannel(3, MoneySound, 0);
        }
        }
       }
       if (Cursor5Cord.y == 379)
       {
         //shadow robe
         if (FoundShadowRobe > 0)
        {
        if ((EquipShadowRobe == true) || (FoundShadowRobe > 1))
        {
        gold = gold + 100;
        FoundShadowRobe--;
        campEnterKey = 2;
        Mix_PlayChannel(3, MoneySound, 0);
        }
        }
       }
       if (Cursor5Cord.y == 416)
       {
        // Leather Set
        if (FoundRockPlate > 0)
        {
          if ((EquipRockPlate == true) || (FoundRockPlate > 1))
          {
          gold = gold + 70;
          FoundRockPlate--;
          campEnterKey = 2;
          Mix_PlayChannel(3, MoneySound, 0);
          }
        }
       }
       
       if (Cursor5Cord.y == 453)
       {
       SellApprentice = false;
       campEnterKey = 2;
       }
     }
   }
   if (!key[SDLK_RETURN])
   {
     campEnterKey = 1;
   }
}

if (MapMenuOpen == true)
{
 SDL_BlitSurface (ChoiceMap, NULL, screen, &ChoiceMapCord);
   SDL_BlitSurface (CampCursor, NULL, screen, &CampCursorCord); 
   
     GoblinForest = TTF_RenderText_Solid(MinionPro, "Goblin Forest", NormalColor);
           SDL_BlitSurface(GoblinForest, NULL, screen, &GoblinForestCord);
     RockCave = TTF_RenderText_Solid(MinionPro, "Rock Cave", NormalColor);
           SDL_BlitSurface(RockCave, NULL, screen, &RockCaveCord);
           
   if (campUpKey == 1)
   {
     if (key[SDLK_UP])
     {
        if (CampCursorCord.y != 269)
        {
        Mix_PlayChannel(2, MenuChoice, 0);
        CampCursorCord.y = CampCursorCord.y - 39;
        campUpKey = 2;
        }
     } 
   }
   if (!key[SDLK_UP])
   {
      campUpKey = 1;
   }
   
   if (campDownKey == 1)
   {
     if (key[SDLK_DOWN])
     {
        if (CampCursorCord.y != 542)
        {
        Mix_PlayChannel(2, MenuChoice, 0);
        CampCursorCord.y = CampCursorCord.y + 39;
        campDownKey = 2;
        }
     } 
   }
   if (!key[SDLK_DOWN])
   {
      campDownKey = 1;
   }
   
    if (campEnterKey == 1)
    {
      if (key[SDLK_RETURN])
      {
        if (CampCursorCord.y == 542)
        {
           Mix_PlayChannel(2, MenuChoice, 0);
           CampCursorCord.y = 388;
           MapMenuOpen = false;
           campEnterKey = 2; 
        }
        if (CampCursorCord.y == 503)
        {
        CampCursorCord.x = 33;
        CampCursorCord.y = 387;
        StopCampM = true;
        campEnterKey = 2;     
        MapMenuOpen = false;     
        ActiveBattle = true;
        GoblinForestMap = true;
        }
        if (CampCursorCord.y == 464)
        {
        CampCursorCord.x = 33;
        CampCursorCord.y = 387;
        StopCampM = true;
        campEnterKey = 2;     
        MapMenuOpen = false;     
        ActiveBattle = true;
        RockCaveMap = true;
        
        }
      }
    }
    if (!key[SDLK_RETURN])
    {
      campEnterKey = 1;
    }
}


if (CharacterStatsMenuOpen == false) 
{
if (EquipmentMenuOpen == false) 
{
   if (CharacterMenuOpen == true)
   {
       SDL_BlitSurface (CharacterMenu, NULL, screen, &CampExitCord);
       SDL_BlitSurface (CampCursor, NULL, screen, &CampCursorCord);  
           if (key[SDLK_DOWN])
       {
           if (campDownKey == 1)
        {
          if (CampCursorCord.y != 494)
          {
             CampCursorCord.y = CampCursorCord.y + 39;
             campDownKey = 2;
               Mix_PlayChannel(2, MenuChoice, 0);
          }  
          }
          }
       if (!key[SDLK_DOWN])
       {
           campDownKey = 1;
       }
       
           if (key[SDLK_UP])
       {
       if (campUpKey == 1)
        {
          if (CampCursorCord.y != 416)
          {
             CampCursorCord.y = CampCursorCord.y - 39;
             campUpKey = 2;
               Mix_PlayChannel(2, MenuChoice, 0);
          }  
          }
          }
       if (!key[SDLK_UP])
       {
           campUpKey = 1;
       }
       
       if (key[SDLK_RETURN])
       {
             if (campEnterKey == 1)
             {   
                  if (CampCursorCord.y == 416)
                  {
                  //Character Stats
                  CharacterStatsMenuOpen = true;
                  Mix_PlayChannel(2, MenuChoice, 0);
                  CampCursorCord.y = 524;
                  CampCursorCord.x = 255; // 278
                  campEnterKey = 2;
                  }
                  if (CampCursorCord.y == 455)
                  {
                  //Equipment
                  EquipmentMenuOpen = true;
                  Mix_PlayChannel(2, MenuChoice, 0);
                  Cursor2Cord.y = 530;
                  Cursor2Cord.x = 178;
                  campEnterKey = 2;
                  }
                  if ( CampCursorCord.y == 494)
                  {
                  //Back
                  CampCursorCord.y = 427;
                  CharacterMenuOpen = false;
                  Mix_PlayChannel(2, MenuChoice, 0);
                  campEnterKey = 2;
                  }
             }
       }
       if (!key[SDLK_RETURN])
       {
             campEnterKey = 1;
       }
   }
}
}

if (CharacterStatsMenuOpen == true)
{
       SDL_BlitSurface (CharacterStatsMenu, NULL, screen, &CharacterStatsCord);
       SDL_BlitSurface (CampCursor, NULL, screen, &CampCursorCord);
       DrawStats();
       if (campEnterKey == 1)
       {
         if (key[SDLK_RETURN]) 
         {
             if ( (CampCursorCord.y = 535)  & (CampCursorCord.x = 255) )
             {
             Mix_PlayChannel(2, MenuChoice, 0);
             CampCursorCord.y = 416;
             CampCursorCord.x = 278;
             CharacterStatsMenuOpen = false;
             campEnterKey = 2;
             }
         }
       }
       if (!key[SDLK_RETURN])
       {
             campEnterKey = 1;
       }
}

if (EquipmentMenuOpen == true)
{  
       SDL_BlitSurface (EquipmentMenu, NULL, screen, &EquipmentMenuCord);
       SDL_BlitSurface (Cursor2, NULL, screen, &Cursor2Cord);
       DrawGear();
       DrawWeapons();
       CheckGear();
       CheckWeapons();
        
       if ((ArmorMenuOpen == false) & (WeaponMenuOpen == false))
       {
       //right
       if (campRightKey == 1) 
          {
            if (key[SDLK_RIGHT])
             {
                if ( Cursor2Cord.x != 340)
                {
                 Mix_PlayChannel(2, MenuChoice, 0);
                Cursor2Cord.x = Cursor2Cord.x + 162;
                campRightKey = 2;
                }
             }
          }
          
          if (!key[SDLK_RIGHT])
          {
              campRightKey = 1;
          }
          //left
          if (campLeftKey == 1)
          {
             if (key[SDLK_LEFT]) 
             {
                 if (Cursor2Cord.x != 16)
                 {
                  Mix_PlayChannel(2, MenuChoice, 0);
                 Cursor2Cord.x = Cursor2Cord.x - 162;
                 campLeftKey = 2;
                 }
             }
          }
          
          if (!key[SDLK_LEFT])
          {
             campLeftKey = 1;
          }
       
       if (campEnterKey == 1)
       {
         if (key[SDLK_RETURN]) 
         {
             if(Cursor2Cord.x == 178)
             {
             //back
             Mix_PlayChannel(2, MenuChoice, 0);
             CampCursorCord.y = 455;
             CampCursorCord.x = 278;
             EquipmentMenuOpen = false;
             campEnterKey = 2;
             }
             if(Cursor2Cord.x == 16)
             {
              //armor
              ArmorMenuOpen = true;
              Mix_PlayChannel(2, MenuChoice, 0);
              campEnterKey = 2;
              
             }
             if(Cursor2Cord.x == 340)
             {
              //weapon
              WeaponMenuOpen = true;
              Mix_PlayChannel(2, MenuChoice, 0);
              campEnterKey = 2;
             }
         }
       }
       if (!key[SDLK_RETURN])
       {
             campEnterKey = 1;
       }
   }
}

if (WeaponMenuOpen == true)
{
    SDL_BlitSurface (Cursor3, NULL, screen, &Cursor4Cord);
    //down
    if (campDownKey == 1)
    {
      if (key[SDLK_DOWN])
      {
         if (Cursor4Cord.y != 467)
         {
         Cursor4Cord.y = Cursor4Cord.y + 37;
         campDownKey = 2;
          CheckWeaponUnequip();
         }
      }
    }
    if (!key[SDLK_DOWN])
    {
       campDownKey = 1;
    }
    // up
     if (campUpKey == 1)
    {
      if (key[SDLK_UP])
      {
         if (Cursor4Cord.y != 171)
         {
         Cursor4Cord.y = Cursor4Cord.y - 37;
         campUpKey = 2;
          CheckWeaponUnequip();
         }
      }
    }
    if (!key[SDLK_UP])
    {
       campUpKey = 1;
    }
    
       // right
     if (campRightKey == 1)
    {
      if (key[SDLK_RIGHT])
      {
         if (Cursor4Cord.x != 277) //30
         {
         Cursor4Cord.x = Cursor4Cord.x + 247;
         campRightKey = 2;
          CheckWeaponUnequip();
         }
      }
    }
    if (!key[SDLK_RIGHT])
    {
       campRightKey = 1;
    }
    
       // left
     if (campLeftKey == 1)
    {
      if (key[SDLK_LEFT])
      {
         if (Cursor4Cord.x != 30) //30
         {
         Cursor4Cord.x = Cursor4Cord.x - 247;
         campLeftKey = 2;
          CheckWeaponUnequip();
         }
      }
    }
    if (!key[SDLK_LEFT])
    {
       campLeftKey = 1;
    }
    
    
    if (campEnterKey == 1)
    {
     if (key[SDLK_RETURN])
     {
        WeaponMenuOpen = false;
        campEnterKey = 2;
     }
    }
    if (!key[SDLK_RETURN])
    {
       campEnterKey = 1;
    }

}

if (ArmorMenuOpen == true)
{
    SDL_BlitSurface (Cursor3, NULL, screen, &Cursor3Cord);
    //down
    if (campDownKey == 1)
    {
      if (key[SDLK_DOWN])
      {
         if (Cursor3Cord.y != 467)
         {
         Cursor3Cord.y = Cursor3Cord.y + 37;
         campDownKey = 2;
          CheckGearUnequip();
         }
      }
    }
    if (!key[SDLK_DOWN])
    {
       campDownKey = 1;
    }
    // up
     if (campUpKey == 1)
    {
      if (key[SDLK_UP])
      {
         if (Cursor3Cord.y != 171)
         {
         Cursor3Cord.y = Cursor3Cord.y - 37;
         campUpKey = 2;
          CheckGearUnequip();
         }
      }
    }
    if (!key[SDLK_UP])
    {
       campUpKey = 1;
    }
    
       // right
     if (campRightKey == 1)
    {
      if (key[SDLK_RIGHT])
      {
         if (Cursor3Cord.x != 277) //30
         {
         Cursor3Cord.x = Cursor3Cord.x + 247;
         campRightKey = 2;
             CheckGearUnequip();
         }
      }
    }
    if (!key[SDLK_RIGHT])
    {
       campRightKey = 1;
    }
    
       // left
     if (campLeftKey == 1)
    {
      if (key[SDLK_LEFT])
      {
         if (Cursor3Cord.x != 30) //30
         {
         Cursor3Cord.x = Cursor3Cord.x - 247;
         campLeftKey = 2;
         CheckGearUnequip();
         }
      }
    }
    if (!key[SDLK_LEFT])
    {
       campLeftKey = 1;
    }
    
    
    if (campEnterKey == 1)
    {
     if (key[SDLK_RETURN])
     {
        ArmorMenuOpen = false;
        campEnterKey = 2;
     }
    }
    if (!key[SDLK_RETURN])
    {
       campEnterKey = 1;
    }
}

   if(menu == 2)
      {
       SDL_BlitSurface (CampExit, NULL, screen, &CampExitCord);
       SDL_BlitSurface (CampCursor, NULL, screen, &CampCursorCord);
       if (campUpKey == 1)
       {
       if (key[SDLK_UP])
       {
           if (CampCursorCord.y == 495)  
           {
                 Mix_PlayChannel(2, MenuChoice, 0);
              CampCursorCord.y = CampCursorCord.y-48;  
           }      
           campUpKey = 2;   
       }
       }
       if (!key[SDLK_UP])
       {
           campUpKey = 1;
       }
       if (campDownKey == 1)
       {
       if (key[SDLK_DOWN])
       {
           if (CampCursorCord.y == 447)
           {
               Mix_PlayChannel(2, MenuChoice, 0);
           CampCursorCord.y = CampCursorCord.y+48; 
           }        
           campDownKey = 2;     
       }
       }
       if (!key[SDLK_DOWN])
       {
         campDownKey = 1;                   
       }
       if (campEnterKey == 1)
       {
       if (key[SDLK_RETURN])
       {
           
           if (CampCursorCord.y == 495)  
           {
                        Mix_PlayChannel(2, MenuChoice, 0);
               campEnterKey = 2;
               CampCursorCord.y = 544;
               menu = 1;
              
           }          
           if (CampCursorCord.y == 447)
           {
                    Mix_PlayChannel(2, MenuChoice, 0);
               campEnterKey = 2;
               CleanData();
               return 0;
           }
           
       }
   }
          if (!key[SDLK_RETURN])
         {
            campEnterKey = 1;
         }
          
}
   
      if (Battle == true)
       {
             if ( StopGame == false)
             {
                   
             Player.flee();
             Player.attack();
             DeathAnimation();
             Enemy1.EnemyAttack();
             if(LifeBarCrop.w <= 87)
             {
                LifeBarCrop.w = 87;
                PlayerDeath = false;
                 StopGame = true;
             }
             
             if (abilitiesButton == true)
{
    SDL_BlitSurface (AbilitiesMenu, NULL, screen, &BattleMenuCord);
    SDL_BlitSurface (CampCursor, NULL, screen, &CampCursorCord);
    if (UnlockQuickSlash == true)
    {
          QuickSlashAbi =TTF_RenderText_Solid(MinionProBold, "Quick Slash 10", BossColor);
          SDL_BlitSurface(QuickSlashAbi, NULL, screen, &FirstAbiCord);
    }
    if (UnlockHighJump == true)
    {
          HighJumpAbi =TTF_RenderText_Solid(MinionProBold, "High Jump 15", BossColor);
          SDL_BlitSurface(HighJumpAbi, NULL, screen, &SecondAbiCord);
   }
    if (campDownKey == 1)
    {
     if (key[SDLK_DOWN])
     {
       if (CampCursorCord.y != 522)
       {
           Mix_PlayChannel(2, MenuChoice, 0);
           CampCursorCord.y = CampCursorCord.y + 39;
       }
       campDownKey = 2;
     }
    }
    if (!key[SDLK_DOWN])
    {
    campDownKey = 1;
    }
    if (campUpKey == 1)
    {
    if (key[SDLK_UP])
    {
        if (CampCursorCord.y != 405) 
        {   
        Mix_PlayChannel(2, MenuChoice, 0);       
        CampCursorCord.y = CampCursorCord.y - 39;
        }
            campUpKey = 2;
    }
}
    if (!key[SDLK_UP])
    {
       campUpKey = 1;
    }
    
    if (campEnterKey == 1)
    {
       if (key[SDLK_RETURN])
       {
          if (CampCursorCord.y == 522) 
          {
             Mix_PlayChannel(2, MenuChoice, 0);
             abilitiesButton = false;
             CampCursorCord.y = 426;
             campEnterKey = 2;
          }
     if ((WaitBar2Crop.w == 210) && (SP >= 10))
     { 
       if ((CampCursorCord.y == 483)  && (UnlockQuickSlash == true))
          {
             Mix_PlayChannel(2, MenuChoice, 0);
             abilitiesAttack1 = true;
             Abilities = true; 
             abilitiesButton = false;
             campEnterKey = 2;
             SP = SP - 10;
             
          }
       }
       if ((WaitBar2Crop.w == 210) && (SP>= 15))
       {
         if ((CampCursorCord.y == 444) && (UnlockHighJump == true))
         {
            Mix_PlayChannel(2, MenuChoice, 0);
            abilitiesAttack2 = true;
            Abilities = true; 
            abilitiesButton = false;
            SP = SP - 15;
            campEnterKey = 2;
         }
       }
       }
       }
    
    if (!key[SDLK_RETURN])
    {
    campEnterKey = 1;
    }
}

             
              if (abilitiesButton == false)
           {
                 
           if (campDownKey == 1)
           {
           if (key[SDLK_DOWN])
           {
                if (CampCursorCord.y != 504)
                {
                       Mix_PlayChannel(2, MenuChoice, 0);
                CampCursorCord.y = CampCursorCord.y + 39;
                }  
                campDownKey = 2;
           }
           }
            if (!key[SDLK_DOWN])
            {
                campDownKey = 1;
            }
           if (campUpKey == 1)
           { 
           if (key[SDLK_UP])
           {
                if (CampCursorCord.y != 387) 
                {   
                  Mix_PlayChannel(2, MenuChoice, 0);       
                CampCursorCord.y = CampCursorCord.y - 39;
                }
                campUpKey = 2;
           }
           }
           if (!key[SDLK_UP])
           {
               campUpKey = 1;
           }
           if (campEnterKey == 1)
           {
           if (key[SDLK_RETURN])
           {
                if (CampCursorCord.y == 387) 
                {
                       if (WaitBar2Crop.w == 210)
                        {
                               Mix_PlayChannel(2, MenuChoice, 0);
                          attackButton = true;
                          }
                          campEnterKey = 2;
                }
                if (CampCursorCord.y == 426)
                {
                   if (EnemyLifeCrop.w > 78)
                   {
                          Mix_PlayChannel(2, MenuChoice, 0);
                       //abilities
                       abilitiesButton = true;
                       CampCursorCord.y = 522;
                       campEnterKey = 2; 
                   }
                }
                if (CampCursorCord.y == 465)
                {
                          Mix_PlayChannel(2, MenuChoice, 0);
                       //items
                       campEnterKey = 2;
                }
                if (CampCursorCord.y == 504)
                {
                       if (WaitBar2Crop.w == 210)
                       {
                          Mix_PlayChannel(2, MenuChoice, 0);
                       fleeButton = true;
                       }
                       campEnterKey = 2;
                }
           }
           }
           if (!key[SDLK_RETURN])
           {
              campEnterKey = 1;
           }
           }
       }
       }
}

void ActiveBattleFunc()
{
     if (ActiveBattle == true)
     {
         //  Mix_PauseMusic();
          Battle = true;
          ActiveBattle = false;
     }
}

Share this post


Link to post
Share on other sites
wack    1358

 

This is gonna be hard to beat, but look at my first games Menu.h file tongue.png This was written about 3 years ago as well tongue.png The funny part, game works perfectly fine here is a video of it http://www.youtube.com/watch?v=4y-5io98vys

 

 

That's not terrible, I have (many times) seen worse stuff, written by supposed professionals...

Share this post


Link to post
Share on other sites

I see it as very bad. It used to be about getting something working, now it's about getting something working in optimized way hehe :)

 

I can't really imagine anything worse tho. What could they do, What can be worse then having 3000 if statements in one file .h file under one function?

 

...Memory Leaks?

Share this post


Link to post
Share on other sites
LennyLen    5715

 

 

This is gonna be hard to beat, but look at my first games Menu.h file tongue.png This was written about 3 years ago as well tongue.png The funny part, game works perfectly fine here is a video of it http://www.youtube.com/watch?v=4y-5io98vys

 

 

That's not terrible, I have (many times) seen worse stuff, written by supposed professionals...

 

 

There is worse out there, but it's still terrible. ;)

Share this post


Link to post
Share on other sites
Orymus3    18821


If I would write it right now, I would make field on board as its own class. That way, in main code I can simply hold a list of fields and manipulate with it, instead of... doing... what I did.

 

Been there, done that... share your pain, and shame. Just when I thought programming was about handling each case individually with a series of Ifs :)

Share this post


Link to post
Share on other sites
Josip Mati?    1304

Phew, weekend started, now I finally have time to be here a little XD

 

@Konrad Jablonski

Wow, game looks nice. As for the code... at least it's readable XD Now, if you would want to make one change, would you be able to do it without breaking whole thing? XXDD

 

@Arthur Souza

Thanks... I guess XD Wrote first thing which came to my mind, and LotR ended up being that...

 

@Orymus3

People learn whole life ^^ Luckily, I improved my code writing... curently I have about 30 classes of my own all communicating with other objects and/or inheriting other classes - something younger me wouldn't even think about doing.

 

What's even more embarrasing is that instead of using Rectangle to represent each board field and just use Rectangle.Contains(Point) method, I invented hot water. >.<

Share this post


Link to post
Share on other sites

Phew, weekend started, now I finally have time to be here a little XD

 

@Konrad Jablonski

Wow, game looks nice. As for the code... at least it's readable XD Now, if you would want to make one change, would you be able to do it without breaking whole thing? XXDD

 

Well probably not, I haven't touched this code in over 3 years. Now I would use classes and functions for this like any normal person :)

Share this post


Link to post
Share on other sites

When I started XNA, I used to load files whenever I needed them. I recently found my first pong game and I had Content.Load lines all over the place. The nice thing about XNA is that it still worked!! But with a bigger project you  probably don't want Content.Load in the Update or Draw method -.-

Share this post


Link to post
Share on other sites

That reminds me of how I still tend to avoid multithreading like the plague as if I had never used it... even after making a whole sound driver that has to cope with two completely different processors without any proper way to do handshake and the most atomic operation I can get is reading or writing a byte in RAM (I don't even get multibyte values!), which must be like the worst of the worst when it comes to multithreading =P

 

The only time I did it on PC (that didn't involve other library doing it for me - the one I mentioned before was not on PC) was recently in my game for the loading screen (otherwise the game can hang without pumping any events, which can make the OS think it got stuck and try to kill it). Given what I said above, I guess it shouldn't be surprising that it worked on the first try (even if it was quite simplistic).

Edited by Sik_the_hedgehog

Share this post


Link to post
Share on other sites
Josip Mati?    1304

Goodie goodie, look what I found on my old PC from 1991 biggrin.png

Few years ago, I was bored on vacation and all other electronic devices were used by other family members, so I wrote this little gem in QBasic which needs serious refactoring:

CLS

DIM a, b, i, n, s AS INTEGER
DIM button AS STRING
DIM direction AS STRING
DIM x(100) AS INTEGER
DIM y(100) AS INTEGER

s = 0
n = 1
direction = ""
x(1) = 12 '25 max
y(1) = 40 '80 max
RANDOMIZE 1
a = INT(RND * 20) + 3
b = INT(RND * 77) + 2

COLOR 9
PRINT "Welcome to Aurioch's ASCII Snake"
COLOR 3
PRINT CHR$(201); STRING$(78, 205); CHR$(187)
FOR i = 1 TO 20
  PRINT CHR$(186); STRING$(78, " "); CHR$(186)
NEXT i
PRINT CHR$(200); STRING$(78, 205); CHR$(188)
LOCATE 1, 60
COLOR 12
PRINT "Score:"; S

DO
  FOR i = 1 TO n
    LOCATE x(i), y(i)
    COLOR 10
    IF i = 1 THEN
      PRINT CHR$(2)
    ELSE
      PRINT CHR$(254)
    END IF
  NEXT i

  LOCATE a, b
  COLOR 14
  PRINT CHR$(42)
  FOR i = 1 TO 5000 'delay
  NEXT i
  button = INKEY$
  FOR i = 1 TO n
    LOCATE x(i), y(i)
    PRINT " "
  NEXT i

  IF button = "w" THEN direction = "up"
  IF button = "s" THEN direction = "down"
  IF button = "a" THEN direction = "left"
  IF button = "d" THEN direction = "right"

  IF (direction = "up") AND (x(1) > 3) THEN
    IF n > 1 THEN
      FOR i = n TO 2 STEP -1
        x(i) = x(i - 1)
        y(i) = y(i - 1)
      NEXT i
    END IF
    x(1) = x(1) - 1
  END IF

  IF (direction = "right") AND (y(1) < 79) THEN
    IF n > 1 THEN
      FOR i = n TO 2 STEP -1
        x(i) = x(i - 1)
        y(i) = y(i - 1)
      NEXT i
    END IF
    y(1) = y(1) + 1
  END IF

  IF (direction = "down") AND (x(1) < 22) THEN
    IF n > 1 THEN
      FOR i = n TO 2 STEP -1
        x(i) = x(i - 1)
        y(i) = y(i - 1)
      NEXT i
    END IF
    x(1) = x(1) + 1
  END IF

  IF (direction = "left") AND (y(1) > 2) THEN
    IF n > 1 THEN
      FOR i = n TO 2 STEP -1
        x(i) = x(i - 1)
        y(i) = y(i - 1)
      NEXT i
    END IF
    y(1) = y(1) + 1
  END IF

  IF (x(1) = a) AND (y(1) = b) THEN
    a = INT(RND * 20) + 3
    b = INT(RND * 77) + 2
    s = s + n
    n = n + 1
    IF direction = "up" THEN
      x(n) = x(1) + 1
      y(n) = y(1)
    END IF
    IF direction = "down" THEN
      x(n) = x(1) - 1
      y(n) = y(1)
    END IF
    IF direction = "left" THEN
      x(n) = x(1)
      y(n) = y(1) + 1
    END IF
    IF direction = "right" THEN
      x(n) = x(1)
      y(n) = y(1) - 1
    END IF
    LOCATE 1, 66
    PRINT s
  END IF

LOOP UNTIL button = CHR$(27)
COLOR 7
END

Yesterday, I was rewriting it on my laptop and noticed that I made game loop without knowing about it at all XD

Edited by Aurioch

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this