Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: fixed speed issue, was a problem with the current track defined in the debug level

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  pj->setFlightDirection(q);
99  pj->setSpeed(this->getSpeed());
100
101  this->worldEntities->add(pj);
102  this->localTime = 0;
103}
104
105
106/**
107   \brief is called, when the weapon gets hit (=collide with something)
108   \param from which entity it is been hit
109   \param where it is been hit
110
111   this may not be used, since it would make the game relay complicated when one
112   can destroy the weapons of enemies or vice versa.
113*/
114void TestGun::hit (WorldEntity* entity, Vector* position) 
115{}
116
117
118/**
119   \brief is called, when the weapon is destroyed
120
121   this is in conjunction with the hit function, so when a weapon is able to get
122   hit, it can also be destoryed.
123*/
124void TestGun::destroy () 
125{}
126
127
128/**
129   \brief tick signal for time dependent/driven stuff
130*/
131void TestGun::tick (float time) 
132{
133  this->localTime += time;
134  //this->debug();
135  //printf("TEST_GUN: this speed is: %f\n", this->getSpeed());
136}
137
138
139/**
140   \brief is called, when there is no fire button pressed
141*/
142void TestGun::weaponIdle()
143{}
144
145
146/**
147   \brief this will draw the weapon
148*/
149void TestGun::draw () 
150{}
151
Note: See TracBrowser for help on using the repository browser.