?? mqggameview.cpp
字號:
// mqgGAMEView.cpp : implementation of the CMqgGAMEView class
//
#include "stdafx.h"
#include "mqgGAME.h"
#include "mqgGAMEDoc.h"
#include "mqgGAMEView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMqgGAMEView
IMPLEMENT_DYNCREATE(CMqgGAMEView, CView)
BEGIN_MESSAGE_MAP(CMqgGAMEView, CView)
//{{AFX_MSG_MAP(CMqgGAMEView)
ON_WM_TIMER()
ON_COMMAND(ID_PLAY, OnPlay)
ON_COMMAND(ID_NOPLAY, OnNoplay)
ON_WM_MOUSEMOVE()
ON_WM_KEYDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMqgGAMEView construction/destruction
CMqgGAMEView::CMqgGAMEView()
{
// TODO: add construction code here
pGAME=new GAME;
pGAME->IniGame();
}
CMqgGAMEView::~CMqgGAMEView()
{
}
BOOL CMqgGAMEView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMqgGAMEView drawing
void CMqgGAMEView::OnDraw(CDC* pDC)
{
CMqgGAMEDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CClientDC ClientDC( this );
pGAME->Draw(pDC);
}
/////////////////////////////////////////////////////////////////////////////
// CMqgGAMEView diagnostics
#ifdef _DEBUG
void CMqgGAMEView::AssertValid() const
{
CView::AssertValid();
}
void CMqgGAMEView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CMqgGAMEDoc* CMqgGAMEView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMqgGAMEDoc)));
return (CMqgGAMEDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMqgGAMEView message handlers
void CMqgGAMEView::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
/* CBrush Brush( RGB( ( rand() & 0xff ),( rand() & 0xff ), ( rand() & 0xff ) ) );
CPen Pen( PS_SOLID, 1, RGB( ( rand() & 0xff ),( rand() & 0xff ), ( rand() & 0xff ) ) );
CClientDC ClientDC( this );
CBrush *pOldBrush =(CBrush *) ClientDC.SelectObject( &Brush );
CPen *pOldPen = (CPen *) ClientDC.SelectObject( &Pen );*/
if(pGAME->pBall->zt==1)
pGAME->Run();
else
this->OnNoplay();
this->Invalidate();
/* ClientDC.SelectObject( pOldPen );
ClientDC.SelectObject( pOldBrush );*/
CView::OnTimer(nIDEvent);
}
void CMqgGAMEView::OnPlay()
{
// TODO: Add your command handler code here
if(pGAME->BallNum>0)
{
pGAME->pBall->zt=1;
this->SetTimer(1,10,NULL);
}
}
void CMqgGAMEView::OnNoplay()
{
// TODO: Add your command handler code here
this->KillTimer(1);
}
void CMqgGAMEView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CView::OnMouseMove(nFlags, point);
}
void CMqgGAMEView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
if(nChar==VK_LEFT)
{
pGAME->pBan->Move(-1);
this->Invalidate();
}
if(nChar==VK_RIGHT)
{
pGAME->pBan->Move(1);
this->Invalidate();
}
if(nChar==VK_SPACE)
{
this->OnPlay();
}
CView::OnKeyDown(nChar, nRepCnt, nFlags);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -