SimpleCircleFacingVisualizer::SimpleCircleFacingVisualizer(
   Ogre::SceneManager* manager,
   Ogre::SceneNode* parent,
   rviz::DisplayContext* context,
   double size,
   std::string text):
   FacingObject(manager, parent, size)
 {
   line_ = new rviz::BillboardLine(
     context->getSceneManager(),
     node_);
   text_under_line_ = new rviz::BillboardLine(
     context->getSceneManager(),
     node_);
   target_text_node_ = node_->createChildSceneNode();
   msg_ = new rviz::MovableText("not initialized", "Arial", 0.05);
   msg_->setVisible(false);
   msg_->setTextAlignment(rviz::MovableText::H_LEFT,
                          rviz::MovableText::V_ABOVE);
   target_text_node_->attachObject(msg_);
   createArrows(context);
   updateLine();
   updateTextUnderLine();
   updateText();
   setEnable(false);
 }
Exemplo n.º 2
0
HoldLine::HoldLine(QWidget *parent) : QWidget(parent){
  XLOC = 36;
  level = 0;
  points = 0;
  gameOver = false;
  gameWon = false;
  paused = false;
  gameStarted = false;
  moving = false;
  prot = new Protagonist();
  quiver = new Quiver();
  trapBag = new TrapBag();
  protect = new Protect();
  protectItem = new ProtectItem();

  ammoList.push_back(quiver);
  ammoList.push_back(trapBag);

  
  MAXENEMIES = 10;
  createBullets(3);
  createArrows(8);
  createTraps(5);
  createTrees(4);

}
Exemplo n.º 3
0
/**
 * Constructor.
 * @param model
 * @param rect
 */
