• 大小: 78KB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2021-06-02
  • 语言: C/C++
  • 标签: MFC  游戏  射击  

资源简介

飞行射击游戏,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个文件信息

评论

共有 条评论