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

  1. /*===========================================================================*\
  2. |
  3. |  File:        cgscene.cpp
  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. #include <windows.h>
  31. #include "cgdebug.h"
  32. #include "cgimage.h"
  33. #include "cgscene.h"
  34.  
  35. #define MAX_IMAGES 4
  36.  
  37. /*---------------------------------------------------------------------------*\
  38. |
  39. |       Class CGameScene
  40. |
  41. |  DESCRIPTION:
  42. |       
  43. |
  44. |
  45. \*---------------------------------------------------------------------------*/
  46. CGameScene::CGameScene(
  47.     )
  48. {
  49. }
  50.  
  51. CGameScene::~CGameScene()
  52. {
  53. }
  54.  
  55.  
  56. /*---------------------------------------------------------------------------*\
  57. |
  58. |       Class CGameGruberScene
  59. |
  60. |  DESCRIPTION:
  61. |       
  62. |
  63. |
  64. \*---------------------------------------------------------------------------*/
  65. CGameGruberScene::CGameGruberScene(
  66.     char* pFileName,
  67.     char* pSceneName
  68.     ) : CGameScene(),
  69.         mpImages( NULL )
  70. {
  71.     // get the image info
  72.     char nameBuf[256];
  73.     CGameGruberImage* tempImages[MAX_IMAGES];
  74.  
  75.     // load all images for this scene
  76.     GetPrivateProfileString(
  77.         pSceneName,
  78.         NULL,       // grab all the keys
  79.         "",     // no default
  80.         nameBuf,
  81.         sizeof( nameBuf ),
  82.         pFileName
  83.         );
  84.  
  85.     for (char *pImage = nameBuf; *pImage && (mNumImages < MAX_IMAGES); pImage++, mNumImages++)
  86.     {
  87.         tempImages[mNumImages] = new CGameGruberImage( pImage );
  88.         pImage += lstrlen( pImage );    // move beyond terminator
  89.     }
  90.  
  91.     // now that we know how many there are, allocate our array & copy the temp
  92.     mpImages = new CGameGruberImage*[ mNumImages ];
  93.     CopyMemory( mpImages, tempImages, mNumImages * sizeof( CGameGruberImage* ) );
  94.  
  95.     // !!! for now use 1st image for size
  96.     mMaxX = mpImages[0]->GetWidth();
  97.     mMaxY = mpImages[0]->GetHeight();
  98. }
  99.  
  100. CGameGruberScene::~CGameGruberScene()
  101. {
  102.     if (mpImages)
  103.     {
  104.         for (; mNumImages>0; mNumImages--)
  105.         {
  106.             delete mpImages[mNumImages-1];
  107.         }
  108.  
  109.         delete[] mpImages;
  110.     }
  111. }
  112.  
  113. BOOL
  114. CGameGruberScene::ScrollTo(
  115.     int x,
  116.     int y
  117.     )
  118. {
  119.     // !!! for now, assume 1 image
  120.     return mpImages[0]->ScrollTo(x, y);
  121. }
  122.  
  123. void
  124. CGameGruberScene::Render(
  125.     CGameGDIScreen* pScreen
  126.     )
  127. {
  128.     // !!! for now, assume 1 image
  129.     mpImages[0]->Render( pScreen );
  130. }
  131.