home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 605b.lha / Spades_v2.10 / Source / Graphics.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-06  |  4.5 KB  |  157 lines

  1. /*
  2.    FILE: Graphics.c
  3.    PURPOSE: Spades graphics functions
  4.    AUTHOR: Gregory M. Stelmack
  5. */
  6.  
  7. #ifndef GLOBALS_H
  8. #include "Globals.h"
  9. #endif
  10.  
  11. extern struct Image CardImage;
  12.  
  13. /**********************************************************
  14. * Function: SetUpScreen                                   *
  15. * Parameters: none                                        *
  16. * Return Values: none                                     *
  17. * Purpose: gets the screen ready for a new hand.          *
  18. **********************************************************/
  19. void SetUpScreen()
  20. {
  21.    /* Clear the Screen */
  22.  
  23.    SetRast(RP,BLUP);
  24.    SetAPen(RP,YELP);
  25.    SetBPen(RP,BLKP);
  26.  
  27.    /* Draw the Score Box */
  28.  
  29.    Move(RP,215,6);
  30.    Text(RP," YOU   CMP ",11);
  31.    Move(RP,215,14);
  32.    Text(RP,"SCORE SCORE",11);
  33.    Move(RP,215,22);
  34.    Text(RP,"           ",11);
  35.    Move(RP,215,30);
  36.    Text(RP," BID   BID ",11);
  37.    Move(RP,215,38);
  38.    Text(RP,"           ",11);
  39.    Move(RP,215,46);
  40.    Text(RP,"TRICK TRICK",11);
  41.    Move(RP,215,54);
  42.    Text(RP,"           ",11); 
  43.    SetAPen(RP,WHTP);
  44.    Move(RP,215,7);
  45.    Draw(RP,302,7);
  46.    Move(RP,258,0);
  47.    Draw(RP,258,55);
  48. }
  49.  
  50. /**********************************************************
  51. * Function: ShowHand                                      *
  52. * Parameters: none                                        *
  53. * Return Values: none                                     *
  54. * Purpose: To display the player's hand.                  *
  55. **********************************************************/
  56. void ShowHand()
  57. {
  58.    int i;
  59.   
  60.    /* Erase old hand */
  61.   
  62.    SetAPen(RP,BLUP);
  63.    SetOPen(RP,BLUP);
  64.    RectFill(RP,21,145,183,186);
  65.  
  66.    /* Draw each card, overlaying part of the previous one */
  67.  
  68.    for (i=0 ; i<13 ; i++)
  69.    {
  70.       if (Hand[0][i])   /* Only draw if card hasn't been played */
  71.          DrawCard(((i*10)+21),145,((Hand[0][i])-1));
  72.    }
  73. }
  74.  
  75. /**********************************************************
  76. * Function: PrintBids                                     *
  77. * Parameters: none                                        *
  78. * Return Values: none                                     *
  79. * Purpose: Display the number of tricks bid by each team  *
  80. *          in the score box.                              *
  81. **********************************************************/
  82. void PrintBids()
  83. {
  84.    int length=0;
  85.   
  86.    SetAPen(RP,GRNP);
  87.    SetBPen(RP,BLKP);
  88.    itoa(PlayerBid,String);
  89.    length=strlen(String);
  90.    Move(RP,(235-(4*length)),38);
  91.    Text(RP,String,length);
  92.    itoa(CompBid,String);
  93.    length=strlen(String);
  94.    Move(RP,(283-(4*length)),38);
  95.    Text(RP,String,length);
  96. }
  97.  
  98. /**********************************************************
  99. * Function: PrintScore                                    *
  100. * Parameters: none                                        *
  101. * Return Values: none                                     *
  102. * Purpose: Display each team's score in the score box.    *
  103. **********************************************************/
  104. void PrintScore()
  105. {
  106.    int length=0;
  107.   
  108.    SetAPen(RP,GRNP);
  109.    SetBPen(RP,BLKP);
  110.    itoa(PlayerScore,String);
  111.    length=strlen(String);
  112.    Move(RP,(235-(4*length)),22);
  113.    Text(RP,String,length);
  114.    itoa(CompScore,String);
  115.    length=strlen(String);
  116.    Move(RP,(283-(4*length)),22);
  117.    Text(RP,String,length);
  118. }
  119.  
  120. /**********************************************************
  121. * Function: PrintTricks                                   *
  122. * Parameters: none                                        *
  123. * Return Values: none                                     *
  124. * Purpose: Display the number of tricks taken by each     *
  125. *          team in the score box.                         *
  126. **********************************************************/
  127. void PrintTricks()
  128. {
  129.    int length=0;
  130.   
  131.    SetAPen(RP,GRNP);
  132.    SetBPen(RP,BLKP);
  133.    itoa(PlayerTricks,String);
  134.    length=strlen(String);
  135.    Move(RP,(235-(4*length)),54);
  136.    Text(RP,String,length);
  137.    itoa(CompTricks,String);
  138.    length=strlen(String);
  139.    Move(RP,(283-(4*length)),54);
  140.    Text(RP,String,length);
  141. }
  142.  
  143. /**********************************************************
  144. * Function: DrawCard                                      *
  145. * Parameters: x -- x coordinate of top left corner        *
  146. *             y -- y coordinate of top left corner        *
  147. *           card -- number of card to draw                *
  148. * Return Values: none                                     *
  149. * Purpose: Draw a card.                                   *
  150. **********************************************************/   
  151. void DrawCard(x, y, card)
  152. int x, y, card;
  153. {
  154.    CardImage.ImageData = (UWORD *)(CardData+card*126*6);
  155.    DrawImage(RP, &CardImage, x, y);
  156. }
  157.