Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5978 in orxonox.OLD for trunk


Ignore:
Timestamp:
Dec 7, 2005, 5:51:54 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk:
merged spaceshipcontrol back to the trunk
merged with command:
svn merge -r5915:HEAD spaceshipcontrol/ ../trunk/
no conflicts (nice work guys :)

Location:
trunk/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/defs/globals.h

    r5956 r5978  
    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"
  • trunk/src/lib/event/event_handler.cc

    r5786 r5978  
    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/**
  • trunk/src/lib/event/event_handler.h

    r5786 r5978  
    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
  • trunk/src/lib/event/key_mapper.cc

    r5944 r5978  
    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"},
  • trunk/src/lib/event/key_mapper.h

    r5915 r5978  
    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
  • trunk/src/lib/gui/gtk_gui/gui_keys.cc

    r5945 r5978  
    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"));
  • trunk/src/world_entities/space_ships/space_ship.cc

    r5915 r5978  
    3030#include "factory.h"
    3131#include "key_mapper.h"
     32#include "event_handler.h"
     33
     34#include "graphics_engine.h"
    3235
    3336using namespace std;
     
    109112  PRINTF(4)("SPACESHIP INIT\n");
    110113
    111 
    112   bUp = bDown = bLeft = bRight = bAscend = bDescend = false;
     114  EventHandler::getInstance()->grabEvents(true);
     115
     116  bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false;
    113117  bFire = false;
     118  xMouse = yMouse = 0;
     119  mouseSensitivity = 0.001;
     120 
     121  cycle = 0.0;
     122 
    114123
    115124  travelSpeed = 15.0;
     
    123132
    124133  //add events to the eventlist
    125   registerEvent(KeyMapper::PEV_UP);
    126   registerEvent(KeyMapper::PEV_DOWN);
    127   registerEvent(KeyMapper::PEV_LEFT);
    128   registerEvent(KeyMapper::PEV_RIGHT);
     134  registerEvent(SDLK_w);
     135  registerEvent(SDLK_s);
     136  registerEvent(SDLK_a);
     137  registerEvent(SDLK_d);
     138  registerEvent(SDLK_q);
     139  registerEvent(SDLK_e);
    129140  registerEvent(KeyMapper::PEV_FIRE1);
    130141  registerEvent(KeyMapper::PEV_NEXT_WEAPON);
     
    132143  registerEvent(SDLK_PAGEUP);
    133144  registerEvent(SDLK_PAGEDOWN);
     145  registerEvent(EV_MOUSE_MOTION);
    134146
    135147  this->getWeaponManager()->setSlotCount(7);
     
    252264void SpaceShip::tick (float time)
    253265{
     266     cycle += time;
    254267  // spaceship controlled movement
    255268  this->calculateVelocity(time);
     
    258271
    259272  //orient the spaceship model in the direction of movement.
     273 
     274  // this is the air friction (necessary for a smooth control)
     275  if(velocity.len() != 0) velocity -= velocity*0.01;
     276 
     277  this->shiftCoor(Vector(0,1,0)*cos(this->cycle*2.0)*0.02);
     278 
     279  //SDL_WarpMouse(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2);
    260280
    261281  this->shiftCoor (move);
     
    280300  if( this->bUp )
    281301   {
    282      this->shiftCoor(this->getAbsDirX());
    283       //if(travelSpeed <= 5000)  travelSpeed += 10;
     302     //this->shiftCoor(this->getAbsDirX());
     303      accel += (this->getAbsDirX())*2;
    284304   }
    285305
    286306  if( this->bDown )
    287307   {
    288      this->shiftCoor(Vector()-this->getAbsDirX());
    289      //if(travelSpeed >= 10) travelSpeed -= 10;
     308     //this->shiftCoor((this->getAbsDirX())*-1);
     309     accel -= (this->getAbsDirX())*2;
    290310   }
    291311
     
    307327    //rotVal += .4;
    308328  }
     329 
     330  if( this->bRollL /* > -this->getRelCoor().z*2*/)
     331  {
     332    this->shiftDir(Quaternion(-time, Vector(1,0,0)));
     333//    accel -= rightDirection;
     334    //velocityDir.normalize();
     335    //rot +=Vector(1,0,0);
     336    //rotVal -= .4;
     337  }
     338  if( this->bRollR /* > this->getRelCoor().z*2*/)
     339  {
     340    this->shiftDir(Quaternion(time, Vector(1,0,0)));
     341
     342    //    accel += rightDirection;
     343    //velocityDir.normalize();
     344    //rot += Vector(1,0,0);
     345    //rotVal += .4;
     346  }
    309347  if (this->bAscend )
    310348  {
     
    326364  }
    327365
    328   velocity += accel*(time);
     366  velocity += accel;
    329367  //rot.normalize();
    330368  //this->setRelDirSoft(Quaternion(rotVal, rot), 5);
     
    347385void SpaceShip::process(const Event &event)
    348386{
    349   if( event.type == KeyMapper::PEV_UP)
    350       this->bUp = event.bPressed;
    351   else if( event.type == KeyMapper::PEV_DOWN)
    352       this->bDown = event.bPressed;
    353   else if( event.type == KeyMapper::PEV_RIGHT)
    354       this->bRight= event.bPressed;
    355   else if( event.type == KeyMapper::PEV_LEFT)
    356       this->bLeft = event.bPressed;
     387 
     388 
     389  if( event.type == SDLK_a)
     390      this->bRollL = event.bPressed;
     391  else if( event.type == SDLK_d)
     392      this->bRollR = event.bPressed;
    357393  else if( event.type == KeyMapper::PEV_FIRE1)
    358394      this->bFire = event.bPressed;
     
    362398    this->getWeaponManager()->previousWeaponConfig();
    363399
    364   else if( event.type == SDLK_PAGEUP)
    365     this->bAscend = event.bPressed; //this->shiftCoor(0,.1,0);
    366   else if( event.type == SDLK_PAGEDOWN)
    367     this->bDescend = event.bPressed; //this->shiftCoor(0,-.1,0);
     400  else if( event.type == SDLK_w)
     401    this->bUp = event.bPressed; //this->shiftCoor(0,.1,0);
     402  else if( event.type == SDLK_s)
     403    this->bDown = event.bPressed; //this->shiftCoor(0,-.1,0);
     404  else if( event.type == EV_MOUSE_MOTION)
     405  {
     406    this->xMouse = event.xRel;
     407    this->yMouse = event.yRel;
     408    this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1)));
     409  }
    368410}
    369411
  • trunk/src/world_entities/space_ships/space_ship.h

    r5915 r5978  
    5555    bool                  bDescend;           //!< descend button presses.
    5656    bool                  bFire;              //!< fire button pressed.
     57    bool                  bRollL;             //!< rolling button pressed (left)
     58    bool                  bRollR;             //!< rolling button pressed (right)
     59   
     60    float                 xMouse;             //!< mouse moved in x-Direction
     61    float                 yMouse;             //!< mouse moved in y-Direction
     62    float                 mouseSensitivity;   //!< the mouse sensitivity
     63    float                 cycle;              //!< hovercycle
    5764
    5865    Vector                velocity;           //!< the velocity of the player.
  • trunk/src/world_entities/weapons/crosshair.cc

    r5750 r5978  
    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);
Note: See TracChangeset for help on using the changeset viewer.