Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/world_entities/weapons/test_bullet.cc @ 4892

Last change on this file since 4892 was 4892, checked in by bensch, 19 years ago

orxonox/trunk: brought logic to the execution-cycle.
There are now some subfunction fireW() that sets all the properties needed for a shoot, and then the extension (derived class) can define the Fire function itself

File size: 1.9 KB
Line 
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 "model.h"
22#include "vector.h"
23
24using namespace std;
25
26
27/**
28 *  standard constructor
29*/
30TestBullet::TestBullet (Weapon* weapon) : Projectile(weapon)
31{
32  this->setClassID(CL_TEST_BULLET, "TestBullet");
33
34  float modelSize = .5;
35  this->model = (Model*)ResourceManager::getInstance()->load("models/orx-rocket.obj", OBJ, RP_LEVEL, (void*) &modelSize);
36}
37
38
39/**
40 *  standard deconstructor
41*/
42TestBullet::~TestBullet ()
43{
44  /*
45     do not delete the test projectModel, since it is pnode
46     and will be cleaned out by world
47  */
48  //delete this->projectileModel;
49}
50
51
52
53/**
54 *  signal tick, time dependent things will be handled here
55 * @param time since last tick
56*/
57void TestBullet::tick (float time)
58{
59  //Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.1);
60  Vector v = this->velocity * (time);
61  this->shiftCoor(v);
62
63  this->lifeCycle += time/this->lifeSpan;
64  if( this->lifeCycle >= 1)
65    {
66      PRINTF(5)("FINALIZE==========================\n");
67      PRINTF(5)("current life cycle is: %f\n", this->lifeCycle);
68      PRINTF(5)("FINALIZE===========================\n");
69      this->finalize();
70    }
71}
72
73/**
74 *  the function gets called, when the projectile is destroyed
75*/
76void TestBullet::destroy ()
77{}
78
79
80void TestBullet::draw ()
81{
82  glMatrixMode(GL_MODELVIEW);
83  glPushMatrix();
84
85  float matrix[4][4];
86  glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
87  this->getAbsDir().matrix (matrix);
88  glMultMatrixf((float*)matrix);
89  glScalef(2.0, 2.0, 2.0);
90  this->model->draw();
91
92  glPopMatrix();
93}
94
Note: See TracBrowser for help on using the repository browser.