-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShape.h
More file actions
82 lines (69 loc) · 1.47 KB
/
Shape.h
File metadata and controls
82 lines (69 loc) · 1.47 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#ifndef SHAPE_H
#define SHAPE_H
#include <SFML/Graphics.hpp>
#include <Box2D/Box2D.h>
#include <ctime>
#include <iostream>
using namespace std;
class Game;
class Shape;
class ParticleSystem;
struct b2BodyUserData
{
int id;
Shape* parent;
bool toBeRemoved;
bool isItem;
};
class Shape
{
public:
virtual ~Shape(void) = 0;
void update();
sf::Shape* getShape();
b2Body* getBody();
b2Vec2* getPosition() const
{
b2Vec2* v = const_cast<b2Vec2*>(&body->GetPosition());
return v;
/*return position;*/
};
void setPosition(b2Vec2* pos)
{
position = pos;
body->SetTransform(*pos, body->GetAngle());
};
void setPosition(b2Vec2* pos, float angle)
{
position = pos;
body->SetTransform(*pos, angle);
};
void makeStatic();
//void setDynamic(bool d) {dynamic = d;};
bool getDynamic() {return dynamic;};
void setId(int id) { userData.id = id; };
int getId() const {return userData.id;};
sf::Time timeSinceUpdate() const;
b2BodyUserData& getUserData() {return userData;};
//reset the update clock
void resetUpdateClock();
void startParticles();
protected:
Shape(Game* game, b2Vec2* position,
bool dynamic, int id, float density, float friction);
void checkForContacts();
sf::Shape* shape;
b2Body* body;
b2Vec2* position;
b2BodyUserData userData;
sf::Clock updateClock;
sf::Clock killTimer;
std::clock_t clock;
float density, friction;
float angle;
bool dynamic;
ParticleSystem* particleSystem;
//private:
Game* game;
};
#endif