plane.cpp

来自「由吕军等人著的《Visual C++ 与面向对象程序设计教程》课后习题的源代码」· C++ 代码 · 共 46 行

CPP
46
字号
// Plane.cpp: implementation of the CPlane class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "My.h"
#include "Plane.h"

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

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

// 飞机类的成员函数
// 构造函数
CPlane::CPlane()
{
	m_pointPlane	= CPoint(0, 50);
	m_bmpPlane.LoadBitmap(IDB_PLANE);
	BITMAP BM;
	m_bmpPlane.GetBitmap(&BM);
	m_nWidth	= BM.bmWidth;
	m_nHeight	= BM.bmHeight;
}
// 显示飞机
void CPlane::ShowPlane(CDC *pDC, CDC *pMemDC, CRect Client)
{
	pMemDC->SelectObject(&m_bmpPlane);
	pDC->BitBlt(m_pointPlane.x, m_pointPlane.y,
				m_nWidth, m_nHeight, pMemDC,0,0,SRCAND);
}
// 改变飞机位置
void CPlane::ChangePos()
{
	if(m_pointPlane.x>788)
		m_pointPlane.x  = 0;
	else
		m_pointPlane.x += 10;
}

⌨️ 快捷键说明

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