Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5556 in orxonox.OLD for trunk/src/world_entities/weapons


Ignore:
Timestamp:
Nov 13, 2005, 2:49:48 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: added Aim-class

Location:
trunk/src/world_entities/weapons
Files:
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/weapons/aim.cc

    r5554 r5556  
    1616#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
    1717
    18 #include "crosshair.h"
    19 #include "event_handler.h"
     18#include "aim.h"
    2019
    2120#include "load_param.h"
     
    3130 * standart constructor
    3231 */
    33 Crosshair::Crosshair (const TiXmlElement* root)
     32Aim::Aim (const TiXmlElement* root)
    3433{
    3534  this->init();
     
    4241
    4342/**
    44  * destroys a Crosshair
     43 * destroys a Aim
    4544*/
    46 Crosshair::~Crosshair ()
     45Aim::~Aim ()
    4746{
    4847  if (this->material)
     
    5655
    5756/**
    58  * initializes the Crosshair
     57 * initializes the Aim
    5958 */
    60 void Crosshair::init()
     59void Aim::init()
    6160{
    62   this->setClassID(CL_CROSSHAIR, "Crosshair");
    63   this->setName("Crosshair");
     61  this->setClassID(CL_CROSSHAIR, "Aim");
     62  this->setName("Aim");
    6463
    6564  this->setLayer(E2D_LAYER_TOP);
     
    7069  this->material = new Material;
    7170
    72   EventHandler::getInstance()->subscribe(this, ES_GAME, EV_MOUSE_MOTION);
    73 
    7471  // center the mouse on the screen, and also hide the cursors
    7572  SDL_WarpMouse(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2);
     
    7976
    8077
    81 void Crosshair::loadParams(const TiXmlElement* root)
     78void Aim::loadParams(const TiXmlElement* root)
    8279{
    8380  static_cast<PNode*>(this)->loadParams(root);
    84   static_cast<EventListener*>(this)->loadParams(root);
    8581
    86   LoadParam<Crosshair>(root, "texture", this, &Crosshair::setTexture)
    87       .describe("the texture-file to load onto the Crosshair");
     82  LoadParam<Aim>(root, "texture", this, &Aim::setTexture)
     83      .describe("the texture-file to load onto the Aim");
    8884
    89   LoadParam<Crosshair>(root, "size", this, &Crosshair::setSize)
    90       .describe("the size of the Crosshair in Pixels");
     85  LoadParam<Aim>(root, "size", this, &Aim::setSize)
     86      .describe("the size of the Aim in Pixels");
    9187
    92   LoadParam<Crosshair>(root, "rotation-speed", this, &Crosshair::setRotationSpeed)
    93       .describe("the Speed with which the Crosshair should rotate");
     88  LoadParam<Aim>(root, "rotation-speed", this, &Aim::setRotationSpeed)
     89      .describe("the Speed with which the Aim should rotate");
    9490}
    9591
    9692
    9793/**
    98  * sets the size of the Crosshair.
     94 * sets the size of the Aim.
    9995 * @param size the size in pixels
    10096 */
    101 void Crosshair::setSize(float size)
     97void Aim::setSize(float size)
    10298{
    10399  this->setSize2D(size/2, size/2);
     
    108104 * @param textureFile The texture-file to load onto the crosshair
    109105 */
    110 void Crosshair::setTexture(const char* textureFile)
     106void Aim::setTexture(const char* textureFile)
    111107{
    112108  this->material->setDiffuseMap(textureFile);
     
    114110
    115111/**
    116  * processes the input
    117  * @param event the Event coming as input
    118  */
    119 void Crosshair::process(const Event &event)
    120 {
    121   if  (event.type == EV_MOUSE_MOTION)
    122   {
    123     this->setAbsCoor2D(event.x, event.y);
    124   }
    125 }
    126 
    127 /**
    128  * ticks the Crosshair
     112 * ticks the Aim
    129113 * @param dt the time to ticks
    130114 */
    131 void Crosshair::tick(float dt)
     115void Aim::tick(float dt)
    132116{
    133117  // let the crosshair rotate
     
    162146 * draws the crosshair
    163147 */
    164 void Crosshair::draw() const
     148void Aim::draw() const
    165149{
    166150  glPushMatrix();
  • trunk/src/world_entities/weapons/aim.h

    r5554 r5556  
    11/*!
    2  * @file crosshair.h
    3   *  Definition of ...
     2 * @file aim.h
     3 *  Definition of
     4 */
    45
    5 */
    6 
    7 #ifndef _CROSSHAIR_H
    8 #define _CROSSHAIR_H
     6#ifndef _AIM_H
     7#define _AIM_H
    98
    109#include "p_node.h"
    1110#include "element_2d.h"
    12 #include "event_listener.h"
    13 
    14 #include "vector.h"
    15 
    16 
    1711// FORWARD DECLARATION
    1812class Model;
     
    2014class TiXmlElement;
    2115
    22 //! A class that enables the
    23 class Crosshair : public PNode, public Element2D, public EventListener {
     16//! An Aim for zooming in on Targets.
     17class Aim : public PNode, public Element2D {
    2418
    2519 public:
    26   Crosshair(const TiXmlElement* root = NULL);
    27   virtual ~Crosshair();
     20  Aim(const TiXmlElement* root = NULL);
     21  virtual ~Aim();
    2822
    2923  void init();
     
    3529  void setRotationSpeed(float rotationSpeed) { this->rotationSpeed = rotationSpeed; };
    3630
    37   virtual void process(const Event &event);
    3831  virtual void tick(float dt);
    3932  virtual void draw() const;
     
    4437};
    4538
    46 #endif /* _CROSSHAIR_H */
     39#endif /* _AIM_H */
Note: See TracChangeset for help on using the changeset viewer.