me.cpp

来自「关于 dirve car 的VC 部分源码」· C++ 代码 · 共 70 行

CPP
70
字号
// Me.cpp: implementation of the CME class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "drivecar.h"
#include "Me.h"

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

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

CMe::CMe()
{
	BITMAP BM;
	m_bmpMeH.LoadBitmap(IDB_MEH);
	m_bmpMeH.GetBitmap(&BM);
	m_bmpMeL.LoadBitmap(IDB_MEL);
	m_bmpMeL.GetBitmap(&BM);
	m_nWidth=BM.bmWidth;
	m_nHeight=BM.bmHeight;
	m_pointMe=CPoint(100,360);
	m_MLoop=-1;
}

CMe::~CMe()
{

}

void CMe::ShowMe(CDC *pDC, CDC *pMemDC, CRect Client)
{
	if(m_bWhich)
		pMemDC->SelectObject(&m_bmpMeL);
	else 
		pMemDC->SelectObject(&m_bmpMeH);
	pDC->BitBlt(m_pointMe.x,m_pointMe.y,m_nWidth,m_nHeight,pMemDC,0,0,SRCAND);

}

void CMe::ChangePos(int x)
{
	if(x==0&&m_pointMe.x>110&&m_pointMe.y>90&&m_pointMe.y<140)
	{m_bWhich=true;m_pointMe.x-=20;}
	else if(x==1&&m_pointMe.x<550&&m_pointMe.y>350&&m_pointMe.y<400)
	{m_bWhich=true;m_pointMe.x+=20;}
	else if(x==2&&m_pointMe.y>110&&m_pointMe.x>550&&m_pointMe.x<600)
	{m_bWhich=false;m_pointMe.y-=20;}
	else if(x==3&&m_pointMe.y<360&&m_pointMe.x>90&&m_pointMe.x<140)
	{m_bWhich=false;m_pointMe.y+=20;}
}

CRect CMe::GetMe()
{
	return CRect(m_pointMe.x,m_pointMe.y,m_pointMe.x+m_nWidth,m_pointMe.y+m_nHeight);
}

void CMe::Reset()
{
	m_pointMe=CPoint(100,360);
	m_bWhich=true;
	m_MLoop=-1;
}

⌨️ 快捷键说明

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