00001
00002
00003
00004
00005
00007
00012 #ifndef HGEENTITY__
00013 #define HGEENTITY__
00014
00015 #include "hgePolygon.h"
00016
00018
00019
00033 enum hgeEntityLayers
00034 {
00035 HEL_BACK = 0,
00036 HEL_MIDDLE1,
00037 HEL_MIDDLE2,
00038 HEL_FRONT
00039 };
00040
00042
00043
00053 class hgeEntity : public hgePolygon
00054 {
00055 private:
00056
00057
00058 bool remove_ent;
00059
00061 bool is_static;
00062
00064 int layer;
00065
00066 public:
00067
00079 hgeEntity(int m_Layer, bool m_Static) : hgePolygon()
00080 {
00081 is_static = m_Static;
00082 layer = m_Layer;
00083 remove_ent = false;
00084 is_entity = true;
00085 }
00086
00087 inline bool IsStatic() { return is_static; }
00088 inline bool IsDynamic(){ return !is_static; }
00089
00090 inline int GetRenderLayer() { return layer; }
00091
00092
00093 virtual hgeEntity *Spawn() = 0;
00094 virtual void Initialize() { return; }
00095 virtual void Update(float dt) { return; }
00096 virtual void Render() { hgePolygon::Render(); }
00097
00098
00099 inline void Delete() { remove_ent = true; }
00100
00101
00102 inline bool Deleted() { return remove_ent; }
00103 };
00104
00106
00107
00108
00117 class hgeEntityEx: public hgeEntity
00118 {
00119 private:
00120
00121
00122 hgeVector master_hotspot;
00123
00124
00125 float rot;
00126 float scale;
00127
00128 void ApplyTransform( float angle_dt );
00129
00130 public:
00131
00132
00138 hgeVector GetRotatedPosition(hgeVector pos, float r)
00139 {
00140 hgeVector m = pos - master_hotspot;
00141 m.Rotate(r);
00142 return master_hotspot + m;
00143 }
00144
00145 hgeVector GetPosition() { return master_hotspot; }
00146
00147 void SetPosition(hgeVector pos)
00148 {
00149 hgeEntityEx::Shift(pos - master_hotspot);
00150 }
00151
00152 void SetHotSpot(hgeVector m_hotspot)
00153 {
00154 hgePolygon::SetHotSpot(m_hotspot);
00155 master_hotspot = hgeVector(aabb.x1, aabb.y1) + m_hotspot;
00156 }
00157
00158 void Shift(hgeVector amount)
00159 {
00160 hgePolygon::Shift(amount);
00161 master_hotspot += amount;
00162 }
00163
00164
00165 hgeEntityEx(int m_Layer, bool m_Static) : hgeEntity(m_Layer, m_Static)
00166 {
00167 rot = 0;
00168 scale = 1;
00169 }
00170
00171 inline void Rotate(float m_angle) { ApplyTransform( m_angle ); }
00172 inline void SetRotation(float m_angle) { ApplyTransform( m_angle-rot ); }
00173 inline float GetRotation() { return rot; }
00174
00175
00176 };
00177
00178
00179 #endif