MenuView::MenuView(Model *model, const SDL_Rect &rect) : RectangleView(model, rect) {
    setCursorIndex(0);
    setVisibleOptionCount(0);
    setWindowTopIndex(0);
    setOptionFontSize(0);
    createArrows();
    cursorTextColor = 0;
}
Exemplo n.º 4
0
void HoldLine::checkCollision(){
   for(int i = 0; i < enemyList.size(); i++){
      if(!(enemyList[i]->isDestroyed())){
         if((prot->getRect()).intersects(enemyList[i]->getRect())){
            enemyList[i]->setDestroyed(true);
            enemyList[i]->resetState();
            
            if(protect->isDestroyed()){
                prot->resetState();
                prot->damage();
                points += 100;
            } 

            enemyCount++;
            if(enemyCount == MAXENEMIES) stopGame();
            if(prot->getLives() == 0)
               stopGame();
            break;
         }//end if
      }//end if
   }//end for

   for(int i = 0; i < enemyList.size(); i++){
      if(!(enemyList[i]->isDestroyed())){
          if(!protect->isDestroyed()){
            if((protect->getRect()).intersects(enemyList[i]->getRect())){
                enemyList[i]->setDestroyed(true);
                 enemyList[i]->resetState();
                 enemyCount++;
                 points += 100;
                 if(enemyCount == MAXENEMIES) stopGame();
                 break;
            }//end if
          }
      }//end if
   }//end for

  for(int i = 0; i < arrowList.size(); i++){
     if(!(arrowList[i]->isDestroyed())){
        for(int j = 0; j < enemyList.size(); j++){
            if(!(enemyList[j]->isDestroyed())){
               if((arrowList[i]->getRect()).intersects(enemyList[j]->getRect())){
                 numRand = rand() % 100;
                 if(numRand < 10 && protectItem->isDestroyed() && protect->isDestroyed()){
                    protectItem->resetState(enemyList[j]->getRect().left(),enemyList[j]->getRect().top());
                    protectItem->setDestroyed(false);
                    timeridItem = startTimer(5000);
                 }
                 arrowList[i]->setDestroyed(true);
                 enemyList[j]->setDestroyed(true);
                 enemyList[j]->resetState();
                 enemyCount++;
                 points += 100;
                 if(enemyCount == MAXENEMIES) stopGame();
                 break;
              }//end if
            }//end if
        }//end for
     }//end if
  }//end for  

  for(int i = 0; i < ammoList.size(); i++){
      if((prot->getRect()).intersects(ammoList[i]->getRect())){
          Ammunition *a;
          a = dynamic_cast <Quiver*> (ammoList[i]);

          if(a != NULL){
            createArrows(8);
            remainingArrows = 8;
            break;
          }

          else{
           createTraps(5);
           remainingTraps = 5;
           break;
          }
     }
  }
  
  if(!protectItem->isDestroyed()){
     if((prot->getRect()).intersects(protectItem->getRect())){
        protectItem->setDestroyed(true);
        killTimer(timeridItem);
        protect->setDestroyed(false);
        protect->resetState(prot->getRect().right(),prot->getRect().top());
        timeridInvincible = startTimer(4000);
     }
  }

  for(int i = 0; i< trapList.size();i++){
     if(!trapList[i]->isDestroyed()){
        if((prot->getRect()).intersects(trapList[i]->getRect())){

            if(protect->isDestroyed()){
                prot->resetState();
                prot->damage();
            } 

            trapList[i]->setDestroyed(true);
            if(prot->getLives() == 0)
               stopGame();
            break;
        }//end if
     }//end if
  }//end for


    for(int i = 0; i< bulletList.size();i++){
     if(!bulletList[i]->isDestroyed()){
        if((prot->getRect()).intersects(bulletList[i]->getRect())){

            if(protect->isDestroyed()){
                prot->resetState();
                prot->damage();
            } 

            bulletList[i]->setDestroyed(true);
            if(prot->getLives() == 0)
               stopGame();
            break;
        }//end if
     }//end if
  }//end for


  for(int i = 0; i < trapList.size(); i++){
     if(!(trapList[i]->isDestroyed())){
        for(int j = 0; j < enemyList.size(); j++){
            if(!(enemyList[j]->isDestroyed())){
               if((trapList[i]->getRect()).intersects(enemyList[j]->getRect())){

                 numRand = rand() % 100;
                 if(numRand < 20 && protectItem->isDestroyed() && protect->isDestroyed()){
                    protectItem->resetState(enemyList[j]->getRect().left(),enemyList[j]->getRect().top());
                    protectItem->setDestroyed(false);
                    timeridItem = startTimer(5000);
                 }

                 trapList[i]->setDestroyed(true);
                 enemyList[j]->setDestroyed(true);
                 enemyList[j]->resetState();
                 enemyCount++;
                 points += 100;

                 if(enemyCount == MAXENEMIES) stopGame();
                 break;
              }//end if
            }//end if
        }//end for
     }//end if
  }//end for

  for(int i = 0; i < arrowList.size(); i++){
     if(!(arrowList[i]->isDestroyed())){
        for(int j = 0; j < treeList.size(); j++){
               if((arrowList[i]->getRect()).intersects(treeList[j]->getRect())){
                 arrowList[i]->setDestroyed(true);
                 break;
              }//end if
        }//end for
     }//end if
  }//end for

}
Exemplo n.º 5
0
void HoldLine::startGame(){
  if(!gameStarted) { 
     prot->resetState();
     arrowCount = 0;
     remainingArrows = 8;
     trapCount = 0;
     remainingTraps = 5;
     enemyCount = 0;
     crossedLine = 0;
     prot->setHealth();
     level++;

     if(level == 1){
          createEnemies(MAXENEMIES);

         for(int i = 0; i < arrowList.size(); i++)
            arrowList[i]->setDestroyed(true);

         for(int i = 0; i < trapList.size(); i++)
            trapList[i]->setDestroyed(true);

         for(int i = 0; i < bulletList.size(); i++)
            bulletList[i]->setDestroyed(true); 

         protectItem->setDestroyed(true);
         protect->setDestroyed(true);

     }

     else if(level == 2){
         for(int i = 0; i < enemyList.size(); i++){
             enemyList[i]->setDestroyed(false);
             enemyList[i]->setDir(0,3);
             enemyList[i]->resetState();
         }
         createEnemies(13);
 
         MAXENEMIES += 13;

         deleteArrows();
         arrowList.resize(0);
         createArrows(8);

         deleteTraps();
         trapList.resize(0);
         createTraps(5);


         for(int i = 0; i < arrowList.size(); i++)
            arrowList[i]->setDestroyed(true);

         for(int i = 0; i < trapList.size(); i++)
            trapList[i]->setDestroyed(true);

         for(int i = 0; i < bulletList.size(); i++)
            bulletList[i]->setDestroyed(true); 

         protectItem->setDestroyed(true);
         protect->setDestroyed(true);
     }//end level 2

     else if(level == 3){
         EnemyObject* f;

         for(int i = 0; i < enemyList.size(); i++){
             enemyList[i]->setDestroyed(false);
             f = dynamic_cast <Enemy*> (enemyList[i]);

             if(f != NULL)
                 enemyList[i]->setDir(0,3);

             enemyList[i]->resetState();
         }

         createEnemies(12);

         MAXENEMIES += 12;

         deleteArrows();
         arrowList.resize(0);
         createArrows(8);

         deleteTraps();
         trapList.resize(0);
         createTraps(5);

         for(int i = 0; i < arrowList.size(); i++)
            arrowList[i]->setDestroyed(true);

         for(int i = 0; i < trapList.size(); i++)
            trapList[i]->setDestroyed(true);

         protectItem->setDestroyed(true);
         protect->setDestroyed(true);
     }//end level 3
     

     startTimers();

     gameOver = false;
     gameWon = false;
     gameStarted = true;
  }
}
Exemplo n.º 6
0
void HoldLine::timerEvent(QTimerEvent *event){
   if(event->timerId() == timeridProt){
      if(!protect->isDestroyed()){
          if(XLOC == 38) protect->setPositive(true);
          else if(XLOC == -38) protect->setPositive(false);

          if(protect->getPositive()) XLOC -= 2;
          else if(!protect->getPositive()) XLOC+=2;
    
          protect->calculatePosition(prot->getRect().left(),prot->getRect().top()+10, XLOC);
          protect->move();
          checkCollision();
      }

      if(moving){
         prot->move();
         checkCollision();
      }

   }

   if(event->timerId() == timeridShoot){
      EnemyObject* a;
      int indexBullet = 0;

      if(bulletList[0]->isDestroyed()){
          for(int i = 0; i < enemyList.size(); i++){
              a = dynamic_cast <Enemy2*> (enemyList[i]);

              if(a != NULL && !enemyList[i]->isDestroyed()){
                 bulletList[indexBullet]->setDestroyed(false);
                 bulletList[indexBullet]->resetState(enemyList[i]->getRect().left(),enemyList[i]->getRect().top());
                 bulletList[indexBullet]->setlastLocation(enemyList[i]->getRect().left(),enemyList[i]->getRect().top());
                 bulletList[indexBullet]->determineDirection(prot->getRect().left(),prot->getRect().top());
                 indexBullet++;
              }
          }
      }
   } 

   if(event->timerId() == timeridShoot2){
      EnemyObject *g;
      int indexBullet = 3;

      if(bulletList[3]->isDestroyed()){
          for(int i = 0; i < enemyList.size(); i++){
	      g = dynamic_cast <Enemy3*> (enemyList[i]);

              if(g != NULL && !enemyList[i]->isDestroyed()){
                 bulletList[indexBullet]->setDestroyed(false);
                 bulletList[indexBullet]->resetState(enemyList[i]->getRect().left(),enemyList[i]->getRect().top());
                 indexBullet++;
              }
           }
       }
    }

   if(event->timerId() == timeridskBullet){
      EnemyBullet* c;

      for(int i = 0; i < bulletList.size(); i++){
          c = dynamic_cast <SeekerBullet*> (bulletList[i]);

          if(c != NULL){
              bulletList[i]->setlastLocation(bulletList[i]->getRect().left(),bulletList[i]->getRect().top());
              bulletList[i]->determineDirection(prot->getRect().left(),prot->getRect().top());
              bulletList[i]->move();
          }
      }

   }

   if(event->timerId() == timeridDisappear){
      EnemyObject* d;

      for(int i = 0; i < enemyList.size(); i++){
              d = dynamic_cast <Enemy3*> (enemyList[i]);

              if(d != NULL){
                  enemyList[i]->resetState();
              }
      }

   }


   if(event->timerId() == timeridEnemy){
     for(int i = 0; i < enemyList.size(); i++)
        enemyList[i]->move();
     checkCollision(); 
     checkCrossLine();
   }

   if(event->timerId() == timeridArrow){
     for(int i = 0; i < arrowList.size(); i++)
        arrowList[i]->move();
     checkCollision();

     for(int i = 0; i < arrowList.size(); i++){
         if(!arrowList[i]->isDestroyed())
            break;

         if(i == arrowList.size()-1){
             if(arrowList.size() != 8){
                deleteArrows();
                arrowList.resize(0);
                createArrows(8);
                arrowCount = 0;
             }
         }
     }
   }

   if(event->timerId() == timeridItem){
       protectItem->setDestroyed(true);
       killTimer(timeridItem);
   }

   if(event->timerId() == timeridInvincible){
      protect->setDestroyed(true);
      killTimer(timeridInvincible);
   }

  if(event->timerId() == timeridBullet){
      EnemyBullet* e;

      for(int i = 0; i < bulletList.size(); i++){

         e = dynamic_cast <Bullet*> (bulletList[i]);

         if(e != NULL)
            bulletList[i]->move();
      }
   }

   if(event->timerId() == timeridAnimation)
       repaint();
}