Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5985 in orxonox.OLD for branches/powerups/src


Ignore:
Timestamp:
Dec 8, 2005, 1:10:27 AM (19 years ago)
Author:
manuel
Message:

merge: factory has now create from class name string function (svn merge -r 5955:HEAD ../trunk/ powerups/)

Location:
branches/powerups/src
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • branches/powerups/src/defs/globals.h

    r5957 r5985  
    7272#define   CONFIG_NAME_PLAYER_LEFT          "Left"
    7373#define   CONFIG_NAME_PLAYER_RIGHT         "Right"
     74#define   CONFIG_NAME_PLAYER_ROLL_RIGHT    "RollR"
     75#define   CONFIG_NAME_PLAYER_ROLL_LEFT     "RollL"
     76
    7477#define   CONFIG_NAME_PLAYER_FIRE          "Fire"
    7578#define   CONFIG_NAME_PLAYER_NEXT_WEAPON   "Next"
  • branches/powerups/src/lib/event/event_handler.cc

    r5786 r5985  
    4747  this->flush(ES_ALL);
    4848  this->withUNICODE(false);
     49  this->grabEvents(false);
    4950
    5051  this->state = ES_GAME;
     
    255256}
    256257
     258void EventHandler::grabEvents(bool grabEvents)
     259{
     260     this->eventsGrabbed = grabEvents;
     261     if(!grabEvents)
     262      SDL_WM_GrabInput(SDL_GRAB_OFF);
     263     else
     264      SDL_WM_GrabInput(SDL_GRAB_ON);
     265}
    257266
    258267/**
  • branches/powerups/src/lib/event/event_handler.h

    r5786 r5985  
    4343
    4444  void withUNICODE(bool enableUNICODE);
     45  void grabEvents(bool grabEvents);
    4546
    4647  void process();
     
    6263
    6364  bool                       bUNICODE;                        //!< If unicode should be enabled.
     65  bool                       eventsGrabbed;                   //!< If the events should be grabbed
    6466};
    6567
  • branches/powerups/src/lib/event/key_mapper.cc

    r5955 r5985  
    3737int KeyMapper::PEV_LEFT              = EV_UNKNOWN;
    3838int KeyMapper::PEV_RIGHT             = EV_UNKNOWN;
     39int KeyMapper::PEV_ROLL_LEFT         = EV_UNKNOWN;
     40int KeyMapper::PEV_ROLL_RIGHT        = EV_UNKNOWN;
    3941int KeyMapper::PEV_STRAFE_LEFT       = EV_UNKNOWN;
    4042int KeyMapper::PEV_STRAFE_RIGHT      = EV_UNKNOWN;
     
    6971  {&KeyMapper::PEV_LEFT,                 CONFIG_NAME_PLAYER_LEFT},
    7072  {&KeyMapper::PEV_RIGHT,                CONFIG_NAME_PLAYER_RIGHT},
     73  {&KeyMapper::PEV_ROLL_LEFT,            CONFIG_NAME_PLAYER_ROLL_RIGHT},
     74  {&KeyMapper::PEV_ROLL_RIGHT,           CONFIG_NAME_PLAYER_ROLL_LEFT},
    7175  {&KeyMapper::PEV_STRAFE_LEFT,          "StrafeLeft"},
    7276  {&KeyMapper::PEV_STRAFE_RIGHT,         "StrafeRight"},
  • branches/powerups/src/lib/event/key_mapper.h

    r5955 r5985  
    4444  static int PEV_RIGHT;             //!< right button
    4545
     46  static int PEV_ROLL_LEFT;         //!< rolls left
     47  static int PEV_ROLL_RIGHT;        //!< rolls right
     48
    4649  static int PEV_STRAFE_LEFT;       //!< strafe left button
    4750  static int PEV_STRAFE_RIGHT;      //!< strafe right button
  • branches/powerups/src/lib/graphics/light.cc

    r5955 r5985  
    274274  while (element != NULL)
    275275  {
    276     Factory::getFirst()->fabricate(element);
     276    Factory::fabricate(element);
    277277
    278278    element = element->NextSiblingElement();
  • branches/powerups/src/lib/gui/gtk_gui/gui_keys.cc

    r5955 r5985  
    115115
    116116        pKeysBox->setGroupName(player);
    117         pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_UP, "UP"));
    118         pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_DOWN, "DOWN"));
    119         pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_LEFT, "LEFT"));
    120         pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_RIGHT, "RIGHT"));
     117        pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_UP, "w"));
     118        pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_DOWN, "s"));
     119        pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_LEFT, "a"));
     120        pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_RIGHT, "d"));
     121        pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_ROLL_LEFT, "q"));
     122        pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_ROLL_RIGHT, "e"));
    121123        pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_FIRE, "BUTTON_LEFT"));
    122124        pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_NEXT_WEAPON, "m"));
  • branches/powerups/src/lib/math/vector.h

    r5692 r5985  
    2121*/
    2222
    23 #ifndef _VECTOR_H
    24 #define _VECTOR_H
     23#ifndef __VECTOR_H_
     24#define __VECTOR_H_
    2525
    2626#include <math.h>
     
    318318
    319319
    320 #endif /* _VECTOR_H */
    321 
     320#endif /* __VECTOR_H_ */
     321
  • branches/powerups/src/lib/physics/physics_engine.cc

    r5955 r5985  
    103103  while (element != NULL)
    104104  {
    105     Factory::getFirst()->fabricate(element);
     105    Factory::fabricate(element);
    106106
    107107    element = element->NextSiblingElement();
     
    119119  while (element != NULL)
    120120  {
    121     Factory::getFirst()->fabricate(element);
     121    Factory::fabricate(element);
    122122
    123123    element = element->NextSiblingElement();
  • branches/powerups/src/lib/sound/sound_engine.cc

    r5965 r5985  
    286286
    287287
    288   }
    289 
     288
     289  }
    290290  // INITIALIZING THE DEVICE:
    291291  ALCchar deviceName[] =
     
    300300  this->context = alcCreateContext(this->device, NULL);
    301301
    302   alcMakeContextCurrent(this->context);
    303 
     302  alcMakeContextCurrent(this->context);
    304303
    305304  if ((result = alGetError()) != AL_NO_ERROR)
  • branches/powerups/src/orxonox.cc

    r5955 r5985  
    9393
    9494  // class-less services/factories
    95   delete Factory::getFirst();
     95  Factory::deleteFactories();
    9696  FastFactory::deleteAll();
    9797  ShellCommandClass::unregisterAllCommands();
  • branches/powerups/src/story_entities/campaign.cc

    r5773 r5985  
    1919#include "campaign.h"
    2020
     21#include "factory.h"
    2122#include "game_loader.h"
    2223#include "story_entity.h"
     
    9091  {
    9192    PRINTF(5)("Campaign: Constructor: adding a world\n");
    92     StoryEntity* created = (StoryEntity*) GameLoader::getInstance()->fabricate(element);
     93    StoryEntity* created = (StoryEntity*) Factory::fabricate(element);
    9394    if( created != NULL)
    9495    {
  • branches/powerups/src/story_entities/world.cc

    r5955 r5985  
    317317      while( element != NULL)
    318318        {
    319           BaseObject* created = (loader->fabricate(element));
     319          BaseObject* created = (Factory::fabricate(element));
    320320          if( created != NULL )
    321321          {
    322322            if(created->isA(CL_WORLD_ENTITY))
    323323              this->spawn(dynamic_cast<WorldEntity*>(created));
    324             printf("Created a %s: %s\n", created->getClassName(), created->getName());
     324            PRINTF(4)("Created a %s: %s\n", created->getClassName(), created->getName());
    325325          }
    326326
  • branches/powerups/src/util/loading/factory.cc

    r5750 r5985  
    1313   co-programmer: Benjamin Grauer
    1414*/
    15 
     15#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_LOADING
    1616
    1717#include "factory.h"
    1818
    19 #include "shell_command.h"
    20 #include "game_loader.h"
     19//#include "shell_command.h"
     20
    2121using namespace std;
    2222
    23 SHELL_COMMAND(create, Factory, fabricate);
     23//SHELL_COMMAND(create, Factory, fabricate);
    2424
    2525
     
    3939  this->setName(factoryName);
    4040
    41   this->next = NULL;
    4241  this->classID = classID;
     42  this->className = factoryName;
    4343
    44   Factory::registerFactory(this);
     44  if( Factory::factoryList == NULL)
     45    Factory::factoryList = new std::list<Factory*>;
     46
     47  Factory::factoryList->push_back(this);
    4548}
    4649
    4750/** a reference to the First Factory */
    48 Factory* Factory::first = NULL;
     51std::list<Factory*>* Factory::factoryList = NULL;
    4952
    5053/**
    5154 *  destructor
    52 
    53    clear the Q
    54 */
     55 *
     56 * clear the Q
     57 */
    5558Factory::~Factory ()
    5659{
     
    5861  //  Factory* tmpDel = this->next;
    5962  //  this->next = NULL;
    60   if (this->next)
    61     delete this->next;
    6263}
    6364
     65void Factory::deleteFactories()
     66{
     67  if (Factory::factoryList != NULL)
     68  {
     69    while(!Factory::factoryList->empty())
     70    {
     71      delete Factory::factoryList->front();
     72      Factory::factoryList->pop_front();
     73    }
     74    delete Factory::factoryList;
     75    Factory::factoryList = NULL;
     76  }
     77}
     78
     79
    6480/**
    65  *  add a Factory to the Factory Queue
    66  * @param factory a Factory to be registered
    67 */
    68 void Factory::registerFactory( Factory* factory)
     81 * Compares the Factories Name against a given ClassName
     82 * @param className the Name of the Class to Query
     83 * @returns true on match, false otherwise.
     84 */
     85bool Factory::operator==(const char* className) const
    6986{
    70   assert( factory != NULL);
     87  return(className != NULL && !strcmp(className, this->className));
     88}
    7189
    72   PRINTF(5)("Registered factory for '%s'\n", factory->getName());
    7390
    74   if( Factory::first == NULL)
     91BaseObject* Factory::fabricate(const TiXmlElement* root)
     92{
     93  if (root == NULL || Factory::factoryList == NULL)
     94    return NULL;
     95
     96  std::list<Factory*>::const_iterator factory;
     97  for (factory = Factory::factoryList->begin(); factory != Factory::factoryList->end(); factory++)
     98    if (*(*factory) == root->Value())
     99      break;
     100
     101  if (factory != Factory::factoryList->end())
    75102  {
    76     Factory::first = factory;
     103    PRINTF(4)("Create a new Object of type %s\n", (*factory)->getName());
     104    return (*factory)->fabricateObject(root);
    77105  }
    78106  else
    79107  {
    80     Factory* tmpFac = Factory::first;
    81     while( tmpFac->next != NULL)
    82     {
    83       tmpFac = tmpFac->next;
    84     }
    85     tmpFac->setNext(factory);
     108    PRINTF(2)("Could not Fabricate an Object of Class '%s'\n", root->Value());
     109    return NULL;
    86110  }
    87111}
    88112
    89 void Factory::fabricate(const char* className, const char* entityName)
     113BaseObject* Factory::fabricate(const char* className)
    90114{
    91   if (className == NULL)
    92     return;
    93   Factory* fac = Factory::first;
     115  if (className == NULL || Factory::factoryList == NULL)
     116    return NULL;
    94117
    95   while (fac != NULL)
     118  std::list<Factory*>::const_iterator factory;
     119  for (factory = Factory::factoryList->begin(); factory != Factory::factoryList->end(); factory++)
     120    if (*(*factory) == className)
     121      break;
     122
     123  if (factory != Factory::factoryList->end())
    96124  {
    97     if (!strcmp(className, fac->getName()))
    98     {
    99       PRINTF(3)("Create a new Object of type %s\n", fac->getName());
    100       BaseObject* object = fac->fabricateDirect();
    101       if (object != NULL)
    102       {
    103         object->setName(entityName);
    104       }
    105       break;
    106     }
    107     fac = fac->next;
     125    PRINTF(4)("Create a new Object of type %s\n", (*factory)->getName());
     126    return (*factory)->fabricateObject(NULL);
     127  }
     128  else
     129  {
     130    PRINTF(2)("Could not Fabricate an Object of Class '%s'\n", className);
     131    return NULL;
    108132  }
    109133}
     134
     135
     136BaseObject* Factory::fabricate(ClassID classID)
     137{
     138  if (Factory::factoryList == NULL)
     139    return NULL;
     140
     141  std::list<Factory*>::const_iterator factory;
     142  for (factory = Factory::factoryList->begin(); factory != Factory::factoryList->end(); factory++)
     143    if (*(*factory) == classID)
     144      break;
     145
     146  if (factory != Factory::factoryList->end())
     147  {
     148    PRINTF(4)("Create a new Object of type %s\n", (*factory)->getName());
     149    return (*factory)->fabricateObject(NULL);
     150  }
     151  else
     152  {
     153    PRINTF(2)("Could not Fabricate an Object of ClassID '%h'\n", classID);
     154    return NULL;
     155  }
     156}
  • branches/powerups/src/util/loading/factory.h

    r5955 r5985  
    2828#include "base_object.h"
    2929#include "debug.h"
     30#include <vector>
    3031
    3132/**
     
    4041
    4142 public:
    42   Factory (const char* factoryName = NULL, ClassID classID = CL_NULL);
     43  Factory (const char* factoryName, ClassID classID);
    4344  virtual ~Factory ();
    4445
    45   void fabricate(const char* className, const char* entityName);
    46   virtual BaseObject* fabricate(ClassID classID) = NULL;
    47   virtual BaseObject* fabricate(const TiXmlElement* root) = NULL;
    48   virtual BaseObject* fabricateDirect() = NULL;
     46  static void deleteFactories();
    4947
    50   static void registerFactory( Factory* factory);
    51   /** @returns the first factory */
    52   static Factory* getFirst() { return Factory::first; };
     48  static  BaseObject* fabricate(const char* className);
     49  static  BaseObject* fabricate(ClassID classID);
     50  static  BaseObject* fabricate(const TiXmlElement* root = NULL);
     51
     52  bool operator==(ClassID classID) const { return (this->classID == classID); };
     53  bool operator==(const char* className) const;
    5354
    5455  protected:
    55     /** sets the Next factory in the list @param nextFactory the next factory */
    56     inline void setNext( Factory* nextFactory) { this->next = nextFactory; };
    57     /** @returns the next factory */
    58     Factory* getNext() const { return this->next; };
    59 
     56    virtual BaseObject* fabricateObject(const TiXmlElement* root = NULL) const = 0;
    6057
    6158  protected:
    62     ClassID           classID;              //!< The CLass-Identifyer of the Factory.
    63 
    64   private:
    65     Factory*          next;                 //!< pointer to the next factory.
    66     static Factory*   first;                //!< A pointer to the first factory.
     59    ClassID                       classID;              //!< The Class-Identifyer of the Factory.
     60    const char*                   className;            //!< The name of the Class.
     61    static std::list<Factory*>*   factoryList;          //!< List of Registered Factories
    6762};
    6863
     
    7368template<class T> class tFactory : public Factory
    7469{
    75   public:
    76     tFactory(const char* factoryName, ClassID classID);
    77     virtual ~tFactory();
     70 public:
     71  tFactory (const char* factoryName, ClassID classID)
     72   : Factory(factoryName, classID)
     73  {
     74  }
    7875
    7976  private:
    80     virtual BaseObject* fabricate(ClassID classID);
    81     virtual BaseObject* fabricate(const TiXmlElement* root);
    82     virtual BaseObject* fabricateDirect();
     77   /**
     78    * fabricates an Object of type T, with the constructor T::T(const TiXmlElemnt*)
     79    * @param root the TiXmlElement T should load parameters from.
     80    * @return the newly fabricated T.
     81    */
     82    virtual BaseObject* fabricateObject(const TiXmlElement* root = NULL) const
     83    {
     84      return new T(root);
     85    }
    8386};
    84 
    85 /**
    86  *  construnts a factory with
    87  * @param factoryName the name of the factory
    88 */
    89 template<class T>
    90     tFactory<T>::tFactory(const char* factoryName, ClassID classID) : Factory(factoryName, classID)
    91 {
    92   PRINTF(4)("Class: %s loadable\n", this->getName());
    93 }
    94 
    95 /**
    96  * destructs the type-Factory
    97  */
    98 template<class T>
    99     tFactory<T>::~tFactory()
    100 {}
    101 
    102 /**
    103  * fabricates an Object of type T, with the constructor T::T(const TiXmlElemnt*)
    104  * @param root the TiXmlElement T should load parameters from.
    105  * @return the newly fabricated T, NULL otherwise.
    106  */
    107 template<class T>
    108     BaseObject* tFactory<T>::fabricate(const TiXmlElement* root)
    109 {
    110   if (root == NULL)
    111     return NULL;
    112 
    113   if(!strcmp(root->Value(), this->getName()))
    114     return new T ( root);
    115   else if( getNext() != NULL)
    116     return getNext()->fabricate( root);
    117   else
    118     return NULL;
    119 }
    120 
    121 
    122 /**
    123  * fabricates an Object of type T, with the constructor T::T(const TiXmlElemnt*)
    124  * @param classID the ClassID of T that should be created.
    125  * @return the newly fabricated T if fabricated NULL otherwise.
    126  */
    127 template<class T>
    128     BaseObject* tFactory<T>::fabricate(ClassID classID)
    129 {
    130   if(classID == this->classID)
    131     return this->fabricateDirect();
    132   else if( getNext() != NULL)
    133     return getNext()->fabricate( classID);
    134   else
    135     return NULL;
    136 }
    137 
    138 /**
    139  * directly fabricate an Entity of this factory.
    140  */
    141 template<class T>
    142     BaseObject* tFactory<T>::fabricateDirect()
    143 {
    144   return new T((const TiXmlElement*)NULL);
    145 }
    14687
    14788#endif /* _FACTORY_H */
  • branches/powerups/src/util/loading/game_loader.cc

    r5819 r5985  
    331331    this->currentCampaign->previousLevel();
    332332}
    333 
    334 /**
    335  *  load a StoryEntity
    336  * @param element a XMLElement containing all the needed info
    337 */
    338 BaseObject* GameLoader::fabricate(const TiXmlElement* element)
    339 {
    340   assert( element != NULL);
    341 
    342   if( Factory::getFirst() == NULL)
    343     {
    344       PRINTF(1)("GameLoader does not know any factories, fabricate() failed\n");
    345       return NULL;
    346     }
    347 
    348   if( element->Value() != NULL)
    349     {
    350       PRINTF(4)("Attempting fabrication of a '%s'\n", element->Value());
    351       BaseObject* b = Factory::getFirst()->fabricate( element);
    352       if( b == NULL)
    353         PRINTF(2)("Failed to fabricate a '%s'\n", element->Value());
    354       else
    355         PRINTF(4)("Successfully fabricated a '%s'\n", element->Value());
    356       return b;
    357     }
    358 
    359   PRINTF(2)("Fabricate failed, TiElement did not contain a value\n");
    360 
    361   return NULL;
    362 }
  • branches/powerups/src/util/loading/game_loader.h

    r5819 r5985  
    6060  ErrorMessage loadDebugCampaign(Uint32 campaignID);
    6161
    62   void registerFactory( Factory* factory );
    63   BaseObject* fabricate(const TiXmlElement* data);
    64 
    6562  void process(const Event &event);
    6663
  • branches/powerups/src/world_entities/extendable.h

    r5965 r5985  
    1212class PowerUp;
    1313
     14#include "power_ups/power_up.h"
    1415
    1516//! A class for ...
     
    1920//   Extendable();
    2021//   virtual ~Extendable();
    21   virtual bool pickup(PowerUp* powerUp) { return false; }
     22   virtual bool pickup(PowerUp* powerUp) { return false; };
    2223
    2324 private:
  • branches/powerups/src/world_entities/player.h

    r5955 r5985  
    88
    99#include "event_listener.h"
     10#include "extendable.h"
    1011
    1112/* Forward Declaration */
     
    1819     the player.cc for debug also
    1920*/
     21
    2022class Player : public EventListener
    2123{
  • branches/powerups/src/world_entities/space_ships/space_ship.cc

    r5973 r5985  
    3131#include "factory.h"
    3232#include "key_mapper.h"
     33#include "event_handler.h"
    3334
    3435#include "power_ups/weapon_power_up.h"
     36
     37#include "graphics_engine.h"
    3538
    3639using namespace std;
     
    8891  Weapon* wpLeft = new TestGun(1);
    8992  wpLeft->setName("testGun Left");
    90   Weapon* cannon = dynamic_cast<Weapon*>(Factory::getFirst()->fabricate(CL_CANNON));
     93  Weapon* cannon = dynamic_cast<Weapon*>(Factory::fabricate(CL_CANNON));
    9194
    9295  cannon->setName("BFG");
     
    112115  PRINTF(4)("SPACESHIP INIT\n");
    113116
    114 
    115   bUp = bDown = bLeft = bRight = bAscend = bDescend = false;
     117  EventHandler::getInstance()->grabEvents(true);
     118
     119  bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false;
    116120  bFire = false;
     121  xMouse = yMouse = 0;
     122  mouseSensitivity = 0.001;
     123
     124  cycle = 0.0;
     125
    117126
    118127  travelSpeed = 15.0;
     
    126135
    127136  //add events to the eventlist
    128   registerEvent(KeyMapper::PEV_UP);
    129   registerEvent(KeyMapper::PEV_DOWN);
    130   registerEvent(KeyMapper::PEV_LEFT);
    131   registerEvent(KeyMapper::PEV_RIGHT);
     137  registerEvent(SDLK_w);
     138  registerEvent(SDLK_s);
     139  registerEvent(SDLK_a);
     140  registerEvent(SDLK_d);
     141  registerEvent(SDLK_q);
     142  registerEvent(SDLK_e);
    132143  registerEvent(KeyMapper::PEV_FIRE1);
    133144  registerEvent(KeyMapper::PEV_NEXT_WEAPON);
     
    135146  registerEvent(SDLK_PAGEUP);
    136147  registerEvent(SDLK_PAGEDOWN);
     148  registerEvent(EV_MOUSE_MOTION);
    137149
    138150  this->getWeaponManager()->setSlotCount(7);
     
    255267void SpaceShip::tick (float time)
    256268{
     269     cycle += time;
    257270  // spaceship controlled movement
    258271  this->calculateVelocity(time);
     
    261274
    262275  //orient the spaceship model in the direction of movement.
     276
     277  // this is the air friction (necessary for a smooth control)
     278  if(velocity.len() != 0) velocity -= velocity*0.01;
     279
     280  this->shiftCoor(Vector(0,1,0)*cos(this->cycle*2.0)*0.02);
     281
     282  //SDL_WarpMouse(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2);
    263283
    264284  this->shiftCoor (move);
     
    283303  if( this->bUp )
    284304   {
    285      this->shiftCoor(this->getAbsDirX());
    286       //if(travelSpeed <= 5000)  travelSpeed += 10;
     305     //this->shiftCoor(this->getAbsDirX());
     306      accel += (this->getAbsDirX())*2;
    287307   }
    288308
    289309  if( this->bDown )
    290310   {
    291      this->shiftCoor(Vector()-this->getAbsDirX());
    292      //if(travelSpeed >= 10) travelSpeed -= 10;
     311     //this->shiftCoor((this->getAbsDirX())*-1);
     312     accel -= (this->getAbsDirX())*2;
    293313   }
    294314
     
    310330    //rotVal += .4;
    311331  }
     332
     333  if( this->bRollL /* > -this->getRelCoor().z*2*/)
     334  {
     335    this->shiftDir(Quaternion(-time, Vector(1,0,0)));
     336//    accel -= rightDirection;
     337    //velocityDir.normalize();
     338    //rot +=Vector(1,0,0);
     339    //rotVal -= .4;
     340  }
     341  if( this->bRollR /* > this->getRelCoor().z*2*/)
     342  {
     343    this->shiftDir(Quaternion(time, Vector(1,0,0)));
     344
     345    //    accel += rightDirection;
     346    //velocityDir.normalize();
     347    //rot += Vector(1,0,0);
     348    //rotVal += .4;
     349  }
    312350  if (this->bAscend )
    313351  {
     
    329367  }
    330368
    331   velocity += accel*(time);
     369  velocity += accel;
    332370  //rot.normalize();
    333371  //this->setRelDirSoft(Quaternion(rotVal, rot), 5);
     
    350388void SpaceShip::process(const Event &event)
    351389{
    352   if( event.type == KeyMapper::PEV_UP)
    353       this->bUp = event.bPressed;
    354   else if( event.type == KeyMapper::PEV_DOWN)
    355       this->bDown = event.bPressed;
    356   else if( event.type == KeyMapper::PEV_RIGHT)
    357       this->bRight= event.bPressed;
    358   else if( event.type == KeyMapper::PEV_LEFT)
    359       this->bLeft = event.bPressed;
     390
     391
     392  if( event.type == SDLK_a)
     393      this->bRollL = event.bPressed;
     394  else if( event.type == SDLK_d)
     395      this->bRollR = event.bPressed;
    360396  else if( event.type == KeyMapper::PEV_FIRE1)
    361397      this->bFire = event.bPressed;
     
    365401    this->getWeaponManager()->previousWeaponConfig();
    366402
    367   else if( event.type == SDLK_PAGEUP)
    368     this->bAscend = event.bPressed; //this->shiftCoor(0,.1,0);
    369   else if( event.type == SDLK_PAGEDOWN)
    370     this->bDescend = event.bPressed; //this->shiftCoor(0,-.1,0);
     403  else if( event.type == SDLK_w)
     404    this->bUp = event.bPressed; //this->shiftCoor(0,.1,0);
     405  else if( event.type == SDLK_s)
     406    this->bDown = event.bPressed; //this->shiftCoor(0,-.1,0);
     407  else if( event.type == EV_MOUSE_MOTION)
     408  {
     409    this->xMouse = event.xRel;
     410    this->yMouse = event.yRel;
     411    this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1)));
     412  }
    371413}
    372414
  • branches/powerups/src/world_entities/space_ships/space_ship.h

    r5965 r5985  
    5858    bool                  bDescend;           //!< descend button presses.
    5959    bool                  bFire;              //!< fire button pressed.
     60    bool                  bRollL;             //!< rolling button pressed (left)
     61    bool                  bRollR;             //!< rolling button pressed (right)
     62   
     63    float                 xMouse;             //!< mouse moved in x-Direction
     64    float                 yMouse;             //!< mouse moved in y-Direction
     65    float                 mouseSensitivity;   //!< the mouse sensitivity
     66    float                 cycle;              //!< hovercycle
    6067
    6168    Vector                velocity;           //!< the velocity of the player.
  • branches/powerups/src/world_entities/weapons/crosshair.cc

    r5750 r5985  
    7070  this->material = new Material;
    7171
    72   EventHandler::getInstance()->subscribe(this, ES_GAME, EV_MOUSE_MOTION);
     72  //EventHandler::getInstance()->subscribe(this, ES_GAME, EV_MOUSE_MOTION);
    7373
    7474  // center the mouse on the screen, and also hide the cursors
     
    122122  if  (event.type == EV_MOUSE_MOTION)
    123123  {
    124     this->setAbsCoor2D(event.x, event.y);
     124    //this->setAbsCoor2D(event.x, event.y);
    125125  }
    126126}
     
    157157               &objZ );
    158158
    159   this->setAbsCoor(objX, objY, objZ);
     159  //this->setAbsCoor(objX, objY, objZ);
    160160}
    161161
     
    166166{
    167167  glPushMatrix();
    168   glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0);
     168  glTranslatef(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2, 0);
    169169
    170170  glRotatef(this->getAbsDir2D(), 0,0,1);
  • branches/powerups/src/world_entities/weapons/ground_turret.cc

    r5955 r5985  
    8585  element = root->FirstChildElement("weapon-left");
    8686  if (element != NULL) element = element->FirstChildElement();
    87   this->left = dynamic_cast<Weapon*>( Factory::getFirst()->fabricate( element) );
     87  this->left = dynamic_cast<Weapon*>( Factory::fabricate( element) );
    8888  if (this->left)
    8989  {
     
    9494  element = root->FirstChildElement("weapon-right");
    9595  if (element != NULL)  if (element != NULL) element = element->FirstChildElement();
    96   this->right = dynamic_cast<Weapon*>( Factory::getFirst()->fabricate( element) );
     96  this->right = dynamic_cast<Weapon*>( Factory::fabricate( element) );
    9797  if (this->right)
    9898  {
  • branches/powerups/src/world_entities/weapons/weapon_manager.cc

    r5965 r5985  
    140140  LOAD_PARAM_START_CYCLE(root, element);
    141141
    142   Weapon* newWeapon = dynamic_cast<Weapon*>(Factory::getFirst()->fabricate(element));
     142  Weapon* newWeapon = dynamic_cast<Weapon*>(Factory::fabricate(element));
    143143  /// @todo implement this !!
    144144
Note: See TracChangeset for help on using the changeset viewer.