home *** CD-ROM | disk | FTP | other *** search
/ NEXT Generation 27 / NEXT27.iso / pc / demos / emperor / dx3.exe / SDK / SAMPLES / IKLOWNS / CGLEVEL.H < prev    next >
C/C++ Source or Header  |  1996-08-28  |  6KB  |  229 lines

  1. /*===========================================================================*\
  2. |
  3. |  File:        cglevel.h
  4. |
  5. |  Description: 
  6. |       
  7. |-----------------------------------------------------------------------------
  8. |
  9. |  Copyright (C) 1995-1996 Microsoft Corporation.  All Rights Reserved.
  10. |
  11. |  Written by Moss Bay Engineering, Inc. under contract to Microsoft Corporation
  12. |
  13. \*===========================================================================*/
  14.  
  15. /**************************************************************************
  16.  
  17.     (C) Copyright 1995-1996 Microsoft Corp.  All rights reserved.
  18.  
  19.     You have a royalty-free right to use, modify, reproduce and 
  20.     distribute the Sample Files (and/or any modified version) in 
  21.     any way you find useful, provided that you agree that 
  22.     Microsoft has no warranty obligations or liability for any 
  23.     Sample Application Files which are modified. 
  24.  
  25.     we do not recomend you base your game on IKlowns, start with one of
  26.     the other simpler sample apps in the GDK
  27.  
  28.  **************************************************************************/
  29.  
  30. #ifndef CGLEVEL_H
  31. #define CGLEVEL_H
  32.  
  33. #include "cgdlist.h"
  34.  
  35. // We use millisecond timing values; our velocity is specified in
  36. // units of (pixels/256) per millisecond
  37. // This macro converts a velocity and elapsed milliseconds into sub-pixels
  38. #define SUBPIXEL_DELTA( vel, ms ) (vel * ms)
  39.  
  40. class CGameTimer;
  41. class CGameInput;
  42. class CGameScreen;
  43. class CGameGraphic;
  44. class CGameCharacter;
  45.  
  46. class CGameLevel
  47. {
  48. public:
  49.     CGameLevel(
  50.         char* pFileName,
  51.         char* pLevelName,
  52.         CGameTimer* pTimer,
  53.         CGameInput* pInput,
  54.         CGameScreen* pScreen
  55.         );
  56.  
  57.     virtual ~CGameLevel();
  58.  
  59.     virtual void Animate(HWND, CGameScreen* pScreen);
  60.  
  61.     virtual int GetOffsetX()
  62.     {
  63.         return mOffsetX;
  64.     }
  65.  
  66.     virtual int GetOffsetY()
  67.     {
  68.         return mOffsetY;
  69.     }
  70.  
  71.     virtual int GetMaxX()
  72.     {
  73.         return mMaxWorldX;
  74.     }
  75.  
  76.     virtual int GetMaxY()
  77.     {
  78.         return mMaxWorldY;
  79.     }
  80.  
  81.     virtual int Screen2WorldX( int screenX )
  82.     {
  83.         return screenX + mOffsetX;
  84.     };
  85.  
  86.     virtual int Screen2WorldY( int screenY )
  87.     {
  88.         return screenY + mOffsetY;
  89.     };
  90.  
  91.     virtual int World2ScreenX( int worldX )
  92.     {
  93.         return worldX - mOffsetX;
  94.     };
  95.  
  96.     virtual int World2ScreenY( int worldY )
  97.     {
  98.         return worldY - mOffsetY;
  99.     };
  100.  
  101.     virtual int Screen2WorldX( int screenX, int parallax )
  102.     {
  103.         return screenX + (mOffsetX >> parallax);
  104.     };
  105.  
  106.     virtual int Screen2WorldY( int screenY, int parallax )
  107.     {
  108.         return screenY + (mOffsetY >> parallax);
  109.     };
  110.  
  111.     virtual int World2ScreenX( int worldX, int parallax )
  112.     {
  113.         return worldX - (mOffsetX >> parallax);
  114.     };
  115.  
  116.     virtual int World2ScreenY( int worldY, int parallax )
  117.     {
  118.         return worldY - (mOffsetY >> parallax);
  119.     };
  120.  
  121.     virtual void SetOffsetX(int newx)
  122.     {
  123.         if ((newx >= 0) && (newx <= mMaxWorldX))
  124.             mOffsetX = newx;
  125.     }
  126.  
  127.     virtual void SetOffsetY(int newy)
  128.     {
  129.         if ((newy >= 0) && (newy <= mMaxWorldY))
  130.             mOffsetY = newy;
  131.     }
  132.  
  133.     virtual void ForceOnScreen(int *x, int *y, int wide, int high, BOOL primary=TRUE);
  134.  
  135.     virtual CGameTimer* GetTimer()
  136.     {
  137.         return mpTimer;
  138.     }
  139.  
  140.     virtual CGameInput* GetInput()
  141.     {
  142.         return mpInput;
  143.     }
  144.  
  145.     virtual CGameScreen* GetScreen()
  146.     {
  147.         return mpScreen;
  148.     }
  149.  
  150.     virtual CGameCharacter * Add(char *name, int curz, 
  151.                                 int curx=0, int cury=0,
  152.                                     void *pObjID=NULL);
  153.  
  154.     virtual void Remove(CGameGraphic * stale)
  155.     {
  156.         if (stale != NULL)
  157.             mpGraphics->Remove(stale);
  158.     }
  159.  
  160.     virtual void AddInvalidRect( LPRECT rect)
  161.     {
  162.         if (mpUpdateList)
  163.             mpUpdateList->AddRect(*rect);
  164.     }
  165.  
  166.     virtual char *GetLevelName()
  167.     {
  168.         return (pLevName);
  169.     }
  170.  
  171.     virtual char *GetProfileName()
  172.     {
  173.         return (pFilName);
  174.     }
  175.  
  176.     virtual char *GetSectionName()
  177.     {
  178.         return (pLevName);
  179.     }
  180.  
  181.     virtual int GetFrameTime()
  182.     {
  183.         return mFrameTime;
  184.     }
  185.  
  186.     virtual void GameOver();
  187.     virtual void StopAnimating();
  188.     virtual void ReSort() 
  189.     {
  190.         mpGraphics->ReSort();
  191.     }
  192.  
  193.     // members which let us access the game type and main characters directly 
  194.     // from within the DLL
  195.     int mGameType;
  196.     int mNumComputerKlowns;
  197.     CGameCharacter *mMainKlown;     // always the main player
  198.     CGameCharacter *mComputerKlowns[4]; // always the computer-generated klown(s)
  199.     CGameCharacter *mSecondKlown;   // second players' klown
  200.     BOOL mFastKlown;
  201.  
  202. protected:
  203.     // a level keeps a linked list of display objects, sorted in z-order
  204.     CGameDisplayList* mpGraphics;   // our set of display objects
  205.     CGameUpdateList * mpUpdateList;
  206.  
  207.     int mMaxWorldX;     // maximum x pixel value in our world
  208.     int mMaxWorldY;     // maximum y pixel value in our world
  209.  
  210.     int mOffsetX;       // current offset of screen within world
  211.     int mOffsetY;       // current offset of screen within world
  212.  
  213.     int mFrameTime;     // time at beginning of current frame
  214.  
  215.     CGameTimer* mpTimer;    // ptr to the game's timer
  216.     CGameInput* mpInput;    // ptr to the game's input object
  217.     CGameScreen* mpScreen;  // ptr to the game's screen object
  218.  
  219.     char *pLevName;
  220.     char *pFilName;
  221.     char *mpGraphicsKey;    // the .gam file section for our graphics list
  222.  
  223.     char* mpProfile;
  224.  
  225.     void MatchProfile( char* pFileName );
  226. };
  227.  
  228. #endif // CGLEVEL_H
  229.