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

📄 snakeview.h

📁 C语言的贪吃蛇代码 绝对正确无误 保证TC2.0平台上正常运行
💻 H
字号:
// SnakeView.h : interface of the CSnakeView class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_SNAKEVIEW_H__2EBD7F0C_452B_11D7_B6CA_0050BAE90E03__INCLUDED_)
#define AFX_SNAKEVIEW_H__2EBD7F0C_452B_11D7_B6CA_0050BAE90E03__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "IGraphicOut.h"
#include "IActionHandler.h"

class CSnakeView : public CView, public IGraphicOut
{
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);
    virtual void OnInitialUpdate();
    protected:
    virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
    virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
    virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
    //}}AFX_VIRTUAL

// Implementation
public:
    void scoreBoard(char *scoreMessages);
	void close();
	void redraw();
    void SetActionHandler(IActionHandler *pHandler);

    void setDisplaySize(int width, int height);
    void drawScore(int score);
    void drawVertWall(int x, int y1, int y2);
    void drawHorzWall(int x1, int x2, int y);
    void drawFood(int type, int x, int y);
    void drawBody(int x, int y);
    void drawHead(int type, int x, int y);

    virtual ~CSnakeView();
#ifdef _DEBUG
    virtual void AssertValid() const;
    virtual void Dump(CDumpContext& dc) const;
#endif

private:
	void closeWindow();

// Generated message map functions
protected:
    //{{AFX_MSG(CSnakeView)
    afx_msg void OnSize(UINT nType, int cx, int cy);
    afx_msg void OnPaint();
	afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnDestroy();
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnChangeLevel();
	//}}AFX_MSG
    DECLARE_MESSAGE_MAP()
private:
	UINT m_wTimerRes;
	int m_timerID;
    IActionHandler * m_pActionHandler;
    void drawSprite(CDC *pDC, int resID, int ix, int iy);
    CSize m_sizeDB;
    CBitmap * m_pBmpDB;
    CDC * m_pDCMemDB;
    int m_numCellsY;
    int m_numCellsX;

    friend void CALLBACK myTimerCallback(UINT wTimerID, 
                                         UINT msg, 
                                         DWORD dwUser, 
                                         DWORD dw1, 
                                         DWORD dw2);
};

#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__2EBD7F0C_452B_11D7_B6CA_0050BAE90E03__INCLUDED_)

⌨️ 快捷键说明

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