tank.cpp

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

CPP
47
字号
// Tank.cpp: implementation of the CTank class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "My.h"
#include "Tank.h"

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

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

// 高炮类成员函数
// 高炮类构造函数
CTank::CTank()
{
	m_pointTank.x = 350;
	m_pointTank.y = 450;
	m_bmpTank.LoadBitmap(IDB_TANK);
	BITMAP BM;
	m_bmpTank.GetBitmap(&BM);
	m_nWidth	= BM.bmWidth;
	m_nHeight	= BM.bmHeight;
}
// 显示高炮
void CTank::ShowTank(CDC *pDC, CDC *pMemDC, CRect Client)
{
	pMemDC->SelectObject(&m_bmpTank);
	pDC->BitBlt(m_pointTank.x, m_pointTank.y,
				m_nWidth, m_nHeight, pMemDC,0,0,SRCAND);
}
// 改变位置
void CTank::ChangePos(int tag)
{
	if(tag == 0 && m_pointTank.x > 0)
		m_pointTank.x	-= 20;
	else if(tag == 1 && m_pointTank.x+m_nWidth < 798)
		m_pointTank.x	+= 20;
}

⌨️ 快捷键说明

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