Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: small cleanup

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