Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 2, 2006, 5:30:14 AM (18 years ago)
Author:
bensch
Message:

radar should provide the right data now

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/elements/glgui_radar.cc

    r8992 r8993  
    1717
    1818#include "glgui_radar.h"
     19#include "world_entity.h"
    1920
    2021namespace OrxGui
     
    2425   */
    2526  GLGuiRadar::GLGuiRadar ()
    26   {
    27   }
     27  {}
    2828
    2929
     
    3232   */
    3333  GLGuiRadar::~GLGuiRadar ()
     34  {}
     35
     36  void GLGuiRadar::init()
    3437  {
     38    this->_updateInterval = 1.0f;
     39    this->_timePassed = 0.0f;
     40    this->_range = 100.0f;
     41    this->_centerNode = NULL;
    3542  }
    3643
     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  }
    3768
    3869
     
    4576  void GLGuiRadar::tick(float dt)
    4677  {
     78    _timePassed+=dt;
    4779
     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    }
    48112  }
    49113
     
    51115  void GLGuiRadar::draw() const
    52116  {
    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    }
    55123  }
    56124
     
    63131
    64132  void GLGuiRadar::showing()
    65   {
    66   }
     133  {}
    67134
    68135  void GLGuiRadar::hiding()
    69   {
    70   }
    71 }
     136{}}
Note: See TracChangeset for help on using the changeset viewer.