[3708] | 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. |
---|
| 12 | |
---|
| 13 | ### File Specific |
---|
| 14 | main-programmer: Patrick Boenzli |
---|
| 15 | co-programmer: |
---|
| 16 | */ |
---|
| 17 | |
---|
| 18 | |
---|
[3709] | 19 | #include "test_bullet.h" |
---|
[3708] | 20 | |
---|
| 21 | #include "world_entity.h" |
---|
| 22 | #include "weapon.h" |
---|
| 23 | #include "null_parent.h" |
---|
| 24 | #include "model.h" |
---|
| 25 | #include "vector.h" |
---|
| 26 | |
---|
| 27 | using namespace std; |
---|
| 28 | |
---|
| 29 | |
---|
| 30 | /** |
---|
| 31 | \brief standard constructor |
---|
| 32 | */ |
---|
[3710] | 33 | TestBullet::TestBullet (Weapon* weapon) : Projectile(weapon) |
---|
[3755] | 34 | { |
---|
[4322] | 35 | this->setClassID(CL_TEST_BULLET, "TestBullet"); |
---|
[3755] | 36 | this->model = (Model*)ResourceManager::getInstance()->load("models/test_projectile.obj", OBJ, RP_LEVEL); |
---|
| 37 | } |
---|
[3708] | 38 | |
---|
| 39 | |
---|
| 40 | /** |
---|
| 41 | \brief standard deconstructor |
---|
| 42 | */ |
---|
[3709] | 43 | TestBullet::~TestBullet () |
---|
[3708] | 44 | { |
---|
| 45 | /* |
---|
| 46 | do not delete the test projectModel, since it is pnode |
---|
| 47 | and will be cleaned out by world |
---|
| 48 | */ |
---|
| 49 | //delete this->projectileModel; |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | |
---|
| 53 | |
---|
| 54 | /** |
---|
| 55 | \brief signal tick, time dependent things will be handled here |
---|
| 56 | \param time since last tick |
---|
| 57 | */ |
---|
[3709] | 58 | void TestBullet::tick (float time) |
---|
[3708] | 59 | { |
---|
[3757] | 60 | Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.1); |
---|
[3708] | 61 | this->shiftCoor(v); |
---|
| 62 | |
---|
| 63 | this->currentLifeTime += time; |
---|
| 64 | if( this->ttl < this->currentLifeTime) |
---|
| 65 | { |
---|
| 66 | PRINTF(5)("FINALIZE==========================\n"); |
---|
| 67 | PRINTF(5)("current life time is: %f/%f\n", this->currentLifeTime, this->ttl); |
---|
| 68 | PRINTF(5)("FINALIZE===========================\n"); |
---|
| 69 | this->finalize(); |
---|
| 70 | this->currentLifeTime = 0.0f; |
---|
| 71 | } |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | /** |
---|
| 75 | \brief the projectile gets hit by another entity |
---|
| 76 | \param the other entity |
---|
| 77 | \param place where it is hit |
---|
| 78 | */ |
---|
[3709] | 79 | void TestBullet::hit (WorldEntity* entity, Vector* place) |
---|
[3708] | 80 | {} |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | /** |
---|
| 84 | \brief the function gets called, when the projectile is destroyed |
---|
| 85 | */ |
---|
[3709] | 86 | void TestBullet::destroy () |
---|
[3708] | 87 | {} |
---|
| 88 | |
---|
| 89 | |
---|
[3709] | 90 | void TestBullet::draw () |
---|
[3708] | 91 | { |
---|
| 92 | glMatrixMode(GL_MODELVIEW); |
---|
| 93 | glPushMatrix(); |
---|
| 94 | |
---|
| 95 | float matrix[4][4]; |
---|
| 96 | glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z); |
---|
| 97 | this->getAbsDir().matrix (matrix); |
---|
| 98 | glMultMatrixf((float*)matrix); |
---|
[3755] | 99 | glScalef(2.0, 2.0, 2.0); |
---|
[3708] | 100 | this->model->draw(); |
---|
| 101 | |
---|
| 102 | glPopMatrix(); |
---|
| 103 | } |
---|
| 104 | |
---|