📄 testgameview.cpp
字号:
// TestGameView.cpp : implementation of the CTestGameView class
//
#include "stdafx.h"
#include "TestGame.h"
#include "MainFrm.h"
#include "TestGameDoc.h"
#include "TestGameView.h"
#include "Game.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTestGameView
IMPLEMENT_DYNCREATE(CTestGameView, CView)
BEGIN_MESSAGE_MAP(CTestGameView, CView)
//{{AFX_MSG_MAP(CTestGameView)
ON_COMMAND(IDR_START, OnStart)
ON_WM_TIMER()
ON_UPDATE_COMMAND_UI(IDR_START, OnUpdateStart)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CTestGameView construction/destruction
CTestGameView::CTestGameView()
{
// TODO: add construction code here
pGame = NULL;
}
CTestGameView::~CTestGameView()
{
}
BOOL CTestGameView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CTestGameView drawing
void CTestGameView::OnDraw(CDC* pDC)
{
CTestGameDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CTestGameView printing
BOOL CTestGameView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CTestGameView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CTestGameView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CTestGameView diagnostics
#ifdef _DEBUG
void CTestGameView::AssertValid() const
{
CView::AssertValid();
}
void CTestGameView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CTestGameDoc* CTestGameView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTestGameDoc)));
return (CTestGameDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CTestGameView message handlers
void CTestGameView::OnStart()
{
// TODO: Add your command handler code here
if ( pGame == NULL )
{
pGame = new CGame(this);
pGame->InitialGame();
SetTimer(100,3000,NULL);
}
else
{
pGame->RestAll();
}
bEnableStarMenu = FALSE;
}
void CTestGameView::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
if ( nIDEvent == 100 )
{
if ( pGame )
{
if ( pGame->m_bNewReset )
{
bEnableStarMenu = TRUE;
}
}
}
CView::OnTimer(nIDEvent);
}
BOOL CTestGameView::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
switch( pMsg->message )
{
case WM_KEYDOWN://击键消息
/* switch(LOWORD(pMsg->wParam))
{
case VK_ESCAPE://退出
break;
case VK_UP:
pGame->ControlPlanePos(pMsg->wParam);
break;
case VK_DOWN:
pGame->ControlPlanePos(pMsg->wParam);
break;
case VK_LEFT:
pGame->ControlPlanePos(pMsg->wParam);
break;
case VK_RIGHT:
pGame->ControlPlanePos(pMsg->wParam);
break;
}*/
break;
}
return CView::PreTranslateMessage(pMsg);
}
void CTestGameView::OnInitialUpdate()
{
CView::OnInitialUpdate();
// TODO: Add your specialized code here and/or call the base class
((CMainFrame*)AfxGetMainWnd())->pGView = this;
bEnableStarMenu = TRUE;
}
void CTestGameView::OnUpdateStart(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(bEnableStarMenu);
}
void CTestGameView::Stop()
{
if ( pGame )
{
delete pGame;
}
Invalidate();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -