ps.h

来自「Direct3D游戏编程入门教程源代码.rar」· C头文件 代码 · 共 37 行

H
37
字号
#ifndef H_PHYSICALSPRITE
#define H_PHYSICALSPRITE

// This is just an example.  PIXELVALUE can be any size/integral type
typedef unsigned char PIXELVALUE;

class PhysicalSprite
{
public:
  // Constructor.  Initializes all data structures needed
  PhysicalSprite(PIXELVALUE* pix, 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);

  void SetPosition(int X, int Y) { x=X; y=Y; }

private:
  // Calculate the bit array from the pixel array
  void CalculateBitArray(PIXELVALUE* pix, PIXELVALUE transparent);
  // Retrieve a 32 bit array starting from a certain pixel position
  unsigned GetBitArray(int x, int y) const;
  // Return a bit mask for the given bits number
  static unsigned GetBitMask(int UpperBitsNumber);
protected:
  int          width;
  int          height;
  int          x;
  int          y;
  unsigned*    bitarray;
  int          groups_number;
};


#endif // PHYSICALSPRITE

⌨️ 快捷键说明

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