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

📄 russian2.cpp

📁 一个可以在嵌入式平台上面开发的俄罗斯方块程序
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		break;
	}
	PaintDesign(pDC);
}
/////////////////////////////////////////////////////////////////////
//CSquare4:
CSquare4::CSquare4()
{
	//1	 2  3
	//	    4
	status=1;
	cx1=ulPosx+frmwidth+(xGrid/2)*mWidth;  
	cy1=ulPosy+frmwidth;
	cx2=cx1+mWidth;
	cy2=cy1;
	cx3=cx1+mWidth*2;
	cy3=cy1;
	cx4=cx3;
	cy4=cy1+mHeight;
		
}
		
CSquare4::~CSquare4()
{
	;
}

void CSquare4::Init()
{
	status=1;
		cx1=ulPosx+frmwidth+(xGrid/2)*mWidth;  
		cy1=ulPosy+frmwidth;
		cx2=cx1+mWidth;
		cy2=cy1;
		cx3=cx1+mWidth*2;
		cy3=cy1;
		cx4=cx3;
		cy4=cy1+mHeight;

	
}

BOOL CSquare4::CanRotate()
{
	CalcStatus();
	BOOL bRtn=1;
	int x1=cx1;
	int x2=cx2;
	int x3=cx3;
	int x4=cx4;
	int y1=cy1;
	int y2=cy2;
	int y3=cy3;
	int y4=cy4;
	switch(status)
	{
	case 1:
		cx1=cx1+mWidth*2;
		cy1=cy1-mHeight*2;
		cx2=cx2+mWidth;
		cy2=cy2-mHeight;
		cx3=cx3;
		cy3=cy3;
		cx4=cx4-mWidth;
		cy4=cy4-mHeight;
		break;
	case 2:
		cx1=cx1+mWidth*2;
		cy1=cy1+mHeight*2;
		cx2=cx2+mWidth;
		cy2=cy2+mHeight;
		cx3=cx3;
		cy3=cy3;
		cx4=cx4+mWidth;
		cy4=cy4-mHeight;
		break;
	case 3:
		cx1=cx1-mWidth*2;
		cy1=cy1+mHeight*2;
		cx2=cx2-mWidth;
		cy2=cy2+mHeight;
		cx3=cx3;
		cy3=cy3;
		cx4=cx4+mWidth;
		cy4=cy4+mHeight;
		break;
	case 4:
		cx1=cx1-mWidth*2;
		cy1=cy1-mHeight*2;
		cx2=cx2-mWidth;
		cy2=cy2-mHeight;
		cx3=cx3;
		cy3=cy3;
		cx4=cx4-mWidth;
		cy4=cy4+mHeight;
		break;
	}
	
	CalcStatus();

	if (
		(array[i1][j1]==1)||
		(array[i2][j2]==1)||
		(array[i3][j3]==1)||
		(array[i4][j4]==1)||
		
		cy1>(ulPosy+frmwidth+(yGrid-1)*mHeight)||
		cy2>(ulPosy+frmwidth+(yGrid-1)*mHeight)||
		cy3>(ulPosy+frmwidth+(yGrid-1)*mHeight)||
		cy4>(ulPosy+frmwidth+(yGrid-1)*mHeight)||
		
		cy1<(ulPosy+frmwidth)||
		cy2<(ulPosy+frmwidth)||
		cy3<(ulPosy+frmwidth)||
		cy4<(ulPosy+frmwidth)||
		
		cx1>(ulPosx+frmwidth+(xGrid-1)*mWidth)||
		cx2>(ulPosx+frmwidth+(xGrid-1)*mWidth)||
		cx3>(ulPosx+frmwidth+(xGrid-1)*mWidth)||
		cx4>(ulPosx+frmwidth+(xGrid-1)*mWidth)||
		
		cx1<(ulPosx+frmwidth)||
		cx2<(ulPosx+frmwidth)||
		cx3<(ulPosx+frmwidth)||
		cx4<(ulPosx+frmwidth)
		)
		{
		bRtn=0;
		}
	cx1=x1;
	cx2=x2;
	cx3=x3;
	cx4=x4;
	cy1=y1;
	cy2=y2;
	cy3=y3;
	cy4=y4;

	CalcStatus();

	return bRtn;
}

