Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/orxonox_tutorial/src/orxonox/objects/TutorialShip.cc @ 1857

Last change on this file since 1857 was 1857, checked in by rgrieder, 16 years ago

Added comments to the TutorialShip

  • Property svn:eol-style set to native
File size: 3.8 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Oliver 'greenman' Scheuss, Reto '1337' Grieder
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29// for precompiled header files. Has to be first!
30#include "OrxonoxStableHeaders.h"
31// always include this class's header file first so that
32// it compiles on its own too.
33#include "TutorialShip.h"
34
35// Additional includes
36#include "util/Convert.h"
37#include "util/Debug.h"
38#include "util/Math.h"
39#include "core/ConfigValueIncludes.h"
40#include "core/ConsoleCommand.h"
41#include "core/CoreIncludes.h"
42#include "core/input/InputManager.h"
43#include "core/XMLPort.h"
44
45namespace orxonox
46{
47    // Specify a console command that can be used in
48    // the shell or as key binding.
49    SetConsoleCommand(TutorialShip, fire, true)
50        .keybindMode(KeybindMode::OnHold);
51
52    // Make sure we can create an object of this class by XML
53    CreateFactory(TutorialShip);
54
55    // Constructor
56    TutorialShip::TutorialShip()
57    {
58        RegisterObject(TutorialShip);
59
60        // reset variables
61        this->hasSpecialEffects_ = false;
62
63        // set config values
64        this->setConfigValues();
65    }
66
67    // Destructor
68    TutorialShip::~TutorialShip()
69    {
70    }
71
72    // Sets the configurable member variables.
73    // They can be found later in orxonox.ini directly.
74    void TutorialShip::setConfigValues()
75    {
76        SetConfigValue(reloadTime_, 0.125)
77            .description("The reload time of the weapon in seconds");
78    }
79   
80    // Called when loading an object of this class with XML
81    // You don't have to know what exactly xmlelement is.
82    // And mode is not important yet (load/save).
83    void TutorialShip::XMLPort(Element& xmlelement, XMLPort::Mode mode)
84    {
85        // Load our parameter "specialEffects". Case sensitive!
86        XMLPortParam(TutorialShip, "specialEffects", setSpecialEffects,
87            hasSpecialEffects, xmlelement, mode);
88
89        // Calls SpaceShip::XMLPort so that the SpaceShip XML parameters
90        // are loaded too.
91        SUPER(TutorialShip, XMLPort, xmlelement, mode);
92    }
93
94    // XML save function. Also used by back end class SpaceShip
95    // to show or hide the special effects.
96    bool TutorialShip::hasSpecialEffects()
97    {
98        return this->hasSpecialEffects_;
99    }
100
101    // XML load function. Called by the XML macro above.
102    void TutorialShip::setSpecialEffects(bool value)
103    {
104        this->hasSpecialEffects_ = value;
105    }
106
107    // virtual function used by back end class SpaceShip.
108    float TutorialShip::getReloadTime()
109    {
110        return this->reloadTime_;
111    }
112
113    // run time update method. Gets called every frame with the delta time that
114    // has passed since the last frame.
115    void TutorialShip::tick(float dt)
116    {
117        // Also call the tick() method of the base clas.
118        SUPER(TutorialShip, tick, dt);
119    }
120
121    // Fire a projectile. Delegated to the back end class SpaceShip.
122    // Function content is insignificant for the tutorial.
123    void TutorialShip::fire()
124    {
125        SpaceShip::getLocalShip()->doFire();
126    }
127}
Note: See TracBrowser for help on using the repository browser.