Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 5, 2007, 2:41:14 PM (17 years ago)
Author:
mbiber
Message:

fixed a bug and adapted constants

Location:
code/branches/steering/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/steering/src/orxonox.cc

    r317 r391  
    8585  : mKeyboard(keyboard), mMouse(mouse)
    8686    {
    87       speed = 250;
    88       loop = 100;
     87      speed = 2500;
    8988      rotate = 10;
     89      loop = 400;
    9090      mouseX = 0;
    9191      mouseY = 0;
     
    9393      minMouseX = 0;
    9494      moved = false;
    95       steering->brakeRotate(rotate*10);
     95      steering->brakeRotate(rotate*5);
    9696      steering->brakeLoop(loop);
    9797      mMouse->setEventCallback(this);
     
    117117      else
    118118        steering->loopLeft(0);
    119 
     119/*
    120120      if(moved) {
    121121        if (mouseY<0)
     
    130130      }
    131131      else {
    132         steering->rotateUp(0);
    133         steering->rotateDown(0);
    134         steering->rotateRight(0);
    135         steering->rotateLeft(0);
    136       }
    137 
    138       steering->tick(evt.timeSinceLastFrame);
    139 //      scenemanager->spacehip->tick(evt.timesincelastframe);
    140       if(mKeyboard->isKeyDown(OIS::KC_ESCAPE))
    141         cout << "maximal MouseX: " << maxMouseX << "\tminMouseX: " << minMouseX << endl;
    142       return !mKeyboard->isKeyDown(OIS::KC_ESCAPE);
    143     }
    144 
    145     bool mouseMoved(const OIS::MouseEvent &e)
    146     {
    147       mouseX = e.state.X.rel;
    148       mouseY = e.state.Y.rel;
    149       if(mouseX>maxMouseX) maxMouseX = mouseX;
    150       if(mouseX<minMouseX) minMouseX = mouseX;
    151       cout << "mouseX: " << mouseX << "\tmouseY: " << mouseY << endl;
    152       moved = true;
    153       return true;
    154     }
     132*/
     133        if(moved) {
     134          if (mouseY<0)
     135            steering->rotateUp(-mouseY*rotate);
     136          if (mouseY>0)
     137            steering->rotateDown(mouseY*rotate);
     138          if (mouseX>0)
     139            steering->rotateRight(mouseX*rotate);
     140          if (mouseX<0)
     141            steering->rotateLeft(-mouseX*rotate);
     142          moved = false;
     143        }
     144        else {
     145          steering->rotateUp(0);
     146          steering->rotateDown(0);
     147          steering->rotateRight(0);
     148          steering->rotateLeft(0);
     149        }
     150
     151        steering->tick(evt.timeSinceLastFrame);
     152        //      scenemanager->spacehip->tick(evt.timesincelastframe);
     153        if(mKeyboard->isKeyDown(OIS::KC_ESCAPE))
     154          cout << "maximal MouseX: " << maxMouseX << "\tminMouseX: " << minMouseX << endl;
     155        return !mKeyboard->isKeyDown(OIS::KC_ESCAPE);
     156        }
     157
     158        bool mouseMoved(const OIS::MouseEvent &e)
     159        {
     160          mouseX = e.state.X.rel;
     161          mouseY = e.state.Y.rel;
     162          if(mouseX>maxMouseX) maxMouseX = mouseX;
     163          if(mouseX<minMouseX) minMouseX = mouseX;
     164          cout << "mouseX: " << mouseX << "\tmouseY: " << mouseY << endl;
     165          moved = true;
     166          return true;
     167}
    155168
    156169    bool mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id) { return true; }
     
    303316      node5->attachObject(head5);
    304317
    305       steering = new SpaceshipSteering(500, 200, 200, 200);
     318      steering = new SpaceshipSteering(5000, 50, 50, 150);
    306319      steering->addNode(node);
    307320
  • code/branches/steering/src/spaceship_steering.cc

    r317 r391  
    6767    if(speedRotateUpDown_ < 0)
    6868      speedRotateUpDown_ += accelerationRotateUpDown_*time;
     69    if(abs(speedRotateUpDown_)<accelerationRotateUpDown_*time)
     70      speedRotateUpDown_ = 0;
    6971  }
    7072
     
    8991    if(speedRotateRightLeft_ < 0)
    9092      speedRotateRightLeft_ += accelerationRotateRightLeft_*time;
     93    if(abs(speedRotateRightLeft_)<accelerationRotateRightLeft_*time)
     94      speedRotateRightLeft_ = 0;
    9195  }
    9296
     
    111115    if(speedLoopRightLeft_ < 0)
    112116      speedLoopRightLeft_ += accelerationLoopRightLeft_*time;
     117    if(abs(speedLoopRightLeft_)<accelerationLoopRightLeft_*time)
     118      speedLoopRightLeft_ = 0;
    113119  }
    114120
Note: See TracChangeset for help on using the changeset viewer.