void CSquare4::Rotate(CDC *pDC)
{
	if(!CanRotate())return;

    CSquareBase::Rotate(pDC);
	switch(status)
	{
	case 1:
		status=2;
		cx1=cx1+mWidth*2;
		cy1=cy1-mHeight*2;
		cx2=cx2+mWidth;
		cy2=cy2-mHeight;
		cx3=cx3;
		cy3=cy3;
		cx4=cx4-mWidth;
		cy4=cy4-mHeight;
		break;
	case 2:
		status=3;
		cx1=cx1+mWidth*2;
		cy1=cy1+mHeight*2;
		cx2=cx2+mWidth;
		cy2=cy2+mHeight;
		cx3=cx3;
		cy3=cy3;
		cx4=cx4+mWidth;
		cy4=cy4-mHeight;
		break;
	case 3:
		status=4;
		cx1=cx1-mWidth*2;
		cy1=cy1+mHeight*2;
		cx2=cx2-mWidth;
		cy2=cy2+mHeight;
		cx3=cx3;
		cy3=cy3;
		cx4=cx4+mWidth;
		cy4=cy4+mHeight;
		break;
	case 4:
		status=1;
		cx1=cx1-mWidth*2;
		cy1=cy1-mHeight*2;
		cx2=cx2-mWidth;
		cy2=cy2-mHeight;
		cx3=cx3;
		cy3=cy3;
		cx4=cx4-mWidth;
		cy4=cy4+mHeight;
		break;
	}
	PaintDesign(pDC);
}
/////////////////////////////////////////////////////////////////////
//CSquare5:
CSquare5::CSquare5()
{
	//1	 2	3
	//4
	status=1;
	cx1=ulPosx+frmwidth+(xGrid/2)*mWidth; 
	cy1=ulPosy+frmwidth;
	cx2=cx1+mWidth;
	cy2=cy1;
	cx3=cx1+mWidth*2;
	cy3=cy1;
	cx4=cx1;
	cy4=cy1+mHeight;
		
}
		
CSquare5::~CSquare5()
{
	;
}
void CSquare5::Init()
{
			status=1;
				cx1=ulPosx+frmwidth+(xGrid/2)*mWidth; 
				cy1=ulPosy+frmwidth;
				cx2=cx1+mWidth;
				cy2=cy1;
				cx3=cx1+mWidth*2;
				cy3=cy1;
				cx4=cx1;
				cy4=cy1+mHeight;

	
}

