forked from WuYufeng233/Tank3000
-
Notifications
You must be signed in to change notification settings - Fork 0
/
base.h
39 lines (31 loc) · 1013 Bytes
/
base.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef BASE_H
#define BASE_H
//大基类,可以派生出各种其他模块
#include<QPoint>
#include<QRect>
#include<QPainter>
enum Direction{Up,Down,Left,Right};
class Base
{
public:
friend class Missile;
friend class Tank;
Base(){}
virtual void display(QPainter &paint)=0;//纯虚函数,用于绘制图片
virtual void move()=0;//纯虚函数,用于移动
bool isDisappeared() const;//判断是否存在
bool isCollision(const Base &base) const;//判断两物体是否碰撞
virtual void setDisappear(bool disappear);//设置存在状态
QPoint getPos() const;//获取左上角点坐标
virtual void beAttacked(int attack);//被攻击扣血
protected:
QPoint pos;//左上角点坐标
QRect rectSphere;//所及范围
Direction dir;//前进方向
bool disappear;//存在状态
int step;//步进长
int life;//血量
int attack;//攻击力
virtual void calSphere()=0;
};
#endif // BASE_H