资源简介
飞行射击游戏,C++编写,使用VC++ 6.0或者相关编译软件即可运行。相关的说明文档在内部有,每个类的用法以及功能描述都在里面,更多内容见文档。欢迎下载。
代码片段和文件信息
//-----------------------------------------------------------------
// Background object
// C++ Source - Background.cpp
//-----------------------------------------------------------------
//Download by http://www.NewXing.com
//-----------------------------------------------------------------
// Include Files
//-----------------------------------------------------------------
#include “Background.h“
//-----------------------------------------------------------------
// Background Constructor(s)/Destructor
//-----------------------------------------------------------------
Background::Background(int iWidth int iHeight COLORREF crColor)
{
// Initialize the member variables
m_iWidth = iWidth;
m_iHeight = iHeight;
m_crColor = crColor;
m_pBitmap = NULL;
}
Background::Background(Bitmap* pBitmap)
{
// Initialize the member variables
m_crColor = 0;
m_pBitmap = pBitmap;
m_iWidth = pBitmap->GetWidth();
m_iHeight = pBitmap->GetHeight();
}
Background::~Background()
{
}
//-----------------------------------------------------------------
// Background General Methods
//-----------------------------------------------------------------
void Background::Update()
{
// Do nothing since the basic background is not animated
}
void Background::Draw(HDC hDC)
{
// Draw the background
if (m_pBitmap != NULL)
m_pBitmap->Draw(hDC 0 0);
else
{
RECT rect = { 0 0 m_iWidth m_iHeight };
HBRUSH hBrush = CreateSolidBrush(m_crColor);
FillRect(hDC &rect hBrush);
Deleteobject(hBrush);
}
}
//-----------------------------------------------------------------
// StarryBackground Constructor
//-----------------------------------------------------------------
StarryBackground::StarryBackground(int iWidth int iHeight int iNumStars
int iTwinkleDelay) : Background(iWidth iHeight 0)
{
// Initialize the member variables
m_iNumStars = min(iNumStars 100);
m_iTwinkleDelay = iTwinkleDelay;
// Create the stars
for (int i = 0; i < iNumStars; i++)
{
m_ptStars[i].x = rand() % iWidth;
m_ptStars[i].y = rand() % iHeight;
m_crStarColors[i] = RGB(128 128 128);
}
}
StarryBackground::~StarryBackground()
{
}
//-----------------------------------------------------------------
// StarryBackground General Methods
//-----------------------------------------------------------------
void StarryBackground::Update()
{
// Randomly change the shade of the stars so that they twinkle
int iRGB;
for (int i = 0; i < m_iNumStars; i++)
if ((rand() % m_iTwinkleDelay) == 0)
{
iRGB = rand() % 256;
m_crStarColors[i] = RGB(iRGB iRGB iRGB);
}
}
void StarryBackground::Draw(HDC hDC)
{
// Draw the solid black background
RECT rect = { 0 0 m_iWidth m_iHeight };
HBRUSH hBrush = CreateSolidBrush(RGB(0 0 0));
FillRect(hDC &rect hBrush);
Deleteobject(hBrush);
// Draw the stars
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1750 2013-12-02 06:11 www.NewXing.com\Background.h
文件 1515 2013-12-02 06:11 www.NewXing.com\Bitmap.h
文件 4658 2013-12-02 06:11 www.NewXing.com\GameEngine.h
文件 1464 2013-12-02 06:11 www.NewXing.com\MeteorDefense.h
文件 1249 2013-12-02 06:11 www.NewXing.com\Resource.h
文件 6209 2013-12-02 06:11 www.NewXing.com\Sprite.h
文件 3116 2013-12-02 06:11 www.NewXing.com\Background.cpp
文件 6819 2013-12-02 06:11 www.NewXing.com\Bitmap.cpp
文件 14230 2013-12-02 06:11 www.NewXing.com\GameEngine.cpp
文件 9066 2013-12-02 06:11 www.NewXing.com\MeteorDefense.cpp
文件 5955 2013-12-02 06:11 www.NewXing.com\Sprite.cpp
....... 19818 2004-01-09 00:37 www.NewXing.com\Res\City.bmp
....... 147510 2004-01-09 00:47 www.NewXing.com\Res\Explosion.bmp
....... 118614 2004-01-09 00:37 www.NewXing.com\Res\GameOver.bmp
....... 93654 2004-01-09 00:37 www.NewXing.com\Res\Ground.bmp
....... 87302 2004-01-09 00:43 www.NewXing.com\Res\Meteor.bmp
....... 2358 2004-01-09 00:37 www.NewXing.com\Res\Missile.bmp
....... 3126 2004-01-09 00:37 www.NewXing.com\Res\Target.bmp
....... 66266 2002-07-29 13:09 www.NewXing.com\Res\BigExplode.wav
....... 15490 2002-07-29 13:07 www.NewXing.com\Res\Explode.wav
....... 8166 2002-07-29 13:05 www.NewXing.com\Res\Fire.wav
....... 4764 2007-10-16 14:16 www.NewXing.com\MeteorDefense.dsp
....... 532 2007-10-16 14:13 www.NewXing.com\MeteorDefense.dsw
....... 2238 2002-07-27 01:50 www.NewXing.com\Res\MeteorDefense.ico
....... 1406 2002-07-27 01:51 www.NewXing.com\Res\MeteorDefense_sm.ico
....... 31412 2002-07-29 14:17 www.NewXing.com\Music.mid
....... 31412 2002-07-29 14:17 www.NewXing.com\Res\Music.mid
....... 1511 2004-01-07 22:30 www.NewXing.com\MeteorDefense.rc
..AD... 0 2012-06-13 06:34 www.NewXing.com\Res
----------- --------- ---------- ----- ----
............此处省略2个文件信息
相关资源
- mfc 调用redis
- MFC视频播放器源码(支持avi/wma/mp3等格
- mfc绘图大全(画直线、矩形、椭圆)
- 打飞机小游戏57466
- MFC控件重绘
- hook,捕获所有案件,查找所有窗口,
- (学习)VS2010之MFC入门到精通教程
- 俄罗斯方块游戏源码(Tetris)
- MFC文档_视图_框架_模板结构体系深入
- 简单员工管理系统(适合初学MFC)
- c++ 猜拳小游戏
- 扫雷游戏.cpp
- 杨中科游戏开发引擎
- 智商超高的中国象棋游戏源码(C++版
- c++ 扫雷游戏源码(控制台)
- C++跑跑卡丁车
- C++“倒忌时”小游戏
- XX游戏客户端源码
- c++小游戏源码.doc
- 基于ege图形的推箱子游戏
- C语言ege贪吃蛇游戏
- C++小游戏4款(源码)
- 推箱子小游戏源码
- 五子棋游戏源码(控制台)
- 猜数字游戏.sb3
- C++贪吃蛇控制台小游戏代码
- 扫雷游戏.cpp(较简单)
- MFC五子棋游戏
- VC++ 大富翁4_大富翁游戏源码
- c++常用游戏算法及数据结构设计
评论
共有 条评论