飞机游戏源码学习小结

来源:互联网 发布:南昌淘宝运营公司 编辑:程序博客网 时间:2024/05/21 22:34

学习飞机游戏源码小结

1.其中一个类CGame

class CGame  
{
public:
CGame();
virtual ~CGame();
//显示信息
void DrawMessage(CDC*pDC,int width,int height);
//火力位图是否出现
void FireOutIf();
//子弹移动
void shotmove();
//敌机发射子弹
void Enemyshot();
//敌机出现
void Enemyplaneout();
//我方射击
void Shot();
//设置透明位图
void TransparentBitmap(HDC hdc, HBITMAP hBitmap, 
    short xStart, short yStart, short xadd,short yadd,
COLORREF cTransparentColor);
//透明色
    COLORREF cTransparentColor;
//飞机爆炸位图
CBitmap enemydead;
//敌机子弹位图
CBitmap bmenemyshot;
//敌机位图
CBitmap enemy;
//我方子弹
CBitmap bmshot;
//我方飞机
CBitmap plane;
//我方飞机数量
short numplane;
//背景数组
int back[15][12];
//飞机出现位置
int xStart,yStart;
//火力位图
CBitmap bmfire;
//火力位置
CPoint pointfire;
//是否出现
bool iffire;
//火力强度
int fire;
};

主要是一个游戏的类,其中注意的是CBitmap类,用于加载图片

2.class CMainFrame : public CFrameWnd
{


    CRect m_FullScreenRect;//全屏显示时的窗口位置
// Attributes
public:
void OnFullScreen();
};

 CRect 用于位置信息

3.CVIEW全图显示的类

class CMy6_1View : public CView
{

public:
CMy6_1Doc* GetDocument();
public:
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);
public:
//暂停
bool bPause;
//屏幕宽度
int width;
//屏幕高度
int height;
//类CGame
CGame game;
//背景位图移动大小:10
int goup;
//背景位图
CBitmap backmap;
virtual ~CMy6_1View();

protected:

afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);

};

afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);

afx_msg宏表示声明的是一个消息响应函数

0 0
原创粉丝点击