📄 bar.cpp
字号:
// Bar.cpp: implementation of the CBar class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "DBallGame.h"
#include "Bar.h"
#include "MyDef.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CBar::CBar()
{
}
CBar::~CBar()
{
}
void CBar::InitBar(CDC *dc, CRect *rect ,int y_pos)
{
pDC = dc;
m_rect = rect;
m_PrePos = m_Pos;
DrawBar(0);
m_Pos = m_PrePos = m_rect->right /2;
DrawBar(1);
if(y_pos == BAR_BELOW)
y_Pos = m_rect->bottom *10/11;//上方的板砖
else if(y_pos == BAR_ABOVE)
y_Pos = m_rect->bottom /11;//下方的板砖
else
TRACE("y_pos illegal");
}
void CBar::DrawBar(bool style)
{
if(style==1)//画
{
pDC->SelectStockObject (BLACK_PEN);
pDC->SelectStockObject (BLACK_BRUSH);
pDC->Rectangle (m_Pos-20,y_Pos-2,m_Pos+20,y_Pos+2);
}
else//擦
{
pDC->SelectStockObject (WHITE_PEN);
pDC->SelectStockObject (WHITE_BRUSH);
pDC->Rectangle (m_PrePos-20,y_Pos-2,m_PrePos+20,y_Pos+2);
}
}
void CBar::GoLeft()
{
m_PrePos = m_Pos;
if(m_Pos >= 20)
m_Pos -= 7 ;
DrawBar(0);
DrawBar(1);
}
void CBar::GoRight()
{
m_PrePos = m_Pos;
if(m_Pos <= m_rect->right -20)
m_Pos += 7;
DrawBar(0);
DrawBar(1);
}
int CBar::GetPos()
{
return m_Pos;
}
void CBar::SetPos(int pos)
{
m_PrePos = m_Pos ;
DrawBar(0);
m_Pos = pos;
DrawBar(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -