Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5567 in orxonox.OLD for branches/world_entities/src


Ignore:
Timestamp:
Nov 15, 2005, 2:32:27 AM (19 years ago)
Author:
bensch
Message:

orxonox/branches/world_entities: smoother aiming, and also displaying Distance (this is not too nice, but quite good to explain a few Things …

Location:
branches/world_entities/src/world_entities
Files:
9 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/world_entities/src/world_entities/player.cc

    r5559 r5567  
    341341void Player::ADDWEAPON()
    342342{
    343   Weapon* turret;
     343  Weapon* turret = NULL;
    344344  if ((float)rand()/RAND_MAX < .1)
    345345  {
    346     turret = new Turret(this->weaponMan);
    347     this->weaponMan->addWeapon(turret, 2);
    348     this->weaponMan->changeWeaponConfig(2);
     346    //if (this->weaponMan->hasFreeSlot(2, WTYPE_TURRET))
     347    {
     348      turret = new Turret(this->weaponMan);
     349      this->weaponMan->addWeapon(turret, 2);
     350      this->weaponMan->changeWeaponConfig(2);
     351    }
    349352  }
    350353  else
    351354  {
    352     turret = new AimingTurret(this->weaponMan);
    353     this->weaponMan->addWeapon(turret, 3);
    354 
    355     this->weaponMan->changeWeaponConfig(3);
     355    //if (this->weaponMan->hasFreeSlot(3))
     356    {
     357      turret = new AimingTurret(this->weaponMan);
     358      this->weaponMan->addWeapon(turret, 3);
     359
     360      this->weaponMan->changeWeaponConfig(3);
     361    }
    356362  }
    357363
    358   turret->setName("Turret");
    359   turret->setStateDuration(WS_SHOOTING, (float)rand()/RAND_MAX*.5+.1);
    360 }
     364  if(turret != NULL)
     365  {
     366    turret->setName("Turret");
     367    turret->setStateDuration(WS_SHOOTING, (float)rand()/RAND_MAX*.5+.1);
     368  }
     369}
  • branches/world_entities/src/world_entities/weapons/aim.cc

    r5560 r5567  
    2424#include "material.h"
    2525#include "t_animation.h"
     26#include "text.h"
    2627
    2728#include "world_entity.h"
     
    3334 * standart constructor
    3435 */
    35 Aim::Aim (const TiXmlElement* root)
     36Aim::Aim (PNode* source, const TiXmlElement* root)
    3637{
    3738  this->init();
     39
     40  this->source = source;
    3841
    3942  if (root)
     
    5053  if (this->material)
    5154    delete this->material;
     55
     56  if (this->text != NULL)
     57    delete this->text;
    5258}
    5359
     
    6672  this->setBindNode(this);
    6773  this->material = new Material;
     74  this->source = NULL;
    6875
    6976  this->anim = new tAnimation<Aim>(this, &Aim::setSize);
     
    7380  this->anim->addKeyFrame(50, .01, ANIM_LINEAR);
    7481
    75 }
    76 
     82  this->text = new Text();
     83  this->text->setParent2D(this);
     84  this->text->setRelCoor2D(10, -50);
     85  this->text->setParentMode2D(E2D_PARENT_MOVEMENT);
     86  this->text->setText("Testing");
     87}
    7788
    7889void Aim::loadParams(const TiXmlElement* root)
     
    101112      {
    102113        this->anim->replay();
    103         this->setParent(entity);
     114        this->setParentSoft(entity, 3);
    104115      }
    105116      delete iterator;
     
    141152  this->shiftDir2D(dt * rotationSpeed);
    142153
     154  char outputText[100];
     155  sprintf(outputText, "distance: %f\n", (this->source->getAbsCoor() - this->getAbsCoor()).len());
     156  this->text->setText(outputText);
    143157
    144158//   float z = 0.0f;
  • branches/world_entities/src/world_entities/weapons/aim.h

    r5560 r5567  
    1212// FORWARD DECLARATION
    1313class Model;
     14class Text;
    1415class Material;
    1516class TiXmlElement;
     
    1718
    1819//! An Aim for zooming in on Targets.
     20/**
     21 * An Aim is a PNode, that is connected, to the Target, it has aquired
     22 * The target becomes, if selected its Parent.
     23 *
     24 * Also the Aim is a Element2D, as it draws a cross onto the Target.
     25 */
    1926class Aim : public PNode, public Element2D {
    2027
    2128 public:
    22   Aim(const TiXmlElement* root = NULL);
     29  Aim(PNode* source, const TiXmlElement* root = NULL);
    2330  virtual ~Aim();
    2431
    2532  void init();
    2633  void loadParams(const TiXmlElement* root);
     34
     35  inline void setSource(PNode* source) { this->source = source; };
    2736
    2837  inline void selectTarget(PNode* target) { this->setParent(target); };
     
    4352   float            rotationSpeed;        //!< Speed of the Rotation.
    4453   tAnimation<Aim>* anim;
     54
     55   PNode*           source;               //!< Where this Shot has come from.
     56
     57   Text*            text;                 //!< A Text to display onto this Node. (distance to Target)
    4558};
    4659
  • branches/world_entities/src/world_entities/weapons/aiming_turret.cc

    r5560 r5567  
    101101  //this->getProjectileFactory()->prepare(100);
    102102
    103   this->target = new Aim();
     103  this->target = new Aim(this);
    104104  this->target->setVisibility(false);
    105105}
  • branches/world_entities/src/world_entities/weapons/crosshair.cc

    r5398 r5567  
    7676  GraphicsEngine::showMouse(false);
    7777  GraphicsEngine::stealWMEvents(true);
     78  SDL_WarpMouse(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2);
    7879}
    7980
  • branches/world_entities/src/world_entities/weapons/laser.cc

    r5512 r5567  
    8585    Laser::explosionParticles->setName("LaserExplosionParticles");
    8686    Laser::explosionParticles->setLifeSpan(.5, .3);
    87     Laser::explosionParticles->setRadius(0.0, 3.0);
     87    Laser::explosionParticles->setRadius(0.0, 10.0);
    8888    Laser::explosionParticles->setRadius(.5, 6.0);
    8989    Laser::explosionParticles->setRadius(1.0, 3.0);
  • branches/world_entities/src/world_entities/weapons/laser.h

    r5500 r5567  
    4242
    4343    WorldEntity* hitEntity; // FIXME TEMPORARY
    44 
    4544};
    4645
  • branches/world_entities/src/world_entities/weapons/weapon_manager.cc

    r5527 r5567  
    474474      return i;
    475475  }
     476  printf("SHIT\n");
    476477  return -1;
    477478}
  • branches/world_entities/src/world_entities/weapons/weapon_manager.h

    r5527 r5567  
    7171    void removeWeapon(Weapon* weapon, int configID = -1);
    7272
    73 
     73    // FIXME ::
     74//    bool hasFreeSlot(int configID, long capability = WTYPE_ALL) { return ( getNextFreeSlot(configID, capability ) != -1)? true : false; };
    7475
    7576    void nextWeaponConfig();
Note: See TracChangeset for help on using the changeset viewer.