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 | |
---|
19 | #include "test_bullet.h" |
---|
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 | */ |
---|
33 | TestBullet::TestBullet (Weapon* weapon) : Projectile(weapon) |
---|
34 | {} |
---|
35 | |
---|
36 | |
---|
37 | /** |
---|
38 | \brief standard deconstructor |
---|
39 | */ |
---|
40 | TestBullet::~TestBullet () |
---|
41 | { |
---|
42 | /* |
---|
43 | do not delete the test projectModel, since it is pnode |
---|
44 | and will be cleaned out by world |
---|
45 | */ |
---|
46 | //delete this->projectileModel; |
---|
47 | } |
---|
48 | |
---|
49 | |
---|
50 | |
---|
51 | /** |
---|
52 | \brief signal tick, time dependent things will be handled here |
---|
53 | \param time since last tick |
---|
54 | */ |
---|
55 | void TestBullet::tick (float time) |
---|
56 | { |
---|
57 | Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.7); |
---|
58 | this->shiftCoor(v); |
---|
59 | |
---|
60 | this->currentLifeTime += time; |
---|
61 | if( this->ttl < this->currentLifeTime) |
---|
62 | { |
---|
63 | PRINTF(5)("FINALIZE==========================\n"); |
---|
64 | PRINTF(5)("current life time is: %f/%f\n", this->currentLifeTime, this->ttl); |
---|
65 | PRINTF(5)("FINALIZE===========================\n"); |
---|
66 | this->finalize(); |
---|
67 | this->currentLifeTime = 0.0f; |
---|
68 | } |
---|
69 | } |
---|
70 | |
---|
71 | /** |
---|
72 | \brief the projectile gets hit by another entity |
---|
73 | \param the other entity |
---|
74 | \param place where it is hit |
---|
75 | */ |
---|
76 | void TestBullet::hit (WorldEntity* entity, Vector* place) |
---|
77 | {} |
---|
78 | |
---|
79 | |
---|
80 | /** |
---|
81 | \brief the function gets called, when the projectile is destroyed |
---|
82 | */ |
---|
83 | void TestBullet::destroy () |
---|
84 | {} |
---|
85 | |
---|
86 | |
---|
87 | void TestBullet::draw () |
---|
88 | { |
---|
89 | glMatrixMode(GL_MODELVIEW); |
---|
90 | glPushMatrix(); |
---|
91 | |
---|
92 | float matrix[4][4]; |
---|
93 | glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z); |
---|
94 | this->getAbsDir().matrix (matrix); |
---|
95 | glMultMatrixf((float*)matrix); |
---|
96 | this->model->draw(); |
---|
97 | |
---|
98 | glPopMatrix(); |
---|
99 | } |
---|
100 | |
---|