Guest User

Untitled

a guest
Sep 7th, 2012
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.61 KB | None | 0 0
  1. void printBoard(bool bDrop, int player)
  2.     {
  3.         //horizontal index
  4.         cout << "   ";
  5.         for(int xCount=0; xCount<xSize; xCount++)
  6.         {
  7.             cout << xCount << " ";
  8.             if(xCount<10)
  9.             {
  10.                 cout << " ";
  11.             }
  12.         }
  13.         cout << endl;
  14.  
  15.         for(int yCount=0; yCount<ySize; yCount++)
  16.         {
  17.             //vertical index
  18.             cout << yCount << " ";
  19.             if(yCount<10)
  20.             {
  21.                 cout << " ";
  22.             }
  23.  
  24.             //actual board
  25.             for(int xCount=0; xCount<xSize; xCount++)
  26.             {
  27.                 switch(bDrop)
  28.                 {
  29.                     case true:
  30.                         //specific base drop coloring
  31.                         if(plCount==2)
  32.                         {
  33.                             if(player==1)
  34.                             {
  35.                                 if(xCount<xSize/2)
  36.                                 {
  37.                                     SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x47);
  38.                                 }
  39.                             }
  40.                             else if(player==2)
  41.                             {
  42.                                 if(xCount>=xSize/2)
  43.                                 {
  44.                                     SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x47);
  45.                                 }
  46.                             }
  47.                         }
  48.                         else if(plCount==4)
  49.                         {
  50.                             if(player==1)
  51.                             {
  52.                                 if(xCount<xSize/2 && yCount<ySize/2)
  53.                                 {
  54.                                     SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x47);
  55.                                 }
  56.                             }
  57.                             else if(player==2)
  58.                             {
  59.                                 if(xCount>=xSize/2 && yCount<ySize/2)
  60.                                 {
  61.                                     SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x47);
  62.                                 }
  63.                             }
  64.                             else if(player==3)
  65.                             {
  66.                                 if(xCount<xSize/2 && yCount>=ySize/2)
  67.                                 {
  68.                                     SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x47);
  69.                                 }
  70.                             }
  71.                             else if(player==4)
  72.                             {
  73.                                 if(xCount>=xSize/2 && yCount>=ySize/2)
  74.                                 {
  75.                                     SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x47);
  76.                                 }
  77.                             }
  78.                         }
  79.                     case false:
  80.                         double percHealth=(double)(myTiles[xCount][yCount].myBuilding.health)/(double)(myTiles[xCount][yCount].myBuilding.maxHealth);
  81.  
  82.                         //colors the current tile
  83.                         for(int playerCount=1; playerCount<=plCount; playerCount++)
  84.                         {
  85.                             if(myTiles[xCount][yCount].player==playerCount && myTiles[xCount][yCount].myType==tile::abuilding)
  86.                             {
  87.                                 pCol=playerCol.begin()+playerCount-1;
  88.                             }
  89.                         }
  90.  
  91.                         if(percHealth>0.66)
  92.                         {
  93.                             hCol=healthCol.begin();
  94.                         }
  95.                         else if(percHealth>0.33)
  96.                         {
  97.                             hCol=healthCol.begin()+1;
  98.                         }
  99.                         else if(percHealth>0)
  100.                         {
  101.                             hCol=healthCol.begin()+2;
  102.                         }
  103.  
  104.                         if(myTiles[xCount][yCount].myType==tile::abuilding)
  105.                         {
  106.                             SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), *hCol | *pCol);
  107.                         }
  108.                         break;
  109.                 }
  110.                
  111.                 //prints the tiles
  112.                 cout << myTiles[xCount][yCount].symbol;
  113.  
  114.                 SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x07);
  115.                 cout << "  ";
  116.             }
  117.             cout << endl;
  118.         }
  119.  
  120.         //statistics below the board
  121.         for(int playerCount=1; playerCount<=plCount; playerCount++)
  122.         {
  123.             pCol=playerCol.begin()+playerCount-1;
  124.             SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), *pCol);
  125.        
  126.             cout << "P" << playerCount << endl;
  127.  
  128.             //SUBJECT TO CHANGE DUE TO PLAYER CLASS
  129.  
  130.             for(int yCount=0; yCount<ySize; yCount++)
  131.             {
  132.                 for(int xCount=0; xCount<xSize; xCount++)
  133.                 {
  134.                     if(myTiles[xCount][yCount].player==playerCount && myTiles[xCount][yCount].myType==tile::abuilding)
  135.                     {
  136.                         if(myTiles[xCount][yCount].myBuilding.myBuildType==0)
  137.                         {
  138.                             cout << "Base: ";
  139.                         }
  140.                         cout << myTiles[xCount][yCount].myBuilding.health << "/" << myTiles[xCount][yCount].myBuilding.maxHealth << endl;
  141.                     }
  142.                 }
  143.             }
  144.  
  145.             //SUBJECT TO CHANGE DUE TO PLAYER CLASS
  146.         }
  147.         SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x07);
  148.     }
Advertisement
Add Comment
Please, Sign In to add comment