-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameObject.hpp
141 lines (130 loc) · 2.85 KB
/
GameObject.hpp
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#ifndef _COMMON_GAMEOBJECT_HPP
#define _COMMON_GAMEOBJECT_HPP
//Classic and Seasons
#include <game/Sprite.h>
#include <game/CompoSprite.h>
#include <lang/Object.h>
#include <lua/LuaTable.h>
enum ColliderType
{
COLLIDER_BASIC,
COLLIDER_EAGLE,
COLLIDER_STATIC,
COLLIDER_BIRD,
COLLIDER_PIG,
COLLIDER_GHOST,
COLLIDER_EGG,
COLLIDER_BASKETBALL,
COLLIDER_INVISIBLE,
COLLIDER_PORTAL,
COLLIDER_HOOP,
COLLIDER_NO_COLLISION,
COLLIDER_NO_BIRD_COLLISION,
COLLIDER_NO_OTHER_COLLISION,
COLLIDER_GLUE,
COLLIDER_BUBBLE,
COLLIDER_COUNT,
COLLIDER_INVALID
};
enum ShapeType
{
SHAPE_CIRCLE,
SHAPE_BOX,
SHAPE_POLYGON,
SHAPE_COUNT,
SHAPE_INVALID
};
struct TransformData
{
float x;
float y;
float angle;
};
class GameObject :
public lang::Object
{
public:
GameObject(b2World* world);
~GameObject();
void create();
void recreate();
void setupLuaTable(LuaTable& world);
ColliderType getColliderType() const;
ShapeType getShapeType() const;
math::float2 getScale() const;
float getWidth() const;
float getHeight() const;
bool getVisible() const;
bool isSensor() const;
void setColliderType (ColliderType type);
void setShape(ShapeType shape);
void setDimensions(float width, float height);
void setRadius(float radius);
void setVertices(const std::vector<b2Vec2>& verts);
void setDensity(float density);
void setFriction(float friction);
void setRestitution(float restitution);
void setScale(math::float2 scale);
void setVisible(bool visible);
void setSensor(bool sensor);
void setFilterCategory(int category);
void setFilterMask(int mask);
int incrementPortalPingPongCount(std::string enterPortal, std::string exitPortal);
void setGravityEnabled(bool enabled);
bool isGravityEnabled const();
void triggerRemoval(float delay);
private:
ColliderType m_colliderType;
ShapeType m_shapeType;
float m_width;
float m_height;
float m_density;
float m_friction;
float m_restitution;
math::float2 m_scale;
b2World* m_world;
bool m_visible;
bool m_sensor;
bool m_gravityEnabled;
public:
b2Body* m_body;
private:
std::vector<b2Vec2> m_vertices;
std::string m_lastExitedPortal;
int m_portalPingPongCount;
void createFixture();
public:
TransformData positions[2];
std::string rollingSound;
lua::LuaTable objectTable;
math::float2 afterCollisionVelocity;
std::string objectName;
std::string spriteName;
std::string textureName;
game::Sprite* sprite;
game::CompoSprite* compoSprite;
gr::Image* texture;
float radius;
float x;
float y;
float angle;
float z_order;
bool updateAfterCollision;
bool oldSleep;
bool collision;
bool hasForceOrFriction;
bool toBeRemoved;
float removeTimer;
bool scalable;
float scaleX;
float scaleY;
float originalScaleX;
float originalScaleY;
bool ghostBlock;
bool hoopCorrectlyEntered;
float ghostWobbleAngle;
float passThroughParticleTimer;
std::string passThroughParticles;
std::string passThroughSound;
};
#endif