BonusStatus.cpp
上传用户:royluo
上传日期:2007-01-05
资源大小:1584k
文件大小:4k
源码类别:

游戏

开发平台:

Visual C++

  1. /*****************************************************************************
  2. *                                                                             
  3. *   BonusStatus.cpp
  4. *                                                                             
  5. *   Electrical Engineering Faculty - Software Lab                             
  6. *   Spring semester 1998                                                      
  7. *                                                                             
  8. *   Tanks game                                                                
  9. *                                                                             
  10. *   Module description: Implements the bonus status object displayed on the 
  11. *                       main dialog.
  12. *                       
  13. *                                                                             
  14. *   Authors: Eran Yariv - 28484475                                           
  15. *            Moshe Zur  - 24070856                                           
  16. *                                                                            
  17. *                                                                            
  18. *   Date: 23/09/98                                                           
  19. *                                                                            
  20. ******************************************************************************/
  21. #include "stdafx.h"
  22. #include "Tanks.h"
  23. #include "BonusStatus.h"
  24. #ifdef _DEBUG
  25. #define new DEBUG_NEW
  26. #undef THIS_FILE
  27. static char THIS_FILE[] = __FILE__;
  28. #endif
  29. BEGIN_MESSAGE_MAP(CBonusStatus, CButton)
  30.     //{{AFX_MSG_MAP(CBonusStatus)
  31.     ON_WM_QUERYNEWPALETTE()
  32.     ON_WM_PALETTECHANGED()
  33.     //}}AFX_MSG_MAP
  34. END_MESSAGE_MAP()
  35. CBonusStatus::CBonusStatus():
  36.          m_bFastFire (FALSE),
  37.          m_bAerial (FALSE),
  38.          m_bChangeDisplay (TRUE)
  39. {
  40.     m_DIB.CreateEmpty (AMMO_STATUS_WIDTH, MAP_HEIGHT - AMMO_STATUS_HEIGHT);
  41.     m_DIB.GetPaletteFromResourceBitmap (IDB_BULLET);
  42. }
  43. void CBonusStatus::Create ()
  44. {
  45.     m_DIBBomb.ReadFromResource (IDB_BOMB_ICON);
  46.     m_DIBFastFire.ReadFromResource (IDB_FASTFIRE);
  47.     m_uFastFireXPos = (AMMO_STATUS_WIDTH / 2) - (m_DIBFastFire.Width() / 2);
  48.     m_uFastFireYPos = MAP_HEIGHT - AMMO_STATUS_HEIGHT - m_DIBFastFire.Height();
  49.     m_uBombXPos = (AMMO_STATUS_WIDTH / 2) - (m_DIBBomb.Width() / 2);
  50.     m_uBombYPos = m_uFastFireYPos - 10 - m_DIBBomb.Height();
  51. }
  52. void CBonusStatus::SetAerialSupport (BOOL bOn)
  53. {
  54.     m_bAerial = bOn;
  55.     m_bChangeDisplay = TRUE;
  56.     InvalidateRect (NULL, FALSE);
  57. }
  58. void CBonusStatus::SetFastFireRate (BOOL bOn)
  59. {
  60.     m_bFastFire = bOn;
  61.     m_bChangeDisplay = TRUE;
  62.     InvalidateRect (NULL, FALSE);
  63. }
  64. CDIB *CBonusStatus::GetImage ()
  65. {
  66.     if (m_bChangeDisplay)
  67.     {   // Something has changed - recreate image
  68.         m_DIB.FillSolidColor (0,0,0);
  69.         if (m_bFastFire)
  70.             m_DIB.CopyRectFrom (&m_DIBFastFire, 
  71.                                 0, 
  72.                                 0, 
  73.                                 m_DIBFastFire.Width(), 
  74.                                 m_DIBFastFire.Height(), 
  75.                                 m_uFastFireXPos, 
  76.                                 m_uFastFireYPos);
  77.         if (m_bAerial)
  78.             m_DIB.CopyRectFrom (&m_DIBBomb, 
  79.                                 0, 
  80.                                 0, 
  81.                                 m_DIBBomb.Width(), 
  82.                                 m_DIBBomb.Height(), 
  83.                                 m_uBombXPos, 
  84.                                 m_uBombYPos);
  85.         m_bChangeDisplay = FALSE;
  86.     }
  87.     return &m_DIB;
  88. }