bounds.h

来自「direct3d游戏编程基础源码」· C头文件 代码 · 共 37 行

H
37
字号
#ifndef H_BOUNDS
#define H_BOUNDS

typedef unsigned char PIXELVALUE;

class PhysicalSprite
{
public:
  // Constructor.  Initializes all data structures needed
  PhysicalSprite(PIXELVALUE* pix, int pitch, 
                 int w, int h, PIXELVALUE transparent);
  // Destructor.  Frees allocated buffers
  virtual ~PhysicalSprite();

  // Test this sprite against another to see if they collide
  bool DetectCollision(const PhysicalSprite& other);

  // Set the sprite's position in the 2D world
  void SetPosition(int X, int Y) { x=X; y=Y; }

private:
  // Calculates the sprite's bounds during initialization
  void CalculateBounds(PIXELVALUE* pix, int pitch, PIXELVALUE transparent);

protected:
  int  x;
  int  y;
  int  width;
  int  height;
  int* top;
  int* bottom;
  int* left;
  int* right;
};


#endif // H_BOUNDS

⌨️ 快捷键说明

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