-
Notifications
You must be signed in to change notification settings - Fork 0
/
gameobject.h
48 lines (40 loc) · 1005 Bytes
/
gameobject.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
40
41
42
43
44
45
46
47
48
#ifndef GAMEOBJECT_H
#define GAMEOBJECT_H
#include <QObject>
#include <QRect>
#include <QPixmap>
#include "route.h"
#include <memory>
#include <QPainter>
#include <memory>
#include "drawed.h"
#include "animated.h"
#include "routed.h"
#include "moved.h"
class GameObject: public Drawed, protected Routed, public Moved
{
public:
enum class Type{Player, Enemy, Explosion, EnemyShot, PlayerShot, Asteroid};
GameObject() = default;
virtual ~GameObject() = default;
void draw(std::shared_ptr<QPainter> painter);
void addRoute(Route::Path path, QPoint end);
void addRoute(Route::Path path);
void setPixmap(QString path);
QPoint getPoint();
Type getType();
void hurt();
bool isAlive();
void moveRectTo(QPoint point);
virtual void read(const QJsonObject &json);
virtual void write(QJsonObject &json) const;
protected:
double speed;
GameObject::Type gameObjectType;
QRect rect;
QPixmap pixmap;
int lives = 1;
private:
QString imagePath;
};
#endif // GAMEOBJECT_H