⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tetrislogic.h

📁 一个利用hge游戏引擎
💻 H
字号:
////  http://dotlive.cnblogs.com/ 
// TetrisLogic.h: interface for the TetrisLogic class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_TETRISLOGIC_H__71D2CBE5_C7D5_4DEA_987D_6C23218131E1__INCLUDED_)
#define AFX_TETRISLOGIC_H__71D2CBE5_C7D5_4DEA_987D_6C23218131E1__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "windows.h"
#include "GameLogic.h"

enum TerisBoxType{
	TerisBoxType1,
	TerisBoxType2,
	TerisBoxType3,
	TerisBoxType4,
	TerisBoxType5,
	TerisBoxType6,
	TerisBoxType7,
	TerisBoxType8,
};

struct TetrisBox 
{
	POINT m_ptPosition;
	INT m_nState;
	INT m_nBoxID;
	TetrisBox(){
		memset(this,0,sizeof(TetrisBox));
// 		m_nBoxID = 0;
// 		m_nState = 0;
// 		m_ptPosition.x = 0;
// 		m_ptPosition.y = 0;
	}
} ;

class TetrisLogic : public GameLogic  
{
public:
	enum TLKEYCODE
	{
		KeyNothing,
		KeyRight,
		KeyLeft,
		KeyDown,
		KeyTurn,
		KeyPause,
		KeyEsc,
		KeyOption,
	};
	TetrisLogic(IGameEngine* m_pGE);
	virtual ~TetrisLogic();

	void Init();

	INT GameStep(float fTimeEscape);
	INT GameInput(INT nKeyCode, int nStep = 1);
	TetrisBox GetFallingBox() const { return m_stFallingBox; }
 	byte GameStage(int x,int y) const;
 	int GetBoxCell(int nBoxid,int nState,int x,int y);
	void Render();

private:

	int GetRadomType();
	void BoxDone();
	void CheckScore();
	BOOL TestHit(TetrisBox stTmpBox);
	
	void PrintScore();
	void DrawLandEdge();
	void DrawLand();
	void DrawBox ();
	void DrawNextBox ();

	double m_nLogicTimer;

	TetrisBox m_stFallingBox;
	TetrisBox m_stNextBox;
	byte m_nGameStage[10][30];
	double m_fFallingSpeed;

	LONG m_nScore;
	byte m_nGameBoxCell[10][4][5][5];
	//  [BoxId][State][x][y]

};

#endif // !defined(AFX_TETRISLOGIC_H__71D2CBE5_C7D5_4DEA_987D_6C23218131E1__INCLUDED_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -