📄 car.cpp
字号:
// Car.cpp: implementation of the CCar class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "MyThread.h"
#include "Car.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
extern CCriticalSection cs;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CCar::CCar()
{
}
CCar::CCar(CPoint position,CPoint direction/* =CPoint(10 ,0)*/)
{
m_CarPosition=position;
m_CarOld=position;
m_direction=direction;
pDC=AfxGetApp()->GetMainWnd()->GetDC();
pDC->TextOut(100,100,"fhdsajklfjks");
m_pCarThread=AfxBeginThread(_CarMove,this,THREAD_PRIORITY_NORMAL);
}
CCar::~CCar()
{
}
UINT CCar::_CarMove(LPVOID lpparam)
{
CCar* This=(CCar*)(lpparam); //lpparam为构造器中传过来的"this"指针
This->CarMove();
return 0;
}
void CCar::CarMove()
{
while(true)
{
cs.Lock();
m_CarOld=m_CarPosition;
m_CarPosition=m_CarPosition+m_direction;
cs.Unlock();
Sleep(500);
}
}
void CCar::Start(CPoint position,CPoint direction/* =CPoint(10 ,0)*/)
{
m_CarPosition=position;
m_CarOld=position;
m_direction=direction;
pDC=AfxGetApp()->GetMainWnd()->GetDC();
pDC->TextOut(m_CarPosition.x,m_CarPosition.y,"fhdsajklfjks");
m_pCarThread=AfxBeginThread(_CarMove,this,THREAD_PRIORITY_NORMAL);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -