📄 snakeview.h
字号:
// snakeView.h : interface of the CSnakeView class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_SNAKEVIEW_H__4D2A10CB_672D_11D6_B20C_00E04C4F707C__INCLUDED_)
#define AFX_SNAKEVIEW_H__4D2A10CB_672D_11D6_B20C_00E04C4F707C__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "midi.h"
#include "wave.h"
//**********************************
#define IDT_MOVE 4444
//**********************************
#define PLAYER1POSX 220
#define PLAYER1POSY 225
#define PLAYER2POSX 220
#define PLAYER2POSY 265
#define PLAYERPOSR 7
#define SELECTCOLOR RGB(255,0,0)
//**********************************
#define BACKCOLOR RGB(0,0,0)
#define PLAYER1COLOR RGB(64,128,128)
#define PLAYER2COLOR RGB(255,128,255)
#define FOODCOLOR RGB(0,255,0)
#define BEDGECOLOR RGB(0,1,255)
//**********************************
#define HISCOREX 325
#define HISCOREY 30
//**********************************
#define UP_POS 0
#define RIGHT_POS 1
#define BOTTOM_POS 2
#define LEFT_POS 3
//**********************************
#define MAX_STAGE 32
//**********************************
struct CSnake //定义蛇的结构体
{
POINT pos[64];
int position;
int len;
};
struct CPlay //定义玩家结构体
{
int life;// 生命
int score;//分数
CSnake snake;
};
class CSnakeView : public CView
{
protected: // create from serialization only
CSnakeView();
DECLARE_DYNCREATE(CSnakeView)
//游戏数据
public:
//CBitmap m_Title;//标题画面
//BITMAP m_Bm;//位图数据
CBrush m_Backbrush,m_Player1brush,m_Player2brush,m_Foodbrush,m_Bedgebrush;
BOOL m_GameStart;//游戏是否开始
BOOL m_GameMode;//游戏模式,TRUE为双人模式
BOOL m_Stage;//游戏关数
BOOL m_Speed;//游戏速度
BOOL m_Pause;//游戏暂停
BOOL m_SetMusic;//启用游戏音效
BOOL m_GameOver;//
BOOL m_PassStage;//过关
int m_LeftFood;//蚕数
int m_Bedges;//障碍物数
int m_Hiscore;//记录最高分
int m_tempplayer1score,m_tempplayer2score;
COLORREF m_Box[50][38];
CPlay m_player1,m_player2;
void DrawBox(CClientDC *pDC,const i,const j,const COLORREF color);//画一个单位方格
void DrawView();//重画数据显示
void DrawTitle();//画标题画面
int GetHiscore();//得到最高分
void SaveHiscore();//保存最高分
void InitPlayer1();
void InitPlayer2();
void InitGameDat();//初始化游戏数据
CMidi m_mid;//播放mid
CWave m_wave;//播放wave
// Attributes
public:
// 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:
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CSnakeView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CSnakeView)
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in snakeView.cpp
#endif
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SNAKEVIEW_H__4D2A10CB_672D_11D6_B20C_00E04C4F707C__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -