stg > game > StgGame

stg/game/stggame.h : ver090316

  1. #ifndef __STG_GAME_STGGAME_H__
  2. #define __STG_GAME_STGGAME_H__
  3.  
  4. #include <windows.h>
  5. #include <d3d9.h>
  6. #include <d3dx9.h>
  7. #include <boost/smart_ptr.hpp>
  8. #include <boost/signal.hpp>
  9.  
  10. #include "siki/siki.hpp"
  11. #include "siki/d3d/defination.hpp"
  12. #include "siki/d3d/gamebase.hpp"
  13. #include "siki/d3d/igamewindow.hpp"
  14. #include "siki/d3d/scenelist.hpp"
  15.  
  16. #include "scene0.hpp"
  17.  
  18. namespace stg{
  19. namespace game{
  20.  
  21. /****
  22.  **** class StgGame : public siki::d3d::Game
  23.  ****
  24.  **** ゲームを統括するクラス
  25.  ****
  26.  ****
  27.  ****/
  28. class StgGame : public siki::d3d::GameBase{
  29.  
  30. /* デフォルトコンストラクタは使用しない */
  31. StgGame();
  32.  
  33. public:
  34.  
  35. /***
  36.   *** コンストラクタ
  37.   ***/
  38. StgGame(siki::d3d::IGameWindow *gamewindow);
  39.  
  40. /***
  41.   *** デストラクタ
  42.   ***/
  43. virtual ~StgGame();
  44.  
  45. /***
  46.   *** 仮想ウィンドウプロシージャ
  47.   ***/
  48. virtual LRESULT WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
  49.  
  50. /***
  51.   *** シーンの更新、描画を行う
  52.   ***/
  53. virtual void Render();
  54.  
  55. private:
  56.  
  57. /**
  58.   ** インスタンスの初期化を行う
  59.   **/
  60. bool Initialize();
  61.  
  62. private: /* フィールド */
  63.  
  64. /** **/
  65. //Scene0 *m_scene0;
  66. };
  67.  
  68. }} // namespace stg::game
  69.  
  70. #endif // __STG_GAME_STGGAME_H__
  71.  


stg/game/stggame.cpp : ver090316

  1. #include "../StdAfx.h"
  2.  
  3. #include <boost/smart_ptr.hpp>
  4. #include <boost/signal.hpp>
  5.  
  6. #include "stggame.hpp"
  7.  
  8. namespace stg{
  9. namespace game{
  10.  
  11. using namespace siki::d3d;
  12.  
  13. /***
  14.  *** コンストラクタ
  15.  ***/
  16. StgGame::StgGame(IGameWindow *gamewindow) : GameBase(gamewindow){
  17.  
  18. // シーンを作成して
  19. boost::shared_ptr<Scene> scene0(new Scene0(this));
  20.  
  21. // リストに追加
  22. get_scenelist()->Register(scene0);
  23. }
  24.  
  25. /***
  26.  *** 仮想デストラクタ
  27.  ***/
  28. StgGame::~StgGame(){
  29.  
  30. }
  31.  
  32. /***
  33.  *** ゲーム用 仮想ウィンドウプロシージャ
  34.  ***
  35.  ***/
  36. LRESULT StgGame::WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
  37. return siki::d3d::GameBase::WndProc(hwnd, message, wParam, lParam);
  38. }
  39.  
  40. /***
  41.  *** 描画メソッド
  42.  *** ウィンドウループ内の空き時間にGameWindowから呼ばれる
  43.  ***/
  44. void StgGame::Render(){
  45. boost::shared_ptr<IDirect3DDevice9> device = get_d3ddevice();
  46.  
  47. /* 黒で塗りつぶして消去 */
  48. device->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0, 0);
  49.  
  50.  
  51. SafeBeginScene();
  52.  
  53. GameBase::Render();
  54.  
  55. SafeEndScene();
  56.  
  57. device->Present(NULL,NULL,NULL,NULL);
  58. }
  59.  
  60. /**
  61.  ** 初期化
  62.  **
  63.  **/
  64. bool StgGame::Initialize(){
  65.  
  66. return true;
  67. }
  68.  
  69. }} // namespace stg::game
  70.  

[09/03/16 04:20][履歴][編集]
最終更新:2009年03月16日 04:20