Changeset 3238 in orxonox.OLD for orxonox/branches/sound/src/player.cc
- Timestamp:
- Dec 20, 2004, 2:42:54 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/sound/src/player.cc
r2640 r3238 25 25 Player::Player(bool isFree) : WorldEntity(isFree) 26 26 { 27 }28 27 29 Player::~Player () 28 this->obj = new Object("reaplow.obj"); 29 /* 30 objectList = glGenLists(1); 31 glNewList (objectList, GL_COMPILE); 30 32 31 {32 }33 34 void Player::post_spawn ()35 {36 travel_speed = 15.0;37 velocity = Vector();38 bUp = bDown = bLeft = bRight = bAscend = bDescend = false;39 bFire = false;40 acceleration = 10.0;41 set_collision (new CollisionCluster (1.0, Vector(0,0,0)));42 }43 44 void Player::tick (float time)45 {46 // movement47 move (time);48 }49 50 void Player::hit (WorldEntity* weapon, Vector loc)51 {52 }53 54 void Player::destroy ()55 {56 }57 58 void Player::collide (WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags)59 {60 }61 62 void Player::command (Command* cmd)63 {64 //printf("Player|recieved command [%s]\n", cmd->cmd);65 if( !strcmp( cmd->cmd, "up")) bUp = !cmd->bUp;66 else if( !strcmp( cmd->cmd, "down")) bDown = !cmd->bUp;67 else if( !strcmp( cmd->cmd, "left")) bLeft = !cmd->bUp;68 else if( !strcmp( cmd->cmd, "right")) bRight = !cmd->bUp;69 else if( !strcmp( cmd->cmd, "fire")) bFire = !cmd->bUp;70 }71 72 void Player::draw ()73 {74 glMatrixMode(GL_MODELVIEW);75 glLoadIdentity();76 float matrix[4][4];77 78 glTranslatef(get_placement()->r.x,get_placement()->r.y,get_placement()->r.z);79 get_placement()->w.matrix (matrix);80 glMultMatrixf ((float*)matrix);81 82 33 glBegin(GL_TRIANGLES); 83 34 glColor3f(1,1,1); … … 99 50 glEnd(); 100 51 101 //printf("Player@%f/%f/%f\n", get_placement()->r.x, get_placement()->r.y, get_placement()->r.z); 52 glEndList (); 53 */ 102 54 } 103 55 104 void Player::get_lookat (Location* locbuf)56 Player::~Player() 105 57 { 106 *locbuf = *get_location(); 107 //locbuf->dist += 5.0; 58 delete this->obj; 108 59 } 109 60 110 void Player::left_world () 61 void Player::postSpawn() 62 { 63 travelSpeed = 15.0; 64 velocity = Vector(); 65 bUp = bDown = bLeft = bRight = bAscend = bDescend = false; 66 bFire = false; 67 acceleration = 10.0; 68 setCollision(new CollisionCluster(1.0, Vector(0,0,0))); 69 } 70 71 void Player::tick(float time) 72 { 73 // movement 74 move (time); 75 } 76 77 void Player::hit(WorldEntity* weapon, Vector loc) 111 78 { 112 79 } 113 80 114 void Player::move (float time) 81 void Player::destroy() 82 { 83 } 84 85 void Player::collide(WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags) 86 { 87 } 88 89 void Player::command(Command* cmd) 90 { 91 //printf("Player|recieved command [%s]\n", cmd->cmd); 92 if( !strcmp( cmd->cmd, "up")) bUp = !cmd->bUp; 93 else if( !strcmp( cmd->cmd, "down")) bDown = !cmd->bUp; 94 else if( !strcmp( cmd->cmd, "left")) bLeft = !cmd->bUp; 95 else if( !strcmp( cmd->cmd, "right")) bRight = !cmd->bUp; 96 else if( !strcmp( cmd->cmd, "fire")) bFire = !cmd->bUp; 97 } 98 99 void Player::draw() 100 { 101 glMatrixMode(GL_MODELVIEW); 102 glLoadIdentity(); 103 float matrix[4][4]; 104 105 glTranslatef(getPlacement()->r.x, getPlacement()->r.y, getPlacement()->r.z); 106 getPlacement()->w.matrix (matrix); 107 glMultMatrixf((float*)matrix); 108 109 glMatrixMode(GL_MODELVIEW); 110 glRotatef(-90, 0,1,0); 111 obj->draw(); 112 // glCallList(objectList); 113 114 115 116 } 117 118 void Player::getLookat(Location* locbuf) 119 { 120 *locbuf = *getLocation(); 121 //locbuf->dist += 5.0; 122 } 123 124 void Player::leftWorld() 125 { 126 } 127 128 void Player::move(float time) 115 129 { 116 130 Vector accel(0.0, 0.0, 0.0); 117 /* FIXME: calculating the direction and orthDirection every time _slice is redundant! save it somewhere */118 Placement *pos = get _placement();131 /* FIXME: calculating the direction and orthDirection every timeSlice is redundant! save it somewhere */ 132 Placement *pos = getPlacement(); 119 133 /* calculate the direction in which the craft is heading */ 120 134 Vector direction(0.0, 0.0, 1.0); … … 128 142 if( bRight ) { accel = accel - (orthDirection*acceleration); } 129 143 if( bAscend ) { /* not yet implemented but just: (0,0,1)*acceleration */} 130 if( bDescend) {/* FIXME */} 144 if( bDescend) {/* FIXME */} /* \todo up and down player movement */ 131 145 132 Location* l = get _location();146 Location* l = getLocation(); 133 147 134 148 // r(t) = r(0) + v(0)*t + 1/2*a*t^2 … … 138 152 139 153 /* this the base-speed of the player: determines how fast and how the player follows the track*/ 140 l->dist = l->dist + travel _speed * time;154 l->dist = l->dist + travelSpeed * time; 141 155 142 156 /* this updates the player position on the track - user interaction */ 143 157 l->pos = l->pos + accel*time; 144 158 } 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
Note: See TracChangeset
for help on using the changeset viewer.