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

📄 game.cpp

📁 小球打砖块
💻 CPP
字号:
// GAME.cpp: implementation of the GAME class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "mqgGAME.h"
#include "GAME.h"

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

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

GAME::GAME()
{
	BallNum=3;
	pBall=new Ball;
	pBan=new Ban;
	pBian=new Bian;
	pJFB=new JFB;
	pQiang=new Qiang;
	pDingBian=new DingBian;
	pZuoBian=new ZuoBian;
	pYouBian=new YouBian;
	pDiBian=new DiBian;

}

GAME::~GAME()
{

}

void GAME::IniGame()
{
	cr.left=600;
	cr.top=180;
	cr.right=650;
	cr.bottom=210;

	pBan->IniBan();
	pBall->IniBall();	
	pBan->pBall=pBall;
	pDingBian->pBall=pBall;
	pZuoBian->pBall=pBall;
	pYouBian->pBall=pBall;
	pDiBian->pGAME=this;
	pQiang->pGAME=this;
	pQiang->IniQiang();
}

void GAME::Draw(CDC *pDC)
{
	pBian->Draw(pDC);
	pJFB->Draw(pDC);
	pQiang->Draw(pDC);
	pBan->Draw(pDC);
	this->DrawBallNum(pDC);

	if(pBall->zt>=0 && BallNum>0)
		pBall->Draw(pDC);
}

void GAME::Run()
{
	if(pBall->zt==1)
		pBall->Fei();
	pDingBian->IsZhuang();
	pZuoBian->IsZhuang();
	pYouBian->IsZhuang();
	pDiBian->IsZhuang();
	pBan->IsZhuang();
	pQiang->IsZhuang();
	
}

void GAME::BallDeath()
{
	BallNum--;
	pBall->zt=-1;
	pBan->IniBan();
	pBall->IniBall();

	if(BallNum>0)
		pBall->zt=0;
}

void GAME::DrawBallNum(CDC *pDC)
{
	POINT p;
	p.x=p.y=10;
	pDC->RoundRect(&cr,p);
	cr.top=cr.top+5;
	pDC->SetBkColor(RGB(0,255,255));
	pDC->SetTextColor(RGB(255,0,255));
	pDC->DrawText("球数=",&cr,DT_CENTER);
	cr.top=cr.top-5;

	RECT r;
	SetRect(&r,cr.right+2,cr.top,cr.right+52,cr.bottom);
	pDC->Rectangle(&r);
	r.top=r.top+5;
	CString s;
	if(BallNum>0)
		s.Format("%d",BallNum);
	else
		s="NULL";
	pDC->DrawText(s,&r,DT_CENTER);
	pDC->SetBkColor(RGB(255,255,255));
	pDC->SetTextColor(RGB(0,0,0));
}

⌨️ 快捷键说明

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