📄 blockgame.h
字号:
/*-----------------------------------------------------------------俄罗斯方块游戏-*/
/*----------------------------------------------write by codekey, codekey@126.com-*/
/*-------------------------------------------------------------------------2008-3-*/
/*---------------------------------------------欢迎使用和修改,但需保留原作者信息-*/
/*--------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------*/
#ifndef _BLOCK_GAME_H
#define _BLOCK_GAME_H
/*--------------------------------------------------------------------------------*/
#include "config.h"
/*--------------------------------------------------------------------------------*/
#define GAME_GRID_ROW 22 //17+6
#define GAME_GRID_COL 16 //10+6
#define GAME_FIRST_ROW 3 //
#define GAME_FIRST_COL 3 //
#define GAME_LAST_ROW (GAME_GRID_ROW-4) //
#define GAME_LAST_COL (GAME_GRID_COL-4) //
/*--------------------------------------------------------------------------------*/
typedef struct{
UINT8 nCurBlockType:4; /*方块的类型(7种)*/
UINT8 nCurBlockStatus:4; /*方块的状态(4种)*/
UINT8 nNextBlockType:4; /*下一方块的类型 */
UINT8 nFirstBlockCol:4;
UINT8 nFirstBlockRow;
UINT16 BlocksInfo;
}BLOCK_ATTR; //5B
typedef struct{
UINT16 Grid[GAME_GRID_ROW];
}GAME_GRID; //46B
typedef struct
{
UINT8 nLastBlockFirstRow; /* 上一方块的起始行 */
SINT8 nFullRowCount; /* 满行数 */
UINT8 nIdleBankCount; /* 无用的空格数 */
UINT8 nGrideHeight; /* 填充格最高高度 */
UINT8 nHighEdgeCount; /* 高边缘数 */
UINT8 nMostHighEdgeHeight; /* 最高边缘的高度 */
}GRID_ATTR;
typedef struct
{
GAME_GRID GameGrid;
BLOCK_ATTR GameBlock;
}BLOCK_GAME;
/*--------------------------------------------------------------------------------*/
/* 基本函数 */
void InitGame( BLOCK_GAME* pGame );
BOOL NewGame( BLOCK_GAME* pGame );
BOOL NewBlock( BLOCK_GAME* pGame );
void BuildBlocks( BLOCK_GAME* pGame );
enum eMoveMode{eMoveLeft=1, eMoveTurn=2, eMoveRight=3, eMoveUp=4, eMoveDown=5};
BOOL MoveBlock( BLOCK_GAME* pGame, UINT8 type);
BOOL TurnBlock( BLOCK_GAME* pGame );
BOOL BlockGridConsistent( BLOCK_GAME* pGame );
void FixCurBlock( BLOCK_GAME* pGame );
BOOL AdjustGrid( BLOCK_GAME* pGame );
void GameOver( BLOCK_GAME* pGame );
/*--------------------------------------------------------------------------------*/
/* 辅助函数 */
void CopyGame( BLOCK_GAME* pDestGame, BLOCK_GAME* pSourGame );
void CopyGameGrid( GAME_GRID* pDestGrid, GAME_GRID* pSourGrid );
void CopyGameBlock( BLOCK_ATTR* pDestBlock, BLOCK_ATTR* pSourBlock );
void CopyGridAttr(GRID_ATTR* pDestAttr, GRID_ATTR* pSourAttr );
/*--------------------------------------------------------------------------------*/
/* 获取属性 */
void GetGridAttr( BLOCK_GAME* pGame , GRID_ATTR* pGridAttr );
void GetFullRow( BLOCK_GAME* pGame , GRID_ATTR* pGridAttr );
void GetIdleBank( BLOCK_GAME* pGame , GRID_ATTR* pGridAttr );
void GetGridHigh( BLOCK_GAME* pGame, GRID_ATTR* pGridAttr );
void GetHighEdge(BLOCK_GAME* pGame, GRID_ATTR* pGridAttr ) ;
/*--------------------------------------------------------------------------------*/
#endif
/*--------------------------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -