Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/world_entities/test_gun.cc @ 3688

Last change on this file since 3688 was 3688, checked in by patrick, 19 years ago

orxonox/trunk: added GARBAGECOLLECTOR to debug module and changed the way the speed is set.

File size: 2.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   \todo: direction in which the projectile flights
19   \todo: a target to set/hit
20*/
21
22
23#include "test_gun.h"
24
25#include "stdincl.h"
26#include "world_entity.h"
27#include "model.h"
28#include "projectile.h"
29
30#include "vector.h"
31#include "list.h"
32
33using namespace std;
34
35
36/**
37   \brief standard constructor
38
39   creates a new weapon
40*/
41TestGun::TestGun (PNode* parent, Vector* coordinate, Quaternion* direction) 
42  :  Weapon (parent, coordinate, direction) 
43{
44  this->idleTime = 0.2f;
45}
46
47
48/**
49   \brief standard deconstructor
50*/
51TestGun::~TestGun () 
52{
53  // model will be deleted from WorldEntity-destructor
54}
55
56
57/**
58   \brief this activates the weapon
59
60   This is needed, since there can be more than one weapon on a ship. the
61   activation can be connected with an animation. for example the weapon is
62   been armed out.
63*/
64void TestGun::activate()
65{}
66
67
68/**
69   \brief this deactivates the weapon
70
71   This is needed, since there can be more than one weapon on a ship. the
72   activation can be connected with an animation. for example the weapon is
73   been armed out.
74*/
75void TestGun::deactivate()
76{}
77
78
79/**
80   \brief fires the weapon
81   
82   this is called from the player.cc, when fire-button is been pushed
83*/
84void TestGun::fire()
85{
86  if( this->localTime < this->idleTime)
87    return;
88
89  Projectile* pj = new Projectile(this);
90
91  Vector* v = new Vector();
92  *v = this->getAbsCoor();
93  pj->setAbsCoor(v);
94  Quaternion* q = new Quaternion();
95  *q = this->getAbsDir();
96  pj->setAbsDir(q);
97
98  //printf("%f\n",this->getSpeed());
99
100  pj->setFlightDirection(q);
101  pj->setSpeed(this->getSpeed());
102
103  this->worldEntities->add(pj);
104  this->localTime = 0;
105}
106
107
108/**
109   \brief is called, when the weapon gets hit (=collide with something)
110   \param from which entity it is been hit
111   \param where it is been hit
112
113   this may not be used, since it would make the game relay complicated when one
114   can destroy the weapons of enemies or vice versa.
115*/
116void TestGun::hit (WorldEntity* entity, Vector* position) 
117{}
118
119
120/**
121   \brief is called, when the weapon is destroyed
122
123   this is in conjunction with the hit function, so when a weapon is able to get
124   hit, it can also be destoryed.
125*/
126void TestGun::destroy () 
127{}
128
129
130/**
131   \brief tick signal for time dependent/driven stuff
132*/
133void TestGun::tick (float time) 
134{
135  this->localTime += time;
136  //this->debug();
137  //printf("TEST_GUN: this speed is: %f\n", this->getSpeed());
138}
139
140
141/**
142   \brief is called, when there is no fire button pressed
143*/
144void TestGun::weaponIdle()
145{}
146
147
148/**
149   \brief this will draw the weapon
150*/
151void TestGun::draw () 
152{}
153
Note: See TracBrowser for help on using the repository browser.