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

📄 scrollingbackground.h

📁 it s a small game we can play it for fun
💻 H
字号:
//-----------------------------------------------------------------
// ScrollingBackground Object
// C++ Header - ScrollingBackground.h
//-----------------------------------------------------------------

#pragma once

//-----------------------------------------------------------------
// Include Files
//-----------------------------------------------------------------
#include <windows.h>
#include "Background.h"

//-----------------------------------------------------------------
// Custom Data Types
//-----------------------------------------------------------------
typedef WORD        SCROLLDIR;
const SCROLLDIR     SD_UP     = 0,
                    SD_RIGHT  = 1,
                    SD_DOWN   = 2,
                    SD_LEFT   = 3;

//-----------------------------------------------------------------
// Background Layer Class
//-----------------------------------------------------------------
class BackgroundLayer : Bitmap
{
protected:
  // Member Variables
  RECT      m_rcViewport;
  int       m_iSpeed;
  SCROLLDIR m_sdDirection;

public:
  // Constructor(s)/Destructor
  BackgroundLayer(HDC hDC, LPTSTR szFileName, int iSpeed,
    SCROLLDIR sdDirection);
  BackgroundLayer(HDC hDC, UINT uiResID, HINSTANCE hInstance, int iSpeed = 0,
    SCROLLDIR sdDirection = SD_LEFT);

  // General Methods
  virtual void  Update();
  virtual void  Draw(HDC hDC, int x, int y, BOOL bTrans = FALSE,
    COLORREF crTransColor = RGB(255, 0, 255));
  void          SetSpeed(int iSpeed)  { m_iSpeed = iSpeed; };
  void          SetDirection(SCROLLDIR sdDirection)
    { m_sdDirection = sdDirection; };
  void          SetViewport(RECT& rcViewport)
    { CopyRect(&m_rcViewport, &rcViewport); };
};

//-----------------------------------------------------------------
// Scrolling Background Class
//-----------------------------------------------------------------
class ScrollingBackground : Background
{
protected:
  // Member Variables
  int               m_iNumLayers;
  BackgroundLayer*  m_pLayers[10];

public:
  // Constructor(s)/Destructor
          ScrollingBackground(int iWidth, int iHeight);
  virtual ~ScrollingBackground();

  // General Methods
  virtual void  Update();
  virtual void  Draw(HDC hDC, BOOL bTrans = FALSE,
    COLORREF crTransColor = RGB(255, 0, 255));
  void          AddLayer(BackgroundLayer* pLayer);
};

⌨️ 快捷键说明

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