- Timestamp:
- Jul 2, 2006, 5:30:14 AM (18 years ago)
- Location:
- trunk/src/world_entities/elements
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/elements/glgui_radar.cc
r8992 r8993 17 17 18 18 #include "glgui_radar.h" 19 #include "world_entity.h" 19 20 20 21 namespace OrxGui … … 24 25 */ 25 26 GLGuiRadar::GLGuiRadar () 26 { 27 } 27 {} 28 28 29 29 … … 32 32 */ 33 33 GLGuiRadar::~GLGuiRadar () 34 {} 35 36 void GLGuiRadar::init() 34 37 { 38 this->_updateInterval = 1.0f; 39 this->_timePassed = 0.0f; 40 this->_range = 100.0f; 41 this->_centerNode = NULL; 35 42 } 36 43 44 void GLGuiRadar::setCenterNode(const PNode* center) 45 { 46 this->_centerNode = center; 47 } 48 49 void GLGuiRadar::addEntityList(const std::list<WorldEntity*>* entityList, const Color& color) 50 { 51 GLGuiRadar::DotList dotList; 52 dotList.dotColor = color; 53 dotList.entityList = entityList; 54 55 this->_dotLists.push_back(dotList); 56 } 57 58 void GLGuiRadar::removeEntityList(const std::list<WorldEntity*>* entityList) 59 { 60 std::vector<DotList>::iterator it; 61 for (it = this->_dotLists.begin(); it != this->_dotLists.end(); ++it) 62 if ((*it).entityList == entityList) 63 { 64 this->_dotLists.erase(it); 65 break; 66 } 67 } 37 68 38 69 … … 45 76 void GLGuiRadar::tick(float dt) 46 77 { 78 _timePassed+=dt; 47 79 80 if (_timePassed > _updateInterval) 81 { 82 _timePassed-=_updateInterval; 83 this->updateRadar(); 84 } 85 86 } 87 88 void GLGuiRadar::updateRadar() 89 { 90 if (_centerNode == NULL) 91 { 92 for (unsigned int i = 0; i < this->_dotLists.size(); ++i) 93 this->_dotLists[i].positions.clear(); 94 return; 95 } 96 97 std::list<WorldEntity*>::const_iterator it; 98 for (unsigned int i = 0; i < this->_dotLists.size(); ++i) 99 { 100 this->_dotLists[i].positions.clear(); 101 102 for (it = _dotLists[i].entityList->begin(); it != _dotLists[i].entityList->end(); ++it) 103 { 104 if (_centerNode->distance(*it) < this->_range) 105 { 106 this->_dotLists[i].positions.push_back(Vector2D(50, 50) + Vector2D(_centerNode->getAbsCoor().x - (*it)->getAbsCoor().x, _centerNode->getAbsCoor().y - (*it)->getAbsCoor().y)/_range * 50); 107 } 108 109 } 110 111 } 48 112 } 49 113 … … 51 115 void GLGuiRadar::draw() const 52 116 { 53 54 117 for (unsigned int i = 0; i < this->_dotLists.size(); ++i) 118 { 119 for (unsigned int j = 0; j < this->_dotLists[i].positions.size(); ++j) 120 { 121 } 122 } 55 123 } 56 124 … … 63 131 64 132 void GLGuiRadar::showing() 65 { 66 } 133 {} 67 134 68 135 void GLGuiRadar::hiding() 69 { 70 } 71 } 136 {}} -
trunk/src/world_entities/elements/glgui_radar.h
r8992 r8993 9 9 #include "glgui_widget.h" 10 10 11 class PNode; 11 12 class WorldEntity; 12 13 … … 27 28 virtual ~GLGuiRadar(); 28 29 30 void addEntityList(const std::list<WorldEntity*>* entityList, const Color& color); 31 void removeEntityList(const std::list<WorldEntity*>* entityList); 32 29 33 void setRange(float range); 30 34 35 void setCenterNode(const PNode* center); 31 36 void setUpdateInterval(float updateInterval) { this->_updateInterval = updateInterval; }; 32 37 void setAttenuation(Attenuation attenuation); 33 38 39 34 40 float range() const { return this->_range; } 35 41 42 void updateRadar(); 36 43 37 44 void tick(float dt); … … 44 51 45 52 private: 53 void init(); 54 55 private: 46 56 typedef struct 47 57 { 48 58 Color dotColor; 49 const std::list<WorldEntity*> &entityList;50 std::vector<Vector2D> position ;59 const std::list<WorldEntity*>* entityList; 60 std::vector<Vector2D> positions; 51 61 } 52 62 DotList; 53 63 54 std::vector<DotList> _dotLists; 64 const PNode* _centerNode; 65 std::vector<DotList> _dotLists; 55 66 56 Attenuation _attenuation;57 float _range;67 Attenuation _attenuation; 68 float _range; 58 69 59 70 60 float _updateInterval;61 float _timePassed;71 float _updateInterval; 72 float _timePassed; 62 73 }; 63 74 }
Note: See TracChangeset
for help on using the changeset viewer.