hunter.h
来自「一个同学用C++写的小游戏」· C头文件 代码 · 共 84 行
H
84 行
// pet.h : Interface of class pet
#ifndef HUNTER_H
#define HUNTER_H
#include <vector>
#include "bitmap.h"
//----------------------------------------------------------------
// Define Direction for Hunter
//-----------------------------------------------------------------
enum HunterDirection
{
Hunter_Up, Hunter_Down, Hunter_Left, Hunter_Right, Hunter_None,
Hunter_DirectNumber
};
//-----------------------------------------------------------------
class Hunter
{
public:
Hunter( SimpleWindow& Window );
Position GetPosition() const;
void SetDirection( const HunterDirection &D );
void Create();
void Move();
protected:
SimpleWindow& GetWindow() const;
const BitMap& GetBmp( const HunterDirection& D ) const;
BitMap& GetBmp( const HunterDirection& D );
void SetPosition( const Position& p );
HunterDirection GetDirection() const; // get direction
Position NewPosition() const; // set a new position for bug to move to
//-----------------------------------------------------------
// get and set vertical movement
//-----------------------------------------------------------
float GetVertMovement() const;
void SetVertMovement( float v);
//-------------------------------------------------------------
// get and set horizontal movement
//-------------------------------------------------------------
float GetHorizMovement() const;
void SetHorizMovement( float h );
//-------------------------------------------------------------
// Draw and erase the bitmaps
//-------------------------------------------------------------
void Draw();
void Erase();
//-------------------------------------------------------------
// Judge whether the pet is at the Edge of window
//-------------------------------------------------------------
bool AtUpEdge() const;
bool AtDownEdge() const;
bool AtLeftEdge() const;
bool AtRightEdge() const;
private:
//------------------------------------------------------------
// Data members
//------------------------------------------------------------
SimpleWindow& m_Window;
vector<BitMap> m_Bmp;
HunterDirection m_HunterDirection;
Position m_HunterPosition;
float m_HorizMovement;
float m_VertMovement;
};
#endif
//------------------------------------------------------------------------
// end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?