home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1996 December / PCWKCD1296.iso / vjplusb / activex / inetsdk / samples / axscript / spruuids / src / score.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-15  |  3.3 KB  |  85 lines

  1. //---------------------------------------------------------------------------
  2. // Score.h
  3. //---------------------------------------------------------------------------
  4. // Score object to track score, # lives, level.
  5. //---------------------------------------------------------------------------
  6. // (C) Copyright 1992-1996 by Microsoft Corporation.  All rights reserved.
  7. //
  8. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 
  9. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 
  10. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 
  11. // PARTICULAR PURPOSE.
  12. //---------------------------------------------------------------------------
  13.  
  14. //---------------------------------------------------------------------------
  15. // Score class
  16. //---------------------------------------------------------------------------
  17. class CScore
  18.   {
  19. public:
  20.   // *** Constructor / Destructor ***
  21.   static HRESULT CreateScore(HINSTANCE hinst, HWND hwnd, HWND hwndPS, HWND hwndStat,
  22.                              long scoreFirst1Up, long scoreSecond1Up, long dscoreNext1Up,
  23.                              int cship, WORD idbmpShip, WORD idbmpPlus,
  24.                              CScore **ppscoreOut);
  25.   CScore(HINSTANCE hinst, HWND hwnd, HWND hwndPS, HWND hwndStat, long scoreSecond1Up, long scoreFirst1Up, long dscoreNext1Up, int cship, WORD idbmpShip, WORD idbmpPlus);
  26.   ~CScore();
  27.  
  28.   // *** Public methods ***
  29.   void NewGame(void);
  30.   void Add(long d);
  31.   void Paint(HDC hdc);
  32.   void SetStatusText(const char *pszText);
  33.   void Size(int cx, int cy);
  34.  
  35.   // *** Public accessor methods ***
  36.   inline long GetScore(void)      {return m_score;};
  37.   inline void SetScore(int s)     {m_score = s;   InvalidateRect(m_hwnd, &m_rectScore, TRUE);};
  38.   inline long GetLevel(void)      {return m_lvl;};
  39.   inline long GetCShip(void)      {return m_cship;};
  40.   inline void SetLevel(int lvl)   {m_lvl = lvl;   InvalidateRect(m_hwnd, &m_rectLvl,  TRUE);};
  41.   inline void NextLevel(void)     {m_lvl++;       InvalidateRect(m_hwnd, &m_rectLvl,  TRUE);};
  42.   inline void SetCShip(int cship) {m_cship=cship; InvalidateRect(m_hwnd, &m_rectShip, TRUE);};
  43.   inline void ShipKilled(void)    {m_cship--;     InvalidateRect(m_hwnd, &m_rectShip, TRUE);};
  44.   inline int  GetSize(void)       {return m_cyMax;};
  45.  
  46.   // Public members
  47.   long      m_scoreFirst1Up;
  48.   long      m_scoreSecond1Up;
  49.   long      m_dscoreNext1Up;
  50.   short     m_cshipStart;
  51.   long      m_scoreNext1Up; // Inits to m_scoreFirst1Up
  52.  
  53. private:
  54.   // *** Private member variables ***
  55.   // Reset at NewGame()
  56.   long      m_score;        // Inits to 0
  57.   short     m_cship;        // Inits to m_cshipStart
  58.   short     m_lvl;          // Inits to 1
  59.  
  60.   // Static state passed into contructor
  61.   HINSTANCE m_hinst;
  62.   HWND      m_hwnd;
  63.   HWND      m_hwndPS;
  64.   HWND      m_hwndStat;
  65.  
  66.   // State calculated from static state
  67.   RECT      m_rectScore;
  68.   RECT      m_rectShip;
  69.   RECT      m_rectLvl;
  70.   HBITMAP   m_hbmpShip;
  71.   HBITMAP   m_hbmpPlus;
  72.   int       m_cyMax,  m_cyStat;
  73.   int       m_cxShip, m_cyShip;
  74.   int       m_cxPlus, m_cyPlus;
  75.  
  76.   // Set if constructor fails
  77.   static HRESULT s_hr;
  78.  
  79.   // DEBUG info
  80.   #define SIG_Score 'Scor'
  81.   DECLARE_SIGNATURE(SIG_Score);
  82.   };
  83.  
  84. //--- EOF -------------------------------------------------------------------
  85.