⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 russiaboxview.cpp

📁 俄罗斯方块
💻 CPP
字号:
// RussiaBoxView.cpp : implementation of the CRussiaBoxView class
//

#include "stdafx.h"
#include "RussiaBox.h"

#include "RussiaBoxDoc.h"
#include "RussiaBoxView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CRussiaBoxView

IMPLEMENT_DYNCREATE(CRussiaBoxView, CView)

BEGIN_MESSAGE_MAP(CRussiaBoxView, CView)
	//{{AFX_MSG_MAP(CRussiaBoxView)
	ON_WM_KEYDOWN()
	ON_WM_TIMER()
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CRussiaBoxView construction/destruction

CRussiaBoxView::CRussiaBoxView()
{
	// TODO: add construction code here
//	this->SetTimer(1,1000,0);

}

CRussiaBoxView::~CRussiaBoxView()
{
}

BOOL CRussiaBoxView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CRussiaBoxView drawing

void CRussiaBoxView::OnDraw(CDC* pDC)
{
	CRussiaBoxDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	this->SetTimer(1,1000,0);
	// TODO: add draw code for native data here

	pDoc->pDownBoxesGame->Draw(pDC);


//	pDoc->pDownBoxes1->ClockWiseRotation();
	

}

/////////////////////////////////////////////////////////////////////////////
// CRussiaBoxView printing

BOOL CRussiaBoxView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CRussiaBoxView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CRussiaBoxView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CRussiaBoxView diagnostics

#ifdef _DEBUG
void CRussiaBoxView::AssertValid() const
{
	CView::AssertValid();
}

void CRussiaBoxView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CRussiaBoxDoc* CRussiaBoxView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CRussiaBoxDoc)));
	return (CRussiaBoxDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CRussiaBoxView message handlers

void CRussiaBoxView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	// TODO: Add your message handler code here and/or call default
	if(nChar=='J' || nChar=='j')
	{
		GetDocument()->pDownBoxesGame->GetDownBoxes()->ClockWiseRotation();
		GetDocument()->UpdateAllViews(0); 
	}
	else if(nChar=='A' || nChar=='a')
	{
		GetDocument()->pDownBoxesGame->GetDownBoxes()->MoveLeft();
		GetDocument()->UpdateAllViews(0); 
	}
	else if(nChar=='D' || nChar=='d')
	{
		GetDocument()->pDownBoxesGame->GetDownBoxes()->MoveRight();
		GetDocument()->UpdateAllViews(0); 
	}
	else if(nChar=='S' || nChar=='s')
	{
		GetDocument()->pDownBoxesGame->GetDownBoxes()->MoveDown();
		GetDocument()->UpdateAllViews(0); 
	}
/*	else if(nChar=='W' || nChar=='w')
	{
		GetDocument()->pDownBoxes->MoveUp();
		GetDocument()->UpdateAllViews(0); 
	}*/
	CView::OnKeyDown(nChar, nRepCnt, nFlags);
}

void CRussiaBoxView::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default

	GetDocument()->pDownBoxesGame->OnTimer(nIDEvent);
	GetDocument()->UpdateAllViews(0);
	CView::OnTimer(nIDEvent);
}

⌨️ 快捷键说明

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