📄 snakeview.h
字号:
// SnakeView.h : interface of the CSnakeView class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_SNAKEVIEW_H__E2A73A3E_1A25_4425_9955_5FBC7EC53B2D__INCLUDED_)
#define AFX_SNAKEVIEW_H__E2A73A3E_1A25_4425_9955_5FBC7EC53B2D__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define N_000000 100
class CSnakeView : public CView
{
protected: // create from serialization only
CSnakeView();
DECLARE_DYNCREATE(CSnakeView)
// Attributes
public:
CSnakeDoc* GetDocument();
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSnakeView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
//}}AFX_VIRTUAL
// Implementation
public:
BOOL IsInitGame();
void InitGame();
void ScoreIncrease();
void BecomeLonger();
BOOL IsEat();
void DisappearFood();
BOOL IsFoodExist();
void CreateFood();
BOOL IsGameOver();
void SnakeMove(int direction);
BOOL IsDirectionChange();
virtual ~CSnakeView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
int speed;
int init_flag;
CString m_str;
int score;
CRect m_rect;
int node_size;
int node_num;
int direction;
int old_direction;
int life;
CBitmap m_BkgBmp,m_BodyBmp,m_FoodBmp;
CDC m_BkgDC,m_BodyDC,m_FoodDC;
struct Node
{
int x;
int y;
}node[N_000000],old_tail;
struct FoodPosition
{
int x;
int y;
}food_pos;
int food_kind;
int food_exist;
//{{AFX_MSG(CSnakeView)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnNewgame();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
};
#ifndef _DEBUG // debug version in SnakeView.cpp
inline CSnakeDoc* CSnakeView::GetDocument()
{ return (CSnakeDoc*)m_pDocument; }
#endif
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SNAKEVIEW_H__E2A73A3E_1A25_4425_9955_5FBC7EC53B2D__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -