[1853] | 1 | |
---|
| 2 | |
---|
| 3 | /* |
---|
| 4 | orxonox - the future of 3D-vertical-scrollers |
---|
| 5 | |
---|
| 6 | Copyright (C) 2004 orx |
---|
| 7 | |
---|
| 8 | This program is free software; you can redistribute it and/or modify |
---|
| 9 | it under the terms of the GNU General Public License as published by |
---|
| 10 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 11 | any later version. |
---|
[1872] | 12 | |
---|
| 13 | ### File Specific: |
---|
| 14 | main-programmer: Patrick Boenzli |
---|
| 15 | co-programmer: |
---|
[1853] | 16 | */ |
---|
| 17 | |
---|
[1858] | 18 | #include <iostream> |
---|
[1920] | 19 | #include <stdlib.h> |
---|
[2036] | 20 | #include <GL/glut.h> |
---|
[1853] | 21 | |
---|
[2036] | 22 | #include "shoot_laser.h" |
---|
| 23 | #include "shoot_rocket.h" |
---|
| 24 | #include "data_tank.h" |
---|
[1896] | 25 | |
---|
[2036] | 26 | #include "player.h" |
---|
| 27 | |
---|
[1856] | 28 | using namespace std; |
---|
[1853] | 29 | |
---|
| 30 | |
---|
[2036] | 31 | Player::Player() |
---|
| 32 | : WorldEntity() { |
---|
| 33 | //cout << "Player::Player" << endl; |
---|
[1872] | 34 | xCor = yCor = zCor = 0; |
---|
[1896] | 35 | shootLaser = new ShootLaser; |
---|
[1920] | 36 | shootRocket = new ShootRocket; |
---|
[1872] | 37 | } |
---|
[1853] | 38 | |
---|
[1896] | 39 | Player::~Player () |
---|
| 40 | { |
---|
| 41 | //delete shootLaser; |
---|
| 42 | } |
---|
[1853] | 43 | |
---|
| 44 | |
---|
[1879] | 45 | void Player::setPosition( float x, float y, float z) |
---|
[1858] | 46 | { |
---|
| 47 | xCor = x; yCor = y; zCor = z; |
---|
| 48 | } |
---|
| 49 | |
---|
[1896] | 50 | |
---|
| 51 | void Player::getPosition(float* x, float* y, float* z) |
---|
[1872] | 52 | { |
---|
| 53 | *x = xCor; *y = yCor; *z = zCor; |
---|
| 54 | } |
---|
[1858] | 55 | |
---|
[1900] | 56 | |
---|
| 57 | void Player::setCollisionRadius(float radius) |
---|
| 58 | { |
---|
| 59 | collisionRadius = radius; |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | |
---|
[1879] | 63 | void Player::goX(float x) |
---|
[1872] | 64 | { |
---|
| 65 | xCor += x; |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | |
---|
[1879] | 69 | void Player::goY(float y) |
---|
[1872] | 70 | { |
---|
| 71 | yCor += y; |
---|
| 72 | } |
---|
| 73 | |
---|
[1879] | 74 | void Player::goZ(float z) |
---|
[1872] | 75 | { |
---|
| 76 | zCor += z; |
---|
| 77 | } |
---|
| 78 | |
---|
[2036] | 79 | |
---|
| 80 | |
---|
[1896] | 81 | void Player::shoot(int n) |
---|
| 82 | { |
---|
[2036] | 83 | |
---|
[1957] | 84 | // if (shootLaser->inhibitor++ <= 100) |
---|
[2036] | 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 | // else |
---|
| 91 | shootLaser->inhibitor =0; |
---|
[1941] | 92 | |
---|
[2036] | 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 | } |
---|
[1896] | 102 | //cout << "Player::shoot" << endl; |
---|
[2036] | 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 | */ |
---|
[1872] | 111 | } |
---|
| 112 | |
---|
| 113 | |
---|
| 114 | //void Player::addIO(InputOutput *io) {} |
---|
| 115 | |
---|
| 116 | |
---|
[2036] | 117 | void Player::paint() |
---|
[1858] | 118 | { |
---|
[2036] | 119 | //cout << "Player::drawPlayer" << endl; |
---|
[1879] | 120 | glPushMatrix(); |
---|
[1896] | 121 | glTranslatef(xCor, yCor, 3.0); |
---|
[1879] | 122 | glScalef(1.0, 3.0, 1.0); |
---|
| 123 | glutWireCube(1.0); |
---|
| 124 | glPopMatrix(); |
---|
[1896] | 125 | /* draw all the shoots additionaly */ |
---|
| 126 | shootLaser->drawShoot(); |
---|
[1920] | 127 | shootRocket->drawShoot(); |
---|
[2036] | 128 | //cout << "Player::drawPlayer, end" << endl; |
---|
[1896] | 129 | } |
---|
[1879] | 130 | |
---|
| 131 | |
---|
[1896] | 132 | |
---|
| 133 | |
---|
| 134 | |
---|
| 135 | |
---|
| 136 | |
---|
| 137 | |
---|
| 138 | |
---|
| 139 | |
---|
| 140 | |
---|
| 141 | |
---|
| 142 | |
---|
| 143 | |
---|
| 144 | |
---|
| 145 | |
---|
| 146 | |
---|
| 147 | |
---|
| 148 | |
---|
| 149 | |
---|
| 150 | |
---|
| 151 | |
---|
| 152 | |
---|
| 153 | |
---|
| 154 | |
---|
| 155 | |
---|