Changeset 4423 in orxonox.OLD for orxonox/trunk/src/lib
- Timestamp:
- May 31, 2005, 7:10:01 PM (20 years ago)
- Location:
- orxonox/trunk/src/lib/coord
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/coord/pilot_node.cc
r4422 r4423 19 19 #include "pilot_node.h" 20 20 #include "command_node.h" 21 #include "event_handler.h" 21 22 #include "event.h" 22 23 … … 33 34 this->setClassID(CL_PILOT_PARENT, "PilotNode"); 34 35 35 36 travelSpeed = 60.0; 37 velocity = new Vector(); 38 bUp = bDown = bLeft = bRight = false; 36 39 } 37 40 … … 48 51 49 52 50 void PilotNode:: command(Command* cmd)53 void PilotNode::tick(float time) 51 54 { 52 53 54 //this->setAbsDir(Quaternion(M_PI * 0.4, Vector(1, 0, 0))); 55 this->move(time); 55 56 } 56 57 57 58 59 /** 60 \brief action if player moves 61 \param time the timeslice since the last frame 62 */ 63 void PilotNode::move (float time) 64 { 65 Vector accel(0.0, 0.0, 0.0); 66 /* FIXME: calculating the direction and orthDirection every timeSlice is redundant! save it somewhere */ 67 /* calculate the direction in which the craft is heading */ 68 Vector direction (1.0, 0.0, 0.0); 69 //direction = this->absDirection.apply (direction); 70 Vector orthDirection (0.0, 0.0, 1.0); 71 //orthDirection = orthDirection.cross (direction); 72 73 if( this->bUp) 74 accel = accel+(direction*acceleration); 75 if( this->bDown) 76 accel = accel -(direction*acceleration); 77 if( this->bLeft) 78 accel = accel - (orthDirection*acceleration); 79 if( this->bRight) 80 accel = accel + (orthDirection*acceleration); 81 82 Vector move = accel * time; 83 this->shiftCoor (move); 84 } 85 58 86 void PilotNode::process( const Event &event) 59 87 { 60 PRINTF(0)("Mouse moved by %d,%d to (%d,%d)\n", event.xRel, event.yRel, 61 event.x, event.y); 88 if( event.type == KeyMapper::PEV_UP) 89 { 90 this->bUp = event.bPressed; 91 } 92 else if( event.type == KeyMapper::PEV_DOWN) 93 { 94 this->bDown = event.bPressed; 95 } 96 else if( event.type == KeyMapper::PEV_RIGHT) 97 { 98 this->bRight= event.bPressed; 99 } 100 else if( event.type == KeyMapper::PEV_LEFT) 101 { 102 this->bLeft = event.bPressed; 103 } 104 else if( event.type == EV_MOUSE_MOTION) 105 { 106 PRINTF(0)("Mouse moved by %d,%d to (%d,%d)\n", event.xRel, event.yRel, 107 event.x, event.y); 108 } 62 109 } -
orxonox/trunk/src/lib/coord/pilot_node.h
r4418 r4423 9 9 10 10 #include "comincl.h" 11 #include " p_node.h"11 #include "world_entity.h" 12 12 #include "event_listener.h" 13 13 14 14 class Event; 15 15 16 class PilotNode : public PNode, public EventListener {16 class PilotNode : public WorldEntity, public EventListener { 17 17 18 18 public: 19 19 PilotNode (); 20 20 virtual ~PilotNode (); 21 22 void command(Command* cmd);21 22 void tick(float time); 23 23 24 24 void process(const Event &event); 25 26 private: 27 void move(float time); 28 29 private: 30 bool bUp; //!< up button pressed. 31 bool bDown; //!< down button pressed. 32 bool bLeft; //!< left button pressed. 33 bool bRight; //!< right button pressed. 34 35 Vector* velocity; //!< the velocity of the player. 36 float travelSpeed; //!< the current speed of the player (to make soft movement) 37 float acceleration; //!< the acceleration of the player. 38 25 39 26 40 };
Note: See TracChangeset
for help on using the changeset viewer.