BOOL CSquare5::CanRotate()
{
		CalcStatus();
	BOOL bRtn=1;
	int x1=cx1;
	int x2=cx2;
	int x3=cx3;
	int x4=cx4;
	int y1=cy1;
	int y2=cy2;
	int y3=cy3;
	int y4=cy4;
	switch(status)
	{
	case 1:
		cx1=cx1;
		cy1=cy1;
		cx2=cx2-mWidth;
		cy2=cy2+mHeight;
		cx3=cx3-mWidth*2;
		cy3=cy3+mHeight*2;
		cx4=cx4-mWidth;
		cy4=cy4-mHeight;
		break;
	case 2:
		cx1=cx1;
		cy1=cy1;
		cx2=cx2-mWidth;
		cy2=cy2-mHeight;
		cx3=cx3-mWidth*2;
		cy3=cy3-mHeight*2;
		cx4=cx4+mWidth;
		cy4=cy4-mHeight;
		break;
	case 3:
		cx1=cx1;
		cy1=cy1;
		cx2=cx2+mWidth;
		cy2=cy2-mHeight;
		cx3=cx3+mWidth*2;
		cy3=cy3-mHeight*2;
		cx4=cx4+mWidth;
		cy4=cy4+mHeight;
		break;
	case 4:
		cx1=cx1;
		cy1=cy1;
		cx2=cx2+mWidth;
		cy2=cy2+mHeight;
		cx3=cx3+mWidth*2;
		cy3=cy3+mHeight*2;
		cx4=cx4-mWidth;
		cy4=cy4+mHeight;
		break;
	}
	CalcStatus();

	if (
		(array[i1][j1]==1)||
		(array[i2][j2]==1)||
		(array[i3][j3]==1)||
		(array[i4][j4]==1)||
		
		cy1>(ulPosy+frmwidth+(yGrid-1)*mHeight)||
		cy2>(ulPosy+frmwidth+(yGrid-1)*mHeight)||
		cy3>(ulPosy+frmwidth+(yGrid-1)*mHeight)||
		cy4>(ulPosy+frmwidth+(yGrid-1)*mHeight)||
		
		cy1<(ulPosy+frmwidth)||
		cy2<(ulPosy+frmwidth)||
		cy3<(ulPosy+frmwidth)||
		cy4<(ulPosy+frmwidth)||
		
		cx1>(ulPosx+frmwidth+(xGrid-1)*mWidth)||
		cx2>(ulPosx+frmwidth+(xGrid-1)*mWidth)||
		cx3>(ulPosx+frmwidth+(xGrid-1)*mWidth)||
		cx4>(ulPosx+frmwidth+(xGrid-1)*mWidth)||
		
		cx1<(ulPosx+frmwidth)||
		cx2<(ulPosx+frmwidth)||
		cx3<(ulPosx+frmwidth)||
		cx4<(ulPosx+frmwidth)
		)
		{
		bRtn=0;
		}
	cx1=x1;
	cx2=x2;
	cx3=x3;
	cx4=x4;
	cy1=y1;
	cy2=y2;
	cy3=y3;
	cy4=y4;

	CalcStatus();

	return bRtn;
}

void CSquare5::Rotate(CDC *pDC)
{
	if(!CanRotate())return;
	CSquareBase::Rotate(pDC);
	switch(status)
	{
	case 1:
		status=2;
		cx1=cx1;
		cy1=cy1;
		cx2=cx2-mWidth;
		cy2=cy2+mHeight;
		cx3=cx3-mWidth*2;
		cy3=cy3+mHeight*2;
		cx4=cx4-mWidth;
		cy4=cy4-mHeight;
		break;
	case 2:
		status=3;
		cx1=cx1;
		cy1=cy1;
		cx2=cx2-mWidth;
		cy2=cy2-mHeight;
		cx3=cx3-mWidth*2;
		cy3=cy3-mHeight*2;
		cx4=cx4+mWidth;
		cy4=cy4-mHeight;
		break;
	case 3:
		status=4;
		cx1=cx1;
		cy1=cy1;
		cx2=cx2+mWidth;
		cy2=cy2-mHeight;
		cx3=cx3+mWidth*2;
		cy3=cy3-mHeight*2;
		cx4=cx4+mWidth;
		cy4=cy4+mHeight;
		break;
	case 4:
		status=1;
		cx1=cx1;
		cy1=cy1;
		cx2=cx2+mWidth;
		cy2=cy2+mHeight;
		cx3=cx3+mWidth*2;
		cy3=cy3+mHeight*2;
		cx4=cx4-mWidth;
		cy4=cy4+mHeight;
		break;
	}
	PaintDesign(pDC);
}
/////////////////////////////////////////////////////////////////////
//CSquare6:
CSquare6::CSquare6()
{
	//		1	2
	//	3	4
	status=1;
	cx1=ulPosx+frmwidth+(xGrid/2)*mWidth; 
	cy1=ulPosy+frmwidth;
	cx2=cx1+mWidth;
	cy2=cy1;
	cx3=cx1-mWidth;
	cy3=cy1+mHeight;
	cx4=cx1;
	cy4=cy3;
		
}
		
CSquare6::~CSquare6()
{
	;
}

void CSquare6::Init()
{
		status=1;
					cx1=ulPosx+frmwidth+(xGrid/2)*mWidth; 
					cy1=ulPosy+frmwidth;
					cx2=cx1+mWidth;
					cy2=cy1;
					cx3=cx1-mWidth;
					cy3=cy1+mHeight;
					cx4=cx1;
					cy4=cy3;

			
}

BOOL CSquare6::CanRotate()
{
		CalcStatus();
	BOOL bRtn=1;
	int x1=cx1;
	int x2=cx2;
	int x3=cx3;
	int x4=cx4;
	int y1=cy1;
	int y2=cy2;
	int y3=cy3;
	int y4=cy4;
	switch(status)
	{
	case 1:
		cx1=cx1;
		cy1=cy1;
		cx2=cx2-mWidth;
		cy2=cy2-mHeight;
		cx3=cx3+mWidth*2;
		cy3=cy3;
		cx4=cx4+mWidth;
		cy4=cy4-mHeight;
		break;
	case 2:
		cx1=cx1;
		cy1=cy1;
		cx2=cx2+mWidth;
		cy2=cy2+mHeight;
		cx3=cx3-mWidth*2;
		cy3=cy3;
		cx4=cx4-mWidth;
		cy4=cy4+mHeight;
		break;
	}
	CalcStatus();

	if (
		(array[i1][j1]==1)||
		(array[i2][j2]==1)||
		(array[i3][j3]==1)||
		(array[i4][j4]==1)||
		
		cy1>(ulPosy+frmwidth+(yGrid-1)*mHeight)||
		cy2>(ulPosy+frmwidth+(yGrid-1)*mHeight)||
		cy3>(ulPosy+frmwidth+(yGrid-1)*mHeight)||
		cy4>(ulPosy+frmwidth+(yGrid-1)*mHeight)||
		
		cy1<(ulPosy+frmwidth)||
		cy2<(ulPosy+frmwidth)||
		cy3<(ulPosy+frmwidth)||
		cy4<(ulPosy+frmwidth)||
		
		cx1>(ulPosx+frmwidth+(xGrid-1)*mWidth)||
		cx2>(ulPosx+frmwidth+(xGrid-1)*mWidth)||
		cx3>(ulPosx+frmwidth+(xGrid-1)*mWidth)||
		cx4>(ulPosx+frmwidth+(xGrid-1)*mWidth)||
		
		cx1<(ulPosx+frmwidth)||
		cx2<(ulPosx+frmwidth)||
		cx3<(ulPosx+frmwidth)||
		cx4<(ulPosx+frmwidth)
		)
		{
		bRtn=0;
		}
	cx1=x1;
	cx2=x2;
	cx3=x3;
	cx4=x4;
	cy1=y1;
	cy2=y2;
	cy3=y3;
	cy4=y4;

	CalcStatus();

	return bRtn;
}

void CSquare6::Rotate(CDC *pDC)
{
	if(!CanRotate())return;
	CSquareBase::Rotate(pDC);
	switch(status)
	{
	case 1:
		status=2;
		cx1=cx1;
		cy1=cy1;
		cx2=cx2-mWidth;
		cy2=cy2-mHeight;
		cx3=cx3+mWidth*2;
		cy3=cy3;
		cx4=cx4+mWidth;
		cy4=cy4-mHeight;
		break;
	case 2:
		status=1;
		cx1=cx1;
		cy1=cy1;
		cx2=cx2+mWidth;
		cy2=cy2+mHeight;
		cx3=cx3-mWidth*2;
		cy3=cy3;
		cx4=cx4-mWidth;
		cy4=cy4+mHeight;
		break;
	}
	PaintDesign(pDC);
}
/////////////////////////////////////////////////////////////////////
//CSquare7:
CSquare7::CSquare7()
{
	
	//1	  2
	//	  3  4
	status=1;
	cx1=ulPosx+frmwidth+(xGrid/2)*mWidth; 
	cy1=ulPosy+frmwidth;
	cx2=cx1+mWidth;
	cy2=cy1;
	cx3=cx2;
	cy3=cy1+mHeight;
	cx4=cx3+mWidth;
	cy4=cy3;
		
}
		
CSquare7::~CSquare7()
{
	;
}

void CSquare7::Init()
{
	status=1;
			cx1=ulPosx+frmwidth+(xGrid/2)*mWidth; 
			cy1=ulPosy+frmwidth;
			cx2=cx1+mWidth;
			cy2=cy1;
			cx3=cx2;
			cy3=cy1+mHeight;
			cx4=cx3+mWidth;
			cy4=cy3;

}

BOOL CSquare7::CanRotate()
{
		CalcStatus();
	BOOL bRtn=1;
	int x1=cx1;
	int x2=cx2;
	int x3=cx3;
	int x4=cx4;
	int y1=cy1;
	int y2=cy2;
	int y3=cy3;
	int y4=cy4;
	switch(status)
	{
	case 1:
		cx1=cx1+mWidth;
		cy1=cy1-mHeight;
		cx2=cx2;
		cy2=cy2;
		cx3=cx3-mWidth;
		cy3=cy3-mHeight;
		cx4=cx4-mWidth*2;
		cy4=cy4;
		break;
	case 2:
		cx1=cx1-mWidth;
		cy1=cy1+mHeight;
		cx2=cx2;
		cy2=cy2;
		cx3=cx3+mWidth;
		cy3=cy3+mHeight;
		cx4=cx4+mWidth*2;
		cy4=cy4;
		break;
	}
	CalcStatus();

	if (
		(array[i1][j1]==1)||
		(array[i2][j2]==1)||
		(array[i3][j3]==1)||
		(array[i4][j4]==1)||
		
		cy1>(ulPosy+frmwidth+(yGrid-1)*mHeight)||
		cy2>(ulPosy+frmwidth+(yGrid-1)*mHeight)||
		cy3>(ulPosy+frmwidth+(yGrid-1)*mHeight)||
		cy4>(ulPosy+frmwidth+(yGrid-1)*mHeight)||
		
		cy1<(ulPosy+frmwidth)||
		cy2<(ulPosy+frmwidth)||
		cy3<(ulPosy+frmwidth)||
		cy4<(ulPosy+frmwidth)||
		
		cx1>(ulPosx+frmwidth+(xGrid-1)*mWidth)||
		cx2>(ulPosx+frmwidth+(xGrid-1)*mWidth)||
		cx3>(ulPosx+frmwidth+(xGrid-1)*mWidth)||
		cx4>(ulPosx+frmwidth+(xGrid-1)*mWidth)||
		
		cx1<(ulPosx+frmwidth)||
		cx2<(ulPosx+frmwidth)||
		cx3<(ulPosx+frmwidth)||
		cx4<(ulPosx+frmwidth)
		)
		{
		bRtn=0;
		}
	cx1=x1;
	cx2=x2;
	cx3=x3;
	cx4=x4;
	cy1=y1;
	cy2=y2;
	cy3=y3;
	cy4=y4;

	CalcStatus();

	return bRtn;
}

void CSquare7::Rotate(CDC *pDC)
{
	if(!CanRotate())return;
	CSquareBase::Rotate(pDC);
	switch(status)
	{
	case 1:
		status=2;
		cx1=cx1+mWidth;
		cy1=cy1-mHeight;
		cx2=cx2;
		cy2=cy2;
		cx3=cx3-mWidth;
		cy3=cy3-mHeight;
		cx4=cx4-mWidth*2;
		cy4=cy4;
		break;
	case 2:
		status=1;
		cx1=cx1-mWidth;
		cy1=cy1+mHeight;
		cx2=cx2;
		cy2=cy2;
		cx3=cx3+mWidth;
		cy3=cy3+mHeight;
		cx4=cx4+mWidth*2;
		cy4=cy4;
		break;
	}
	PaintDesign(pDC);
}

⌨️ 快捷键说明

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