forked from capocattiveria/Super_mario
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathObject.h
48 lines (33 loc) · 1.23 KB
/
Object.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
#pragma once
#include <string>
#include <QGraphicsPixmapItem>
#include "utils.h"
// base class for all game objects
class Object : public QGraphicsPixmapItem
{
protected:
bool collidable; // whether the object is collidable
bool collider_visible; // whether the collider is visible
std::string level_name; // level where object is located
public:
Object();
// getters
bool isCollidable() {return collidable;}
void setLevelName(std::string _level_name) { level_name = _level_name; }
std::string getLevelName() { return level_name; }
// object name
virtual std::string name() = 0;
// animate (=compute next texture)
virtual void animate() = 0;
// advance (=compute next location)
virtual void advance() = 0;
// solve collisions
virtual void solveCollisions() = 0;
// object hit by 'what' from direction 'fromDir'
virtual void hit(Object *what, Direction fromDir) = 0;
// utility methods: detect collision/touching direction
virtual Direction collisionDirection(Object* item);
virtual Direction touchingDirection(Object* item);
// show / hide collider
void toogleColliderVisible();
};