📄 blockdoc.cpp
字号:
// blockDoc.cpp : implementation of the CBlockDoc class
//
#include "stdafx.h"
#include "block.h"
#include "blockDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBlockDoc
#include "blockview.h"
IMPLEMENT_DYNCREATE(CBlockDoc, CDocument)
BEGIN_MESSAGE_MAP(CBlockDoc, CDocument)
//{{AFX_MSG_MAP(CBlockDoc)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBlockDoc construction/destruction
CBlockDoc::CBlockDoc()
{
// TODO: add one-time construction code here
}
CBlockDoc::~CBlockDoc()
{
}
BOOL CBlockDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
memset(m_iMap,0,sizeof(m_iMap));
m_clrBack=RGB(0,150,0);
m_clrBlock=RGB(150,0,100);
m_iLevel=0;
m_uScore=0;
m_iNextShape=rand()%7;
POSITION pos;
pos=this->GetFirstViewPosition();
CBlockView *pView=(CBlockView *)GetNextView(pos);
pView->CreateSquare();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CBlockDoc serialization
void CBlockDoc::Serialize(CArchive& ar)
{
int i,j;
if (ar.IsStoring())
{
// TODO: add storing code here
ar<<m_clrBack<<m_clrBlock<<m_iLevel;
ar<<m_iNextShape<<m_iShape<<m_iState<<m_uScore;
for(i=0;i<20;i++)
for(j=0;j<12;j++)
ar<<m_iMap[i][j];
for(i=0;i<4;i++)
ar<<m_ptCurrentPos[i].x<<m_ptCurrentPos[i].y;
}
else
{
ar>>m_clrBack>>m_clrBlock>>m_iLevel;
ar>>m_iNextShape>>m_iShape>>m_iState>>m_uScore;
for(i=0;i<20;i++)
for(j=0;j<12;j++)
ar>>m_iMap[i][j];
for(i=0;i<4;i++)
ar>>m_ptCurrentPos[i].x>>m_ptCurrentPos[i].y;
}
}
/////////////////////////////////////////////////////////////////////////////
// CBlockDoc diagnostics
#ifdef _DEBUG
void CBlockDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CBlockDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -