Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/height_map_merge/src/world_entities/projectiles/projectile.cc @ 6527

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

orxonox/trunk: moved the projectiles to Projectiles

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