ã¯ããã«
ããã§ãæãªãšãã«äººæ°ã®ããã°ã©ãã£ãã¯APIãå匷ããããšã«ããŸããã ããã€ãã®æ¬ãèªãã§ãå€ãã®äŸãšãã¥ãŒããªã¢ã«ïŒDirectX SDKãå«ãïŒã調ã¹ãåŸãèªåã§æãè©Šãã¹ãæãæ¥ãŠããããšã«æ°ä»ããŸããã äž»ãªåé¡ã¯ãæ¢åã®äŸã®ã»ãšãã©ããããŸãã¯ãã®APIæ©èœãåã«ç€ºããã»ãŒ1ã€ã®cppãã¡ã€ã«ã§æç¶ãçã«å®è£ ãããDXUTã©ãããŒã䜿çšããŠããæçµçãªã¢ããªã±ãŒã·ã§ã³ãã©ã®ãããªæ§é ãæã£ãŠããã¹ãããç¥ããªãããšã§ãããã¹ãŠã®ã¯ã©ã¹ãçŸãããèªã¿ããããå¹ççã«æ©èœããããã«ãã©ã®ã¯ã©ã¹ãèšèšããå¿ èŠããããã©ã®ããã«çžäºäœçšãããã ãã®æ¬ ç¹ã¯Direct3Dããã¯ã«é©çšãããŸããããšãã°ãå€ãã®åå¿è ã«ãšã£ãŠãåãã¬ãŒã ãã¬ã³ããªã³ã°ãããšãã«ã¬ã³ããªã³ã°ç¶æ ãåžžã«æŽæ°ããå¿ èŠãããããã§ã¯ãªããã»ãšãã©ã®éãæäœïŒé ç¹ãããã¡ãŒã®å å¡«ãªã©ïŒãå®è¡ããå¿ èŠãããããšãæããã§ã¯ãããŸããã¢ããªã±ãŒã·ã§ã³ã®åæåäžïŒãŸãã¯ã²ãŒã ã¬ãã«ã®ããŒãäžïŒã«1åã®ã¿ã
ã¢ã€ãã¢
ã²ãŒã ã®ã¢ã€ãã¢ãã®ãã®ã決ããããã«æåã«å¿ èŠãªããšã MS-DOSã®äžã§ã®1992幎ã®å€ãã²ãŒã ã¯ããã«æãæµ®ãã³ãŸããã ããã¯Gamosããžãã¯ã²ãŒã Linesã§ãã
ããŠãé»è©±ã¯åãå ¥ããããŸããã ããã«ç§ãã¡ãæã£ãŠãããã®ããããŸãïŒ
- ã»ã«ã®æ£æ¹åœ¢ã®ãã£ãŒã«ãããããŸãã
- ãã£ãŒã«ãã®ã»ã«ã«ã¯ã«ã©ãã«ãªããŒã«ããããŸãã
- ããŒã«ã移åããåŸãæ°ããããŒã«ã衚瀺ãããŸãã
- ãã¬ãŒã€ãŒã®ç®æšã¯ã1è²ã®ããŒã«ãäžåã«äžŠã¹ãããšã§ããç¹å®ã®æ°ã®1è²ã®ããŒã«ã1è¡ã«èç©ãããšãççºãšãã€ã³ãã®ç²åŸã«ã€ãªãããŸãã
- äž»ãªã¿ã¹ã¯ã¯ããã£ãŒã«ãäžã§ç©ºãã»ã«ããªããªããŸã§å¯èœãªéãé·ãããããšã§ãã
次ã«ãDirect3Dã¢ããªã±ãŒã·ã§ã³ã®èŠç¹ãèŠãŠã¿ãŸãããã
- ã»ã«ã®ãã£ãŒã«ããçªèµ·ã®ãã3次å ãã©ãããã©ãŒã ã®åœ¢ã§äœæããŸããåã»ã«ã¯è¡šåœ°å°ã®ãããªãã®ã«ãªããŸãã
- 3çš®é¡ã®ããŒã«ã¢ãã¡ãŒã·ã§ã³ãå®è£
ããå¿
èŠããããŸãã
- ããŒã«ã®å€èŠ³ïŒæåã«å°ããªããŒã«ã衚瀺ãããããã«å€§äººã®ãµã€ãºã«æé·ããŸãã
- ããŒã«ã®ç§»åïŒã»ã«å ã®åçŽãªé£ç¶ç§»åã
- ãžã£ã³ãããŒã«ïŒããŠã¹ã§ããŒã«ãéžæãããšãã¢ã¯ãã£ãã«ãªããæå®ã®äœçœ®ã«ãžã£ã³ããå§ããŸãã
- ççºã®ã¢ãã¡ãŒã·ã§ã³ã§äœ¿çšãããããŒãã£ã¯ã«ã·ã¹ãã ãå®è£ ããå¿ èŠããããŸãã
- ããã¹ãã®åºåãå®è£ ããå¿ èŠããããŸããç²åŸãããã€ã³ããç»é¢ã«è¡šç€ºããŸãã
- ä»®æ³ã«ã¡ã©å¶åŸ¡ãå®è£ ããå¿ èŠããããŸãïŒå転ãšãºãŒã ã
å®éãäžèšã®ãã€ã³ãã¯ãèšèšãããžã§ã¯ããšåŒã°ããææžã®æ²æšãªé¡äŒŒç¹ã§ãã éçºãéå§ããåã«ããã®äžã®ãã¹ãŠã现éšãŸã§ãã€ã³ãããå°å·ããŠç®ã®åã«çœ®ãããšã匷ããå§ãããŸãïŒ ä»åŸãã¢ã€ãã ã®å®è£ ãæ確ã«ããããã«ãã¢ãããªãããã«è¡šç€ºããŸãïŒã¡ãªã¿ã«ããããªã¯ezvidããã°ã©ã ã䜿çšããŠèšé²ãããã®ã§ãæåã®ã¹ãã©ãã·ã¥ã¹ã¯ãªãŒã³ã«é©ããªãã§ãã ããïŒã
éçºéå§
ãããŸã§ã®ãšãããã©ã®ããŒã«ã䜿çšããããã¯èšåããŠããŸããã ãŸããDirectXãœãããŠã§ã¢éçºãããïŒSDKïŒãå¿ èŠã§ããããã¯ãMicrosoft Webãµã€ãDirectX SDKããåžžã«ç¡æã§ããŠã³ããŒãã§ããŸã ã ç§ã®ãããªDirect3D 9ã®ããŒãžã§ã³ã䜿çšããå Žåã¯ãã€ã³ã¹ããŒã«åŸã«ã¡ã€ã³ã¡ãã¥ãŒããDirectXã³ã³ãããŒã«ããã«ãéããDirect3D 9ã¿ãã§ã¢ã»ã³ããªäžã«äœ¿çšããã©ã€ãã©ãªã®ããŒãžã§ã³ãéžæããå¿ èŠããããŸã-å°å£²ãŸãã¯ãããã°ïŒããã¯Direct3Dãã¬ããŒããããã©ããã«åœ±é¿ããŸããããã¬ã®ã¢ã¯ãã£ããã£ã®çµæã«ã€ããŠïŒïŒ
ãããã°ãŸãã¯ãªããŒã«
Direct3DããŒãžã§ã³9ã¯ãªãã§ããïŒ ããã¯ææ°ããŒãžã§ã³ã§ãããããåºå®æ©èœãã€ãã©ã€ã³ãã€ãŸããããšãã°ãç §æã®èšç®ãé ç¹ã®åŠçããã¬ã³ããªã©ã®æ©èœãå«ãåºå®ã°ã©ãã£ãã¯ãã€ãã©ã€ã³ãååšããŸãã 10çªç®ã®ããŒãžã§ã³ãããéçºè ã¯ãããã®æ©èœãã·ã§ãŒããŒã«åå¥ã«å®è£ ããããã«æåŸ ãããŠããŸããããã¯è°è«ã®äœå°ã®ãªãå©ç¹ã§ãããDirect3Dã®æåã®å®éšã§ã¯ç解ãã«ãããšæããŸãã
ãªãã³ãŒã::ãããã¯ãªã®ãïŒ ãããããã¯ãã¹ãã©ãããã©ãŒã IDEã䜿çšããŠãéã¯ãã¹ãã©ãããã©ãŒã APIã䜿çšããã¢ããªã±ãŒã·ã§ã³ãéçºããã®ã¯æããªããšã§ããã Just Code ::ãããã¯ã¯ãVisual Studioã®æ°åã®ã¹ããŒã¹ããå¿ èŠãšããŸããã
Direct3Dã䜿çšããéçºã®éå§ã¯éåžžã«ç°¡åã§ããã Code ::ãããã¯ã§ã¯ç©ºã®ãããžã§ã¯ããäœæãããã«ããªãã·ã§ã³ã§ã¯2ã€ã®ããšãããªããã°ãªããŸããã§ããã
1ïŒ[æ€çŽ¢ãã£ã¬ã¯ããª]ã¿ããš[ã³ã³ãã€ã©]ãµãã¿ãã§ãã€ã³ã¯ã«ãŒãDirectX SDKãã£ã¬ã¯ããªãžã®ãã¹ãè¿œå ããŸã-ããšãã°ã次ã®ããã«ïŒ
æ€çŽ¢ãã£ã¬ã¯ããª
2ïŒ[ãªã³ã«ãŒ]ã¿ãã§ã2ã€ã®ã©ã€ãã©ãªd3d9.libãšd3dx9.libãè¿œå ããŸãã
ãªã³ã«ãŒ
ãã®åŸãDirect3DããããŒãã¡ã€ã«ãã¢ããªã±ãŒã·ã§ã³ã®ãœãŒã¹ã³ãŒãã«å«ããå¿ èŠããããŸãã
#include "d3d9.h" #include "d3dx9.h"
ã¢ããªã±ãŒã·ã§ã³æ§é
ããã§æåã®ééããç¯ããŸãããã©ã®ãã¶ã€ã³ãã¿ãŒã³ãéžæããããèãå§ããŸããã MVCïŒmodel-view-controllerïŒãæé©ã§ãããšããçµè«ã«éããŸãããã¢ãã«ã¯ã²ãŒã ïŒã²ãŒã ïŒã®ã¯ã©ã¹ã§ããããã¹ãŠã®ããžãã¯-移åãã¹ã®èšç®ãããŒã«ã®å€èŠ³ãççºçãªçµã¿åããã®åæãå«ã¿ãŸãã ãã¬ãŒã³ããŒã·ã§ã³ã¯ãšã³ãžã³ã¯ã©ã¹ã«ãªããDirect3Dã®ã¬ã³ããªã³ã°ãšå¯Ÿè©±ãè¡ããŸãã ã³ã³ãããŒã©ãŒã¯ã©ãããŒèªäœïŒã¢ããªïŒã«ãªããŸããããã«ã¯ãã¡ãã»ãŒãžåŠçãµã€ã¯ã«ããŠãŒã¶ãŒå ¥ååŠçããããŠæãéèŠãªç¶æ ãããŒãžã£ãŒãå«ãŸããã²ãŒã ãšãšã³ãžã³ãªããžã§ã¯ãã®çžäºäœçšãä¿èšŒãããŸãã ãã¹ãŠãåçŽãªããã§ãããããŒãã¡ã€ã«ãæžãå§ããããšãã§ããŸãããããã«ã¯ãããŸããã§ããïŒ ãã®æ®µéã§ã¯ããããã®ã¯ã©ã¹ã«å¿ èŠãªã¡ãœãããããã²ãŒãããŠç解ããããšã¯éåžžã«å°é£ã§ããããšãå€æããŸããã çµéšã®å®å šãªæ¬ åŠãç§ã«åœ±é¿ãäžããããšã¯æããã§ãããç§ã¯æ¬ã®ããããã®ã¢ããã€ã¹ã«é Œãããšã«æ±ºããŸããã ãæåããå®ç§ãªã³ãŒããæžãããšããªãã§ãã ãããéæé©ã§æ··andãšããŸãã çµæãšããŠã ãã§ã«æ©èœããŠããã¬ã€ã¢ãŠãããªãã¡ã¯ã¿ãªã³ã°ããããã€ãã®å埩ã®åŸã3ã€ã®äž»èŠãªã¯ã©ã¹ã®å®çŸ©ã¯æ¬¡ã®åœ¢åŒãåããŸããã
ã¯ã©ã¹tgame
class TGame { private: BOOL gameOver; TCell *cells; WORD *path; WORD pathLen; LONG score; void ClearField(); WORD GetSelected(); WORD GetNeighbours(WORD cellId, WORD *pNeighbours); BOOL CheckPipeDetonate(WORD *pPipeCells); public: TGame(); ~TGame(); void New(); BOOL CreateBalls(WORD count); void Select(WORD cellId); BOOL TryMove(WORD targetCellId); BOOL DetonateTest(); WORD GetNewBallList(TBallInfo **ppNewList); WORD GetLastMovePath(WORD **ppMovePath); WORD GetDetonateList(WORD **ppDetonateList); LONG GetScore(); BOOL IsGameOver(); };
ã¯ã©ã¹tengine
class TEngine { private: HWND hWindow; RECT WinRect; D3DXVECTOR3 CameraPos; LPDIRECT3D9 pD3d; LPDIRECT3DDEVICE9 pDevice; LPDIRECT3DTEXTURE9 pTex; LPD3DXFONT pFont; D3DPRESENT_PARAMETERS settings; clock_t currentTime; TGeometry *cellGeometry; TGeometry *ballGeometry; TParticleSystem *psystem; TBall *balls; TAnimate *jumpAnimation; TAnimate *moveAnimation; TAnimate *appearAnimation; LONG score; void InitD3d(); void InitGeometry(); void InitAnimation(); void DrawPlatform(); void DrawBalls(); void UpdateView(); public: TEngine(HWND hWindow); ~TEngine(); void AppearBalls(TBallInfo *ballInfo, WORD count); void MoveBall(WORD *path, WORD pathLen); void DetonateBalls(WORD *detonateList, WORD count); BOOL IsSelected(); BOOL IsMoving(); BOOL IsAppearing(); BOOL IsDetonating(); void OnResetGame(); WORD OnClick(WORD x, WORD y, BOOL *IsCell); void OnRotateY(INT offset); void OnRotateX(INT offset); void OnZoom(INT zoom); void OnResize(); void OnUpdateScore(LONG score); void Render(); };
TApplicationã¯ã©ã¹
class TApplication { private: HINSTANCE hInstance; HWND hWindow; POINT mouseCoords; TEngine* engine; TGame* game; BOOL moveStarted; BOOL detonateStarted; BOOL appearStarted; void RegWindow(); static LRESULT CALLBACK MsgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); void ProcessGame(); public: TApplication(HINSTANCE hInstance, INT cmdShow); ~TApplication(); TEngine* GetEngine(); TGame* GetGame(); INT MainLoop(); };
TGameã¯ã©ã¹ã«ã¯ããŠãŒã¶ãŒèªèº«ãéå§ã§ãã3ã€ã®ã¡ãœããïŒNewïŒæ°ããã²ãŒã ïŒãSelectïŒããŒã«ã®éžæïŒãTryMoveïŒããŒã«ã®ç§»åã®è©Šã¿ïŒïŒã®ã¿ããããŸãã æ®ãã¯è£å©çãªãã®ã§ãç¹å¥ãªå Žåã«ã³ã³ãããŒã©ãŒã«ãã£ãŠåŒã³åºãããŸãã ããšãã°ãDetonateTestïŒççºçãªçµã¿åããã®ãã¹ãïŒã¯ãæ°ããããŒã«ãåºçŸããåŸããŸãã¯ç§»åãè©Šã¿ãåŸã«åŒã³åºãããŸãã GetNewBallListãGetLastMovePathãGetDetonateListã¯ãç¹å®ã®ããŒã«ã®ãªã¹ããååŸããäœããæç»ããåŠçã®ããã«ãšã³ãžã³ãªããžã§ã¯ãã«æž¡ãããã«ãããŒã«ã®åºçŸåŸã移ååŸãççºåŸã«ããããåŒã³åºãããŸãã ã³ã¡ã³ãä»ãã®ãœãŒã¹ã³ãŒãããããããTGameã®ããžãã¯ã«ã€ããŠè©³ãã説æããããããŸããã ããŒã«ã®ç§»åçµè·¯ã®æ±ºå®ã¯ããã¹ãŠã®ãšããžã®éã¿ãçããç¡åã°ã©ãã䜿çšãããã€ã¯ã¹ãã©ã¢ã«ãŽãªãºã ã䜿çšããŠå®è£ ãããŠãããšããèšããŸããã
ãšã³ãžã³ãšã³ã³ãããŒã©ãŒã®ã¯ã©ã¹ãããã«è©³ããèããŠã¿ãŸãããã
Tengine
- ãã®ã¯ã©ã¹ã¯ããŠã£ã³ããŠãšãã®é·æ¹åœ¢ã®ãã³ãã«ãæ ŒçŽããããã®ãã£ãŒã«ããå®çŸ©ããŸãã ãããã¯OnResizeã¡ãœããã§äœ¿çšãããŸãããã®ã¡ãœããã¯ããŠã£ã³ããŠã®ãµã€ãºãå€æŽããããšãã«ã³ã³ãããŒã©ãŒãæ°ããæ圱è¡åãèšç®ããããã«åŒã³åºããŸãã
- CameraPosãã£ãŒã«ãã«ã¯ãã¯ãŒã«ã空éã§ã®èŠ³æž¬è ã®åº§æšãæ ŒçŽãããŸãã ç§ã®èãã«ããã°ãã«ã¡ã©ã¯åžžã«åç¹ã«åããããŠããã®ã§ãèŠç·ã®æ¹åãã¯ãã«ã¯ä¿åããå¿ èŠã¯ãããŸããããããã¯ã¡ãªã¿ã«ãã©ãããã©ãŒã ã®äžå¿ãšäžèŽããŸãã
- Direct3Dã€ã³ã¿ãŒãã§ã€ã¹ãžã®ãã€ã³ã¿ãŒããããŸããLPDIRECT3D9ã¯ãããã€ã¹ã®äœæã«ã®ã¿å¿ èŠã§ãã LPDIRECT3DDEVICE9-å®éã«ã¯ãDirect3Dããã€ã¹èªäœãæäœããªããã°ãªããªãã¡ã€ã³ã€ã³ã¿ãŒãã§ã€ã¹ã ããã¹ãããã³ãã¯ã¹ãã£ãæäœããããã®LPD3DXFONTããã³LPDIRECT3DTEXTURE9ã
- currentTimeãã£ãŒã«ãã¯çŸåšã®æéãããªç§åäœã§ä¿åããããã«äœ¿çšãããã¹ã ãŒãºãªã¢ãã¡ãŒã·ã§ã³ãã¬ã³ããªã³ã°ããããã«å¿ èŠã§ãã å®éã«ã¯ãåãã¬ãŒã ã®æç»ã«ã¯ç°ãªãããªç§æ°ããããããããããã®ããªç§ãæ¯å枬å®ããã¢ãã¡ãŒã·ã§ã³ãè£éããéã®ãã©ã¡ãŒã¿ãŒãšããŠäœ¿çšããå¿ èŠããããŸãã ãã®æ¹æ³ã¯æéåæãšåŒã°ããææ°ã®ã°ã©ãã£ãã¯ã¹ã¢ããªã±ãŒã·ã§ã³ã®ããããå Žæã§äœ¿çšãããŠããŸãã
- TGeometryã¯ã©ã¹ã®ãªããžã§ã¯ãïŒcellGeometryããã³ballGeometryïŒãžã®ãã€ã³ã¿ãŒã¯ã1ã€ã®ã»ã«ãš1ã€ã®ããŒã«ã®ãžãªã¡ããªãæ ŒçŽããŸãã TGeometryãªããžã§ã¯ãèªäœã¯ããã®ååã瀺ããšããããžãªã¡ããªãæäœããããã«èšèšãããŠãããé ç¹ãããã¡ãŒãšã€ã³ããã¯ã¹ãããã¡ãŒãããã³ãããªã¢ã«ã®èª¬æïŒD3DMATERIAL9ïŒãå«ãŸããŠããŸãã ã¬ã³ããªã³ã°ãããšããã¯ãŒã«ããããªãã¯ã¹ãå€æŽããTGeometryãªããžã§ã¯ãã®Renderã¡ãœãããåŒã³åºãããšãã§ããŸããããã«ãããããã€ãã®ã»ã«ãŸãã¯ããŒã«ãæç»ãããŸãã
- TParticleSystemã¯ãè€æ°ã®ããŒãã£ã¯ã«ãåæåãã空éå ã®äœçœ®ãæŽæ°ãããããŠãã¡ããã¬ã³ããªã³ã°ããããã®ã¡ãœãããæã€ããŒãã£ã¯ã«ã·ã¹ãã ã¯ã©ã¹ã§ãã
- TBall *ããŒã«-è²ãšç¶æ [ãžã£ã³ãã移åã衚瀺]ã«é¢ããæ å ±ãæã€ããŒã«ã®é åã
- ã¿ã€ãTAnimateã®3ã€ã®ãªããžã§ã¯ã-ã¢ãã¡ãŒã·ã§ã³ãæäŸããŸãã ãã®ã¯ã©ã¹ã«ã¯ãäžçã®å€æè¡åã§ããããŒãã¬ãŒã ãåæåããã¡ãœãããšãã¢ãã¡ãŒã·ã§ã³ã®çŸåšã®äœçœ®ãèšç®ããŠå€æãé©çšããã¡ãœããããããŸãã ã¬ã³ããªã³ã°æé ã§ã¯ããšã³ãžã³ãªããžã§ã¯ããããŒã«ãé çªã«æç»ããå¿ èŠã«å¿ããŠãç®çã®ã¢ãã¡ãŒã·ã§ã³ã®ApplyTransformã¡ãœãããåŒã³åºããŠããŒã«ãã¯ãŒããŸãã¯ç§»åããŸãã
- InitD3dãInitGeometryãInitAnimationã¯TEngineã³ã³ã¹ãã©ã¯ã¿ãŒããã®ã¿åŒã³åºãããæ確ã«ããããã«åå¥ã®ã¡ãœããã«åããããŸãã Direct3Dããã€ã¹ã¯InitD3dã§äœæãããå¿ èŠãªãã¹ãŠã®ã¬ã³ããªã³ã°ç¶æ ãã€ã³ã¹ããŒã«ãããŸããããã«ã¯ããã©ãããã©ãŒã ã®äžå¿ã®çäžã«ã¹ããã¥ã©ãŒã³ã³ããŒãã³ããæã€ç¹å æºã®ã€ã³ã¹ããŒã«ãå«ãŸããŸãã
- AppearBallsãMoveBallãããã³DetonateBallsã®3ã€ã®ã¡ãœããã¯ãããããå€èŠ³ãåããççºã®ã¢ãã¡ãŒã·ã§ã³ãããªã¬ãŒããŸãã
- IsSelectedãIsMovingãIsAppearingãIsDetonatingã¡ãœããã¯ãã¢ãã¡ãŒã·ã§ã³ãçµäºããç¬éã远跡ããããã«ç¶æ ãããŒãžã£ãŒé¢æ°ã§äœ¿çšãããŸãã
- Onãã¬ãã£ãã¯ã¹ãæã€ã¡ãœããã¯ã察å¿ããã€ãã³ããçºçãããšãã«ã³ã³ãããŒã©ãŒã«ãã£ãŠåŒã³åºãããŸãïŒããŠã¹ã¯ãªãã¯ãã«ã¡ã©ã®å転ãªã©ã
ã¡ã€ã³ã®Renderã¡ãœãããæ€èšããŠãã ããã
TEngine ::ã¬ã³ããªã³ã°ïŒïŒ
void TEngine::Render() { //, clock_t elapsed=clock(), deltaTime=elapsed-currentTime; currentTime=elapsed; // , if(jumpAnimation->IsActive()) { jumpAnimation->UpdatePosition(deltaTime); } if(appearAnimation->IsActive()) { appearAnimation->UpdatePosition(deltaTime); } if(moveAnimation->IsActive()) { moveAnimation->UpdatePosition(deltaTime); } pDevice->Clear(0,NULL,D3DCLEAR_STENCIL|D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,D3DCOLOR_XRGB(0,0,0),1.0f,0); pDevice->BeginScene(); // DrawPlatform(); // DrawBalls(); // , if(psystem->IsActive()) { pDevice->SetTexture(0,pTex); psystem->Update(deltaTime); psystem->Render(); pDevice->SetTexture(0,0); } // char buf[255]="Score: ",tmp[255]; itoa(score,tmp,10); strcat(buf,tmp); RECT fontRect; fontRect.left=0; fontRect.right=GetSystemMetrics(SM_CXSCREEN); fontRect.top=0; fontRect.bottom=40; pFont->DrawText(NULL,_T(buf),-1,&fontRect,DT_CENTER,D3DCOLOR_XRGB(0,255,255)); pDevice->EndScene(); pDevice->Present(NULL,NULL,NULL,NULL); }
æåã«ãååã®RenderïŒïŒã®åŒã³åºãããçµéããããªç§æ°ãèšç®ããããã®åŸãã¢ãã¡ãŒã·ã§ã³ãã¢ã¯ãã£ããªå Žåã¯é²è¡ãæŽæ°ãããŸãã ãããã¡ã¯Clearã¡ãœããã䜿çšããŠã¯ãªã¢ããããã©ãããã©ãŒã ãããŒã«ãããã³ããŒãã£ã¯ã«ã·ã¹ãã ãã¢ã¯ãã£ããªå Žåã¯é çªã«æç»ãããŸãã æåŸã«ãç²åŸãããã€ã³ãã®çŸåšã®å€ãå«ãè¡ã衚瀺ãããŸãã
Tã¢ããªã±ãŒã·ã§ã³
- ãã®ã¯ã©ã¹ã«ã¯ãã«ã¡ã©ãå転ãããããã«çžå¯Ÿçãªã«ãŒãœã«ãªãã»ãããèšç®ããå¿ èŠããããããããŠã¹åº§æšãæ ŒçŽãããã£ãŒã«ãããããŸãã
- 察å¿ããã¢ãã¡ãŒã·ã§ã³ã®ã¹ããŒã¿ã¹ã远跡ããã«ã¯ãbooleanãã©ã°ãappearStartedãmoveStartedãããã³detonateStartedãå¿ èŠã§ãã
- ãŠã£ã³ããŠã¯ã©ã¹ãç»é²ããããã®ã³ãŒãã¯ãRegWindowã¡ãœããã«ç§»åãããŸããã
- MsgProcéçã¡ãœããã¯ããããããŠã£ã³ããŠããã·ãŒãžã£ã§ãã
- ProcessGameã¯ç¶æ ãããŒãžã£ãŒã®ç°¡æããŒãžã§ã³ã§ãã²ãŒã ã®çŸåšã®ç¶æ ãè©äŸ¡ãããããã«å¿ããŠããã€ãã®ã¢ã¯ã·ã§ã³ãå®è¡ãããŸãã
- MainLoop-ã¡ãã»ãŒãžåŠçã«ãŒãã
ããããã®ãããªè»œéã®ã³ã³ãããŒã©ãŒã§ãã åæ§ã®ã¡ãã»ãŒãžåŠçã«ãŒãã¯ãDirect3Dããã¯ã§èŠã€ããããšãã§ããŸãã
TApplication :: MainLoopïŒïŒ
INT TApplication::MainLoop() { MSG msg; ZeroMemory(&msg,sizeof(MSG)); while(msg.message!=WM_QUIT) { if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } else { // , ProcessGame(); engine->Render(); } } return (INT)msg.wParam; }
elseãããã¯å ã«ãããã®ã ãã泚ç®ã«å€ããŸã-ããã¯ããããIdleFunctionã§ãããã¡ãã»ãŒãžããªãå Žåã«å®è¡ãããŸãã
ãããŠããããç¶æ 管çæ©èœã§ãïŒ
TApplication :: ProcessGameïŒïŒ
void TApplication::ProcessGame() { if(moveStarted) { // if(!engine->IsMoving()) { // - moveStarted=FALSE; if(game->DetonateTest()) { // WORD *detonateList, count=game->GetDetonateList(&detonateList); detonateStarted=TRUE; engine->DetonateBalls(detonateList,count); engine->OnUpdateScore(game->GetScore()); } else { // if(game->CreateBalls(APPEAR_COUNT)) { TBallInfo *appearList; WORD count=game->GetNewBallList(&appearList); appearStarted=TRUE; engine->AppearBalls(appearList,count); } else { //game over! } } } } if(appearStarted) { // if(!engine->IsAppearing()) { appearStarted=FALSE; // - if(game->DetonateTest()) { // WORD *detonateList, count=game->GetDetonateList(&detonateList); detonateStarted=TRUE; engine->DetonateBalls(detonateList,count); engine->OnUpdateScore(game->GetScore()); } } } if(detonateStarted) { // if(!engine->IsDetonating()) { // detonateStarted=FALSE; } } }
ãŸããããããããã ãã§ãïŒ
ãããã«
ããã«æ¬ é¥ããªã¹ãããå ŽæããããŸãã ãã¡ãããã³ãŒãã«ã¯æé©åã®ããã®å ŽæããããããããŸãã ããã«ããããªã¢ãŒãèšå®ã®å€æŽïŒç»é¢è§£å床ããã«ããµã³ããªã³ã°ïŒããã³ããã€ã¹æ倱åŠçïŒLostDeviceïŒãªã©ã«ã€ããŠã¯èšåããŸããã§ããã åŸè ãç ç²ã«ããŠãgamedev.ruãŠã§ããµã€ãã§è©³çŽ°ãªè°è«ããããŸã ã
ç§ã®ç 究ã誰ãã®ããã«ãªãããšãé¡ã£ãŠããŸã ãšããã§ã githubã®ãœãŒã¹ ã
ãæž èŽããããšãããããŸããïŒ
çŽæã®æåŠ
1. Frank D. Luna DirectX 9.0ã«ãã3Dã²ãŒã ããã°ã©ãã³ã°å ¥é-åºæ¬ãç解ããããã
2. C ++ã§ã®Gornakov S. DirectX9ããã°ã©ãã³ã°ã¬ãã¹ã³ãåºæ¬ã§ãããDirectInputãDirectSoundãDirectMusicã«é¢ããç« ããããŸãã ãµã³ãã«ããã°ã©ã ã§ã¯ããšã©ãŒãçºçããå ŽåããããŸãã
3. Flenov M. YeãDirectXããã³C ++ããã°ã©ãã³ã°ã®èžè¡-楜ãããã¬ãŒã³ããŒã·ã§ã³ã¹ã¿ã€ã«ã åºæ¬çã«ãæ¬ã®ç®æšã¯ãã·ã§ãŒããŒãå«ããªã©ãèå³æ·±ãå¹æã䜿çšããŠã¢ãã¡ãŒã·ã§ã³ã¯ãªãããäœæããããšã§ãã ã»ã¯ã·ã§ã³åã§å€æããŠãã ããïŒå¿èçºäœããã¡ã€ã¢ãŒãã©ãŽã³ã
4. Barron Todd DirectX 9ã䜿çšããæŠç¥çã²ãŒã ã®ããã°ã©ãã³ã°-æŠç¥çã²ãŒã ã«é¢é£ãããããã¯ã«å®å šã«å°å¿µããŸãããããã¯ã°ã©ãã£ãã¯ãAIãããããšã©ã³ãã¹ã±ãŒãã®äœæãã¹ãã©ã€ããããŒãã£ã¯ã«ã·ã¹ãã ã®ç¹æ®å¹æãç»é¢ã€ã³ã¿ãŒãã§ã€ã¹ã®éçºãDirectSound /é³æ¥œã®æäœã
5. Bill Fleming 3D Creature WorkShop-ããã°ã©ãã³ã°ã§ã¯ãªããLightWaveã3D Studio MaxãAnimation Masterç°å¢ã§ã®3次å ãã£ã©ã¯ã¿ãŒã¢ãã«ã®éçºã«é¢ããæ¬ã
6. Thorn Alan DirectX 9ãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹ã®èšèšãšå®è£ -DirectXã䜿çšããã°ã©ãã£ã«ã«ã€ã³ã¿ãŒãã§ã€ã¹ã®éçºã«é¢ãã詳现ãªæ¬ã Delphiã§å®è£ ãããŠãããã®ãšåæ§ã®ç»é¢ãã©ãŒã ã®ã³ã³ããŒãã³ãã®éå±€ã¢ãã«ãèæ ®ãããŸãã
7. DirectXã䜿çšããAdams Jim Advanced Animation-ã¢ãã¡ãŒã·ã§ã³ã®çš®é¡ïŒéªšæ Œãã¢ãŒãã£ã³ã°ãçš®é¡ïŒãšãã®å®è£ ãæ€èšããXãã¡ã€ã«ããã®ãžãªã¡ããªãšã¢ãã¡ãŒã·ã§ã³ãæäœããŸãã
8. Windowsçšã®Lamot Andreããã°ã©ãã³ã°ã²ãŒã ã å°é家ã®ã¢ããã€ã¹-ãã®æ¬ã¯ããæ·±å»ã§ããæé©åã®åé¡ãããŸããŸãªã¿ã¹ã¯ã®ããŒã¿æ§é ã®éžæããã«ãã¹ã¬ãããç©çã¢ããªã³ã°ãAIãèæ ®ãããŸãã æåŸã®ç« ã§ã¯ãå®å®è¹ãšãšã€ãªã¢ã³ã«é¢ããã²ãŒã ã®äœæã«ã€ããŠèª¬æããŸãã
9. David H. Eberly 3Dã²ãŒã ãšã³ãžã³ã®èšèšã¯ãã²ãŒã æ§ç¯ã®çè«å šäœãç解ããã®ã«é©ããæ¬ã§ããæåã«ãã°ã©ãã£ãã¯APIïŒå€æãã©ã¹ã¿ãŒåãã·ã§ãŒãã£ã³ã°ããã¬ã³ãããã«ããã¯ã¹ãã£ãªã³ã°ããã©ã°ãªã©ïŒã®æè¡ã«ã€ããŠèª¬æãã次ã«ã·ãŒã³ã°ã©ããªã©ã®ãããã¯ã«ã€ããŠèª¬æããŸãããªããžã§ã¯ãã®éžæãè¡çªã®å®çŸ©ããã£ã©ã¯ã¿ãŒã¢ãã¡ãŒã·ã§ã³ã詳现ã¬ãã«ã颚æ¯ã
10.ã²ãŒã ããã°ã©ãã³ã°ã«ãããDanielSánchez-CrespoDalmauã³ã¢ãã¯ããã¯ãšã¢ã«ãŽãªãºã -AIãã¹ã¯ãªããäœæãé空éãšãªãŒãã³ã¹ããŒã¹ã§ã®ã¬ã³ããªã³ã°ãã¯ãªããã³ã°ã¢ã«ãŽãªãºã ãæé ãã¯ããã¯ãã·ã£ããŠã®å®è£ æ¹æ³ãªã©ãã²ãŒã ãšã³ãžãã¢ãªã³ã°ã¿ã¹ã¯ã§äœ¿çšãããã¢ã«ãŽãªãºã ãšããŒã¿æ§é ã®è©³çŽ°ãã«ã¡ã©ã®å®è£ ãªã©ã
11. Lamot Andreããã°ã©ãã³ã°directX 9ã䜿çšããããŒã«ãã¬ã€ã³ã°ã²ãŒã -æ°åããŒãžã«ããã詳现ãªRPGéçºã¬ã€ãã Direct3DãDirectInputãDirectSoundãDirectPlayã䜿çšããããã°ã©ãã³ã°ã«é¢ããçè«çãªç« ãšãã²ãŒã ãšã³ãžã³ã«çŽæ¥é¢é£ããå¿çšç« ã®äž¡æ¹ãå«ãŸããŠããŸãã