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

📄 square.cpp

📁 贪吃蛇源代码(小游戏)
💻 CPP
字号:
// Square.cpp: implementation of the Square class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Snake.h"
#include "Square.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

Square::Square()
{
	bUp=FALSE;
	bDown=FALSE;
	bRight=TRUE;
	bLeft=FALSE;
	data=new int[3];
	for(int i=0;i<3;i++)
		data[i]=1;
}

Square::~Square()
{

}
void Square::DrawBakGnd(CDC* pDC,int x,int y,int width ,int height,COLORREF color,BOOL grid)
{
    pDC->FillSolidRect(x,y,width,height,color);
	////////////////////////////////////////
	//以下内容为画出客户区的栅格;
	//
	//
	/////////////////////////////////////////
	if(grid)
	{
		CPen pen,*pOldPen;	
		pen.CreatePen(PS_SOLID,1,RGB(0,255,50));
		pOldPen=pDC->SelectObject(&pen);
		for(int i=0;i<16;i++)
		{
		pDC->MoveTo(x+i*20,y);
		pDC->LineTo(x+i*20,y+height);
		pDC->MoveTo(x,y+i*20);
			pDC->LineTo(width,y+i*20);
		}
		pDC->SelectObject(pOldPen);
	}
}
void Square::DrawCell(CDC* pDC,int row,int col,COLORREF color)
{
    	
   //pDC->FillSolidRect(2+col*20,7+row*20,18,18,RGB(255,255,255));
   pDC->FillSolidRect(3+col*20,1+row*20,16,18,color);

}
BOOL Square::CanUp()
{
    if(bUp||bDown)
	return FALSE;
	  return TRUE;
}
BOOL Square::CanDown()
{
	if(bUp||bDown)
		return FALSE;
	return TRUE;
}
BOOL Square::CanLeft()
{
	if(bLeft||bRight)
	return FALSE;
	return TRUE;
}
BOOL Square::CanRight()
{
	if(bLeft||bRight)
	return FALSE;
	return TRUE;
}

⌨️ 快捷键说明

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