BackGround.cpp
上传用户:cydong117
上传日期:2009-11-10
资源大小:638k
文件大小:3k
源码类别:

模拟服务器

开发平台:

Visual C++

  1. #include "stdafx.h"
  2. #define AVI_CREATECHAR ".\CreateChr.avi"
  3. #define AVI_STARTGAME ".\StartGame.avi"
  4. #define IMG_IDX_SELECT_CHR_BACK 50
  5. #define IMG_IDX_CREATE_CHR_BACK 90
  6. #define BACK_IMG_POS_X 0
  7. #define BACK_IMG_POS_Y 0
  8. CBackGround::CBackGround()
  9. {
  10. m_nRenderState = 0;
  11. m_pxImage = NULL;
  12. }
  13. CBackGround::~CBackGround()
  14. {
  15. m_xCreateChrAvi.ReleaseAvi();
  16. m_xStartGameAvi.ReleaseAvi();
  17. }
  18. VOID CBackGround::Create(CWHWilImageData* pxImage)
  19. {
  20. m_pxImage = pxImage;
  21. m_xCreateChrAvi.InitAvi(g_xSound.GetSoundObject()->GetDS());
  22. m_xStartGameAvi.InitAvi(g_xSound.GetSoundObject()->GetDS());
  23. }
  24. HRESULT CBackGround::OnKeyDown(WPARAM wParam, LPARAM lParam)
  25. {
  26. return 0;
  27. }
  28. HRESULT CBackGround::OnButtonDown(WPARAM wParam, LPARAM lParam)
  29. {
  30. return 0;
  31. }
  32. HRESULT CBackGround::OnButtonDown(POINT ptMouse)
  33. {
  34. return 0;
  35. }
  36. HRESULT CBackGround::OnButtonUp(WPARAM wParam, LPARAM lParam)
  37. {
  38. return 0;
  39. }
  40. HRESULT CBackGround::OnButtonUp(POINT ptMouse)
  41. {
  42. return 0;
  43. }
  44. LRESULT CBackGround::OnMouseMove(WPARAM wParam, LPARAM lParam)
  45. {
  46. return 0;
  47. }
  48. VOID CBackGround::Render(INT nLoopTime)
  49. {
  50. if(m_fIsActive)
  51. {
  52. switch(m_nRenderState)
  53. {
  54. case _RENDER_STILL_1:
  55. {
  56. m_pxImage->NewSetIndex(IMG_IDX_SELECT_CHR_BACK);
  57. g_xMainWnd.DrawWithImageForComp(BACK_IMG_POS_X, BACK_IMG_POS_Y,
  58. m_pxImage->m_lpstNewCurrWilImageInfo->shWidth,m_pxImage->m_lpstNewCurrWilImageInfo->shHeight,
  59. (WORD*)(m_pxImage->m_pbCurrImage));
  60. break;
  61. }
  62. case _RENDER_AVI_IN:
  63. {
  64. if(!m_xCreateChrAvi.Draw(nLoopTime))
  65. {
  66. m_nRenderState = _RENDER_STILL_2;
  67. }
  68. break;
  69. }
  70. case _RENDER_STILL_2:
  71. {
  72. m_pxImage->NewSetIndex(IMG_IDX_CREATE_CHR_BACK);
  73. g_xMainWnd.DrawWithImageForComp(BACK_IMG_POS_X, BACK_IMG_POS_Y,
  74. m_pxImage->m_lpstNewCurrWilImageInfo->shWidth,m_pxImage->m_lpstNewCurrWilImageInfo->shHeight,
  75. (WORD*)(m_pxImage->m_pbCurrImage));
  76. break;
  77. }
  78. case _RENDER_AVI_OUT:
  79. {
  80. if(!m_xCreateChrAvi.Draw(nLoopTime))
  81. m_nRenderState = _RENDER_STILL_1;
  82. break;
  83. }
  84. case _RENDER_AVI_START:
  85. {
  86. if(!m_xStartGameAvi.Draw(nLoopTime))
  87. m_nRenderState = _RENDER_STARTGAME;
  88. break;
  89. }
  90. }
  91. }
  92. }
  93. VOID CBackGround::SetRenderState(INT nState)
  94. {
  95. RECT tRect;
  96. SetRect(&tRect,0,0,640,480);
  97. AllStopAvi();
  98. switch(m_nRenderState)
  99. {
  100. case _RENDER_AVI_IN:
  101. case _RENDER_AVI_OUT:
  102. m_xCreateChrAvi.Stop();
  103. break;
  104. case _RENDER_AVI_START:
  105. m_xStartGameAvi.Stop();
  106. break;
  107. }
  108. m_nRenderState = nState;
  109. switch(m_nRenderState)
  110. {
  111. case _RENDER_AVI_IN:
  112. {
  113. m_xCreateChrAvi.Create(AVI_CREATECHAR, FALSE);
  114. m_xCreateChrAvi.SetDestRect(tRect);
  115. m_xCreateChrAvi.Start();
  116. break;
  117. }
  118. case _RENDER_AVI_OUT:
  119. {
  120. m_xCreateChrAvi.Create(AVI_CREATECHAR, FALSE,FALSE);
  121. m_xCreateChrAvi.SetDestRect(tRect);
  122. m_xCreateChrAvi.Start();
  123. break;
  124. }
  125. case _RENDER_AVI_START:
  126. {
  127. m_xStartGameAvi.Create(AVI_STARTGAME,FALSE);
  128. m_xStartGameAvi.SetDestRect(tRect);
  129. m_xStartGameAvi.Start();
  130. break;
  131. }
  132. }
  133. }
  134. INT CBackGround::GetRenderState(VOID)
  135. {
  136. return m_nRenderState;
  137. }
  138. VOID CBackGround::AllStopAvi(VOID)
  139. {
  140. m_xCreateChrAvi.Stop();
  141. m_xStartGameAvi.Stop();
  142. }