stone.cpp

来自「VC面向对象的学习教程」· C++ 代码 · 共 53 行

CPP
53
字号
// Stone.cpp: implementation of the CStone class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "My.h"
#include "Stone.h"

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

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

// 炮弹类成员函数
// 炮弹类构造函数
CStone::CStone()
{
	m_bShot = FALSE;
	m_bmpStone.LoadBitmap(IDB_STONE);
	BITMAP BM;
	m_bmpStone.GetBitmap(&BM);
	m_nWidth	= BM.bmWidth;
	m_nHeight	= BM.bmHeight;
}
// 发射
void CStone::Shot(int x)
{
	m_bShot = TRUE;
	m_pointStone.x = x+48;
	m_pointStone.y = 440;
}
// 显示炮弹
void CStone::ShowStone(CDC *pDC, CDC *pMemDC, CRect Client)
{
	if(m_bShot)
	{
		pMemDC->SelectObject(&m_bmpStone);
		pDC->BitBlt(m_pointStone.x, m_pointStone.y,
					m_nWidth, m_nHeight, pMemDC,0,0,SRCAND);
	}
}
// 改变位置
void CStone::ChangePos()
{
	if(m_bShot)
		m_pointStone.y    -= 20;
}

⌨️ 快捷键说明

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