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

📄 cblock.cpp

📁 俄罗斯方块3D 程序+源码俄罗斯方块3D(程序+源码
💻 CPP
字号:
#include "CBlock.h"

////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////
CBlock::CBlock()
{
	m_Position.row = 0;
	m_Position.col = 0;
	m_iMaterialIndex = -1;
}

////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////
CBlock::~CBlock()
{
	
}

////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////
CBlock::CBlock( const CBlock &block )
{
	m_Position.row = block.m_Position.row;
	m_Position.col = block.m_Position.col;
	m_iMaterialIndex = block.m_iMaterialIndex;
}

////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////
CBlock::CBlock( int row, int col, int iMat )
{
	m_Position.row = row;
	m_Position.col = col;
	m_iMaterialIndex = iMat;
}

////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////
CBlock &CBlock::operator = ( const CBlock &block )
{
	m_Position.row = block.m_Position.row;
	m_Position.col = block.m_Position.col;
	m_iMaterialIndex = block.m_iMaterialIndex;
	return *this;
}

////////////////////////////////////////////////////////////////
//旋转一个方块,注意这里的行,和列分别代表y和x!
//Out_x = -In_y + Pos_y + Pos_x;
//Out_y = In_x - Pos_x + Pos_y;

/*旋转矩阵:
|	0		1		0	|
|   -1		0		0	|
|  px+py  -px+py	1	|
*/
////////////////////////////////////////////////////////////////
void BlockRotation( CBlock &newBlock, const POSITION &pos, const CBlock &oldBlock )
{
	newBlock.m_Position.col = pos.row + pos.col - oldBlock.m_Position.row;
	newBlock.m_Position.row = oldBlock.m_Position.col - pos.col + pos.row;
}

////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////
void BlockDrop( CBlock &newBlock, const CBlock &oldBlock )
{
	newBlock.m_Position.row = oldBlock.m_Position.row - 1;
	newBlock.m_Position.col = oldBlock.m_Position.col;
}

////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////
void BlockMovement( CBlock &newBlock, const CBlock &oldBlock, int iStep )
{
	newBlock.m_Position.row = oldBlock.m_Position.row;
	newBlock.m_Position.col = oldBlock.m_Position.col + iStep;
}

⌨️ 快捷键说明

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