Changeset 2096 in orxonox.OLD for orxonox/branches/chris/src/player.cc
- Timestamp:
- Jul 9, 2004, 11:14:42 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/chris/src/player.cc
r2058 r2096 13 13 ### File Specific: 14 14 main-programmer: Patrick Boenzli 15 co-programmer: 15 co-programmer: Christian Meyer 16 16 */ 17 17 … … 20 20 #include <GL/glut.h> 21 21 22 #include "shoot_laser.h"23 #include "shoot_rocket.h"24 #include "data_tank.h"25 26 22 #include "player.h" 27 23 … … 29 25 30 26 31 Player::Player() 32 : WorldEntity() { 33 //cout << "Player::Player" << endl; 34 xCor = yCor = zCor = 0; 35 shootLaser = new ShootLaser; 36 shootRocket = new ShootRocket; 27 Player::Player(bool isFree) : WorldEntity(isFree) 28 { 37 29 } 38 30 39 31 Player::~Player () 40 32 { 41 //delete shootLaser;42 33 } 43 34 44 45 void Player::setPosition( float x, float y, float z) 35 void Player::post_spawn () 46 36 { 47 xCor = x; yCor = y; zCor = z; 37 travel_speed = 1.0; 38 velocity = Vector(); 39 bUp = bDown = bLeft = bRight = bAscend = bDescend = false; 40 bFire = false; 41 acceleration = 10.0; 42 set_collision (new CollisionCluster (1.0, Vector(0,0,0)); 48 43 } 49 44 50 51 void Player::getPosition(float* x, float* y, float* z) 45 void Player::tick (float time) 52 46 { 53 *x = xCor; *y = yCor; *z = zCor; 47 // movement 48 move (float time); 54 49 } 55 50 56 57 void Player::setCollisionRadius(float radius) 51 void Player::hit (WorldEntity* weapon, Vector loc) 58 52 { 59 collisionRadius = radius;60 53 } 61 54 62 63 void Player::goX(float x) 55 void Player::destroy () 64 56 { 65 xCor += x;66 57 } 67 58 68 69 void Player::goY(float y) 59 void Player::collide (WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags) 70 60 { 71 yCor += y;72 61 } 73 62 74 void Player:: goZ(float z)63 void Player::command (Command* cmd) 75 64 { 76 zCor += z; 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; 77 70 } 78 71 79 80 81 void Player::shoot(int n) 72 void Player::draw () 82 73 { 83 84 // if (shootLaser->inhibitor++ <= 100)85 shootLaser->addShoot(xCor, yCor, zCor);86 // else if (shootLaser->inhibitor++ <= 200)87 shootLaser->addShootExt(xCor, yCor, zCor, .1, .4, .0);88 // else if (shootLaser->inhibitor++ <= 300)89 shootLaser->addShootExt(xCor, yCor, zCor, -0.1, .4, .0);90 // else91 shootLaser->inhibitor =0;92 93 // if (shootRocket->inhibitor++ >=80)94 {95 shootRocket->addBackParable(xCor, yCor, zCor);96 shootRocket->addSideAcc(xCor, yCor, zCor, RIGHT);97 shootRocket->addSideAcc(xCor, yCor, zCor, LEFT);98 shootRocket->addRotater(xCor, yCor, zCor);99 // if (shootRocket->inhibitor >=90)100 // shootRocket->inhibitor =0;101 }102 //cout << "Player::shoot" << endl;103 104 /*105 shootLaser->addShoot(xCor, yCor, zCor);106 shootLaser->addShootExt(xCor, yCor, zCor, .1, .4, .0);107 shootLaser->addShootExt(xCor, yCor, zCor, -0.1, .4, .0);108 //shootRocket->addShoot(xCor, yCor, zCor);109 //cout << "Player::shoot" << endl;110 */111 74 } 112 75 76 void Player::get_lookat (Location* locbuf) 77 { 78 *locbuf = *get_location(); 79 locbuf->dist += 5.0; 80 } 113 81 114 //void Player::addIO(InputOutput *io) {} 82 void Player::left_world () 83 { 84 } 115 85 116 117 void Player::paint() 86 void Player::move (float time) 118 87 { 119 //cout << "Player::drawPlayer" << endl; 120 glPushMatrix(); 121 glTranslatef(xCor, yCor, 3.0); 122 glScalef(1.0, 3.0, 1.0); 123 glutWireCube(1.0); 124 glPopMatrix(); 125 /* draw all the shoots additionaly */ 126 shootLaser->drawShoot(); 127 shootRocket->drawShoot(); 128 //cout << "Player::drawPlayer, end" << endl; 88 float xAccel, yAccel, zAccel; 89 xAccel = yAccel = zAccel = 0; 90 if( bUp) xAccel += acceleration; 91 if( bDown) xAccel -= acceleration; 92 if( bLeft) yAccel += acceleration; 93 if( bRight) yAccel -= acceleration; 94 if( bAscend) zAccel += acceleration; 95 if( bDescend) zAccel -= acceleration; 96 97 Vector accel( xAccel, yAccel, zAccel); 98 99 Location* l = get_location(); 100 101 // r(t) = r(0) + v(0)*t + 1/2*a*t^2 102 // r = position 103 // v = velocity 104 // a = acceleration 105 106 l->pos = l->pos + velocity*time + (accel*(0.5*t*t))); 107 l->dist += travel_speed * time; 108 109 velocity += accel * time; 129 110 } 130 111 … … 146 127 147 128 148 149 150 151 152 153 154 155
Note: See TracChangeset
for help on using the changeset viewer.