Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/weapons/projectile.cc @ 6074

Last change on this file since 6074 was 6074, checked in by bensch, 18 years ago

orxonox/trunk: taken out NullParent.
THE TRUNK IS NOT RUNNING FOR THE TIME BEING. DO NOT BE ALARMED, THIS IS TEMPORARY

File size: 2.4 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#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
18
19#include "projectile.h"
20
21#include "world_entity.h"
22#include "weapon.h"
23#include "model.h"
24
25#include "garbage_collector.h"
26
27using namespace std;
28
29
30/**
31 *  standard constructor
32*/
33Projectile::Projectile () : WorldEntity()
34{
35  this->setClassID(CL_PROJECTILE, "Projectile");
36
37  this->lifeCycle = 0.0;
38  this->lifeSpan = 1.0f; /* sec */
39  this->target.addNodeModeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT |
40                                PNODE_REPARENT_TO_NULLPARENT);
41
42  this->removeNode();
43}
44
45
46/**
47 *  standard deconstructor
48*/
49Projectile::~Projectile ()
50{
51  /*
52     do not delete the test projectModel, since it is pnode
53     and will be cleaned out by world
54  */
55  //delete this->projectileModel;
56}
57
58
59void Projectile::setEnergies(float energyMin, float energyMax)
60{
61  this->energyMin = energyMin;
62  if (energyMax <= energyMin)
63  {
64    this->bChargeable = false;
65    this->energyMax = energyMin;
66  }
67  else
68  {
69    this->bChargeable = true;
70    this->energyMax = energyMax;
71  }
72}
73
74
75/**
76 *  this sets the flight direction of the projectile
77 * @param directin in which to flight
78
79   this function will calculate a vector out of this to be used in the
80   tick function
81*/
82void Projectile::setFlightDirection(const Quaternion& flightDirection)
83{
84  Vector v(1, 0, 0);
85  this->flightDirection = flightDirection.apply(v);
86  this->flightDirection.normalize();
87}
88
89/**
90 *  sets the velocity vector to a spec speed
91 * @param velocity: vector of the velocity
92*/
93void Projectile::setVelocity(const Vector &velocity)
94{
95  //Vector offsetVel =
96  this->velocity = velocity;
97 // offsetVel.normalize();
98  //this->velocity += (offsetVel * 50.0);
99}
100
101
102
103void Projectile::setTarget(PNode* target)
104{
105  this->target.setParent(target);
106}
107
108
109/**
110 * signal tick, time dependent things will be handled here
111 * @param dt since last tick
112*/
113void Projectile::tick (float dt)
114{
115  Vector v = this->velocity * (dt);
116  this->shiftCoor(v);
117
118  if (this->tickLifeCycle(dt))
119    this->destroy();
120}
121
122
123/**
124 *  the function gets called, when the projectile is destroyed
125*/
126void Projectile::destroy ()
127{}
128
Note: See TracBrowser for help on using the repository browser.