Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 209 for code


Ignore:
Timestamp:
Nov 14, 2007, 3:38:28 PM (17 years ago)
Author:
mbiber
Message:

added steering class

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

Legend:

Unmodified
Added
Removed
  • code/branches/steering/src/CMakeLists.txt

    r164 r209  
    33# create a few variables to simplify life
    44
    5 SET(SRC_FILES orxonox.cc loader/LevelLoader.cc xml/xmlParser.cc)
    6 SET(INC_FILES loader/LevelLoader.h xml/xmlParser.h)
     5SET(SRC_FILES orxonox.cc loader/LevelLoader.cc xml/xmlParser.cc spaceship_steering.cc)
     6SET(INC_FILES loader/LevelLoader.h xml/xmlParser.h spaceship_steering.h )
    77
    88#Creates an executable
  • code/branches/steering/src/orxonox.cc

    r164 r209  
    4141#include "xml/xmlParser.h"
    4242#include "loader/LevelLoader.h"
     43
     44#include "spaceship_steering.h"
     45SpaceshipSteering* steering;
    4346
    4447
     
    8689    bool frameStarted(const FrameEvent& evt)
    8790    {
     91      float speed = 1;
     92      float rotate = 1;
    8893      mKeyboard->capture();
     94      if (mKeyboard->isKeyDown(OIS::KC_SPACE))
     95        steering->moveForward(speed);
     96      else
     97        steering->moveForward(0);
     98      if(mKeyboard->isKeyDown(OIS::KC_C))
     99        steering->brake(speed);
     100      else
     101        steering->brake(0.1);
     102      if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W))
     103        steering->rotateUp(rotate);
     104      else
     105        steering->rotateUp(0);
     106      if (mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S))
     107        steering->rotateDown(rotate);
     108      else
     109        steering->rotateDown(0);
     110      if (mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D))
     111        steering->rotateRight(rotate);
     112      else
     113        steering->rotateRight(0);
     114      if (mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A))
     115        steering->rotateLeft(rotate);
     116      else
     117        steering->rotateLeft(0);
     118      if (mKeyboard->isKeyDown(OIS::KC_E))
     119        steering->loopRight(rotate);
     120      else
     121        steering->loopRight(0);
     122      if (mKeyboard->isKeyDown(OIS::KC_Q))
     123        steering->loopLeft(rotate);
     124      else
     125        steering->loopLeft(0);
     126      steering->tick(evt.timeSinceLastFrame);
     127//      scenemanager->spacehip->tick(evt.timesincelastframe);
    89128      return !mKeyboard->isKeyDown(OIS::KC_ESCAPE);
    90129    }
     
    199238      SceneManager *mgr = mRoot->createSceneManager(ST_GENERIC, "Default SceneManager");
    200239      Camera *cam = mgr->createCamera("Camera");
     240      cam->setPosition(Vector3(0,0,-250));
     241      cam->lookAt(Vector3(0,0,0));
    201242      Viewport *vp = mRoot->getAutoCreatedWindow()->addViewport(cam);
     243
     244
     245      mgr->setAmbientLight(ColourValue(1,1,1));
     246      Entity* head = mgr->createEntity("head", "ogrehead.mesh");
     247      SceneNode *node = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode", Vector3(0,0,0));
     248      node->attachObject(head);
     249      node->attachObject(cam);
     250      mgr->setSkyBox(true, "Examples/SceneSkyBox2");
     251
     252      Entity* head1 = mgr->createEntity("head1", "ogrehead.mesh");
     253      SceneNode *node1 = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode1", Vector3(200,0,0));
     254      node1->attachObject(head1);
     255      Entity* head2 = mgr->createEntity("head2", "ogrehead.mesh");
     256      SceneNode *node2 = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode2", Vector3(200,400,-100));
     257      node2->attachObject(head2);
     258      Entity* head3 = mgr->createEntity("head3", "ogrehead.mesh");
     259      SceneNode *node3 = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode3", Vector3(0,400,200));
     260      node3->attachObject(head3);
     261      Entity* head4 = mgr->createEntity("head4", "ogrehead.mesh");
     262      SceneNode *node4 = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode4", Vector3(-400,-200,600));
     263      node4->attachObject(head4);
     264      Entity* head5 = mgr->createEntity("head5", "ogrehead.mesh");
     265      SceneNode *node5 = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode5", Vector3(0,0,-400));
     266      node5->attachObject(head5);
     267
     268      steering = new SpaceshipSteering(500, 200, 200, 200);
     269      steering->addNode(node);
     270
    202271    }
    203272
     
    240309    {
    241310      mListener = new OrxExitListener(mKeyboard);
    242       mRoot->addFrameListener(mListener);
     311      mRoot->addFrameListener(mListener);     
    243312    }
    244313
Note: See TracChangeset for help on using the changeset viewer.