Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/world_entities/weapon.cc @ 3576

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

orxonox/trunk: added function for setting the energy of a weapon

File size: 3.7 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 "weapon.h"
20#include "stdincl.h"
21#include "world_entity.h"
22#include "vector.h"
23#include "objModel.h"
24#include "projectile.h"
25
26using namespace std;
27
28
29/**
30   \brief standard constructor
31
32   creates a new weapon
33*/
34Weapon::Weapon () : WorldEntity()
35{
36  this->model = new OBJModel("");
37}
38
39
40/**
41   \brief standard deconstructor
42*/
43Weapon::~Weapon () 
44{
45  delete this->model;
46}
47
48
49/**
50   \brief sets a new projectile to the weapon
51   \param new projectile for this weapon
52
53   weapon an projectile are independent, so you can combine them as you want
54*/
55void Weapon::setProjectile(Projectile* projectile)
56{
57  this->projectile = projectile;
58}
59
60
61/**
62   \brief sets a new projectile to the weapon
63   \returns the current projectile of this weapon
64
65   weapon an projectile are independent, so you can combine them as you want
66*/
67Projectile* Weapon::getProjectile()
68{
69  return this->projectile;
70}
71
72
73/**
74   \brief this activates the weapon
75
76   This is needed, since there can be more than one weapon on a ship. the
77   activation can be connected with an animation. for example the weapon is
78   been armed out.
79*/
80void Weapon::activate()
81{}
82
83
84/**
85   \brief this deactivates the weapon
86
87   This is needed, since there can be more than one weapon on a ship. the
88   activation can be connected with an animation. for example the weapon is
89   been armed out.
90*/
91void Weapon::deactivate()
92{}
93
94/**
95   \brief asks if the current weapon is active
96   \returns true if it the weapon is active
97*/
98bool Weapon::isActive()
99{}
100
101
102/**
103   \brief this sets the energy of a weapon
104   \param amount of energy
105
106   a weapon has a limited amount of energy, this means a limited amount of shoots
107*/
108void Weapon::setWeaponEnergy(int energy)
109{}
110
111/**
112   \brief adds weapon energy
113   \param amount of energy
114   \returns amount of energy, that is over the energy limit
115
116   this can be used for energy-power up for example. There is a limited amount of energy
117   a weapon can have. so if you want to add more, than it supports, the rest will
118   be returned from this weapon.
119*/
120int Weapon::addWeaponEnergy(int addEnergy)
121{}
122
123/**
124   \brief removes weapon energy
125   \param amount of enery
126
127   this is the case, when ther should be some sort of energy loss in the weapon
128   system. propably wont be the case but usefull to have
129*/
130void Weapon::substractWeaponEnergy(int subEnergy)
131{}
132
133/**
134   \brief gets the amount of energy of a weapon (= ammo)
135*/
136int Weapon::getWeaponEnergy()
137{}
138
139
140/**
141   \brief tick signal for time dependent/driven stuff
142*/
143void Weapon::tick (float time) 
144{}
145
146/**
147   \brief is called, when the weapon gets hit (=collide with something)
148   \param from which entity it is been hit
149   \param where it is been hit
150
151   this may not be used, since it would make the game relay complicated when one
152   can destroy the weapons of enemies or vice versa.
153*/
154void Weapon::hit (WorldEntity* entity, Vector position) 
155{}
156
157/**
158   \brief is called, when the weapon is destroyed
159
160   this is in conjunction with the hit function, so when a weapon is able to get
161   hit, it can also be destoryed.
162*/
163void Weapon::destroy () 
164{}
165
166
167/**
168   \brief this will draw the weapon
169*/
170void Weapon::draw () 
171{
172  glMatrixMode(GL_MODELVIEW);
173  glPushMatrix();
174
175  float matrix[4][4];
176  glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
177  this->getAbsDir().matrix (matrix);
178  glMultMatrixf((float*)matrix);
179  this->model->draw();
180
181  glPopMatrix();
182}
183
Note: See TracBrowser for help on using the repository browser.