home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 11 Learning / 04 Mommersteeg / Tennis / tennisfield.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-23  |  2.0 KB  |  62 lines

  1. //----------------------------------------------------------------------------------------------
  2. // Sequential Prediction Demo: The positioning pattern
  3. // 
  4. // Author:  Fri Mommersteeg
  5. // Date:    10-09-2001
  6. // File:    TennisField.h
  7. //----------------------------------------------------------------------------------------------
  8.  
  9. #ifndef __TENNISFIELD_H
  10. #define __TENNISFIELD_H
  11.  
  12. //----------------------------------------------------------------------------------------------
  13. // Include files
  14. //----------------------------------------------------------------------------------------------
  15.  
  16. #include "paddle.h"
  17. #include "ball.h"
  18. #include "observer.h"
  19.  
  20. //----------------------------------------------------------------------------------------------
  21. // Defined constants
  22. //----------------------------------------------------------------------------------------------
  23.  
  24. #define PLAYER1    0
  25. #define PLAYER2    1
  26. #define NET_WIDTH  5
  27. #define NET_HEIGHT 0 // disable net
  28.  
  29. //----------------------------------------------------------------------------------------------
  30. // CTennisField: Manages the game objects
  31. //----------------------------------------------------------------------------------------------
  32.  
  33. class CTennisField : public CObserver {
  34.  
  35. public:
  36.  
  37.     void            SetupField(LPRECT pField, CPaddle * Player1, CPaddle * Player2, CTennisBall * Ball);
  38.     void            Update();
  39.     BOOL            Notify(int msg, DWORD param);
  40.     void            SetupService(int ServicePlayer);
  41.     void            NetCollision();
  42.     void            Start() { StartTime = timeGetTime()-1000; nFrameCount = DEFAULT_SPEED; }
  43.  
  44. protected:
  45.     BOOL            BallInField(int index, POINT pt);
  46.     void            PlayerScores(int index);
  47.     void            ShowPlayerScore(HDC dc, int x, int y, int PlayerId);
  48.     void            ShowFPS(HDC dc, int x, int y);
  49.  
  50. protected:
  51.  
  52.     HWND            hWnd;
  53.     RECT            field;
  54.     CPaddle *        player[2];    
  55.     CTennisBall *    ball;
  56.     DWORD            StartTime;
  57.     DWORD            nFrameCount;
  58. };
  59.  
  60. //----------------------------------------------------------------------------------------------
  61. #endif // __TENNISFIELD_H
  62.