Advertisement
purxiz

update_bullets

May 9th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. void MyViewer::update_bullets() {
  2.     int i = 0;
  3.     bullet_list = bullet::getList();
  4.     for (std::vector<bullet *>::iterator it = bullet_list.begin(); it != bullet_list.end(); ) {
  5.         for (std::vector<collision *>::iterator it_b = buildings.begin(); it_b != buildings.end(); ++it_b) {
  6.             if ((*it_b)->contains((*it)->getPos(), 0.05f)) {
  7.                 (*it)->setAge(1500000);
  8.             }
  9.         }
  10.         if ((*it)->getAge() > 150) {
  11.             bullet_group->remove(i + 1);
  12.             it = bullet_list.erase(it);
  13.         }
  14.         else {
  15.             (*it)->update();
  16.             ++it;
  17.         }
  18.         ++i;
  19.     }
  20.     bullet::setList(bullet_list);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement