Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/cpp11/src/modules/jump/JumpCenterpoint.h @ 10443

Last change on this file since 10443 was 10443, checked in by landauf, 9 years ago

fixed includes to make it compile without build units

  • Property svn:eol-style set to native
File size: 11.6 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 *      Fabien Vultier
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#ifndef _JumpCenterpoint_H__
30#define _JumpCenterpoint_H__
31
32#include "jump/JumpPrereqs.h"
33#include "worldentities/StaticEntity.h"
34
35namespace orxonox
36{
37   
38    /**
39    @brief
40        The JumpCenterpoint implements the playing field @ref orxonox::Jump "Jump" takes place in and allows for many parameters of the minigame to be set.
41        The playing field resides in the x,z-plane, with the x-axis being the horizontal axis and the z-axis being the vertical axis.
42       
43        Various parameters can be set:
44        - The <b>dimension</b> is a vector, that defines the width and height of the playing field. The default is <em>(200, 120)</em>.
45        - The <b>balltemplate</b> is a template that is applied to the @ref orxonox::JumpPlatform "JumpPlatform", it can be used to attach different things to it, e.g. its @ref orxonox::Model "Model". See below for a usage example.
46        - The <b>battemplate</b> is a template that is applied to the @ref orxonox::JumpPlatform "JumpFigure", it can be used to attach different things to it, e.g. its @ref orxonox::Model "Model". See below for a usage example.
47        - The <b>ballspeed</b> is the speed with which the @ref orxonox::JumpPlatform "JumpPlatform" moves. The default is <em>100</em>.
48        - The <b>ballaccfactor</b> is the acceleration factor for the @ref orxonox::JumpPlatform "JumpPlatform". The default is <em>1.0</em>.
49        - The <b>batspeed</b> is the speed with which the @ref orxonox::JumpFigure "JumpFigures" move. The default is <em>60</em>.
50        - The <b>batlength</b> is the length of the @ref orxonox::JumpFigure "JumpFigures" as the percentage of the height of the playing field. The default is <em>0.25</em>.
51       
52        An example in XML of the JumpCenterpoint would be:
53       
54        First the needed templates:
55        The template for the @ref orxonox::JumpPlatform "JumpPlatform".
56        @code
57        <Template name="jumpball">
58          <JumpPlatform>
59            <attached>
60              <Model mesh="sphere.mesh" scale="2" />
61              <ParticleSpawner name="hiteffect" position="0,0,0" source="Orxonox/sparks2" lifetime="0.01" autostart="0" mainstate="spawn" />
62            </attached>
63            <eventlisteners>
64              <EventTarget target="hiteffect" />
65            </eventlisteners>
66          </JumpPlatform>
67        </Template>
68        @endcode
69        As can be seen, a sphere is attached as the @ref orxonox::Model "Model" for the @ref orxonox::JumpPlatform "JumpPlatform", and also an @ref orxonox::EventListener "EventListener" that triggers a @ref orxonox::ParticleSpawner "ParticleSpawner", whenever the ball hits the boundaries is attached.
70       
71        Additionally the template for the @ref orxonox::JumpFigure "JumpFigure".
72        @code
73        <Template name="jumpbatcameras" defaults="0">
74          <JumpFigure>
75            <camerapositions>
76              <CameraPosition position="0,200,0" pitch="-90" absolute="true" />
77            </camerapositions>
78          </JumpFigure>
79        </Template>
80
81        <Template name="jumpbat">
82          <JumpFigure camerapositiontemplate=jumpbatcameras>
83            <attached>
84              <Model position="0,0,3" mesh="cube.mesh" scale3D="14,2,2" />
85            </attached>
86          </JumpFigure>
87        </Template>
88        @endcode
89        As can be seen, there are actually two templates. The first template is needed to set the camera for the @ref orxonox::JumpFigure "JumpFigure". The second template ist the actual template for the @ref orxonox::JumpFigure "JumpFigure", the template for the camera position is added and a @ref orxonox::Model "Model" for the @ref orxonox::JumpFigure "JumpFigure" is attached.
90        propellerTemplate_
91        Finally the JumpCenterpoint is created.
92        @code
93        <JumpCenterpoint name="jumpcenter" dimension="200,120" balltemplate="jumpball" battemplate="jumpbat" ballspeed="200" ballaccfactor="1.0" batspeed="130" batlength="0.25">
94          <attached>
95            <Model position="0,0,60" mesh="cube.mesh" scale3D="105,1,1" />
96            <Model position="0,0,-60" mesh="cube.mesh" scale3D="105,1,1" />
97          </attached>
98        </JumpCenterpoint>
99        @endcode
100        All parameters are specified. And also two @ref orxonox::Model "Models" (for the upper and lower boundary) are attached.
101       
102        For a more elaborate example, have a look at the <code>jump.oxw</code> level file.
103
104    */
105    class _JumpExport JumpCenterpoint : public StaticEntity
106    {
107        public:
108            JumpCenterpoint(Context* context); //!< Constructor. Registers and initializes the object and checks whether the gametype is actually Jump.
109            virtual ~JumpCenterpoint() {}
110            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method to create a JumpCenterpoint through XML.
111            virtual void changedGametype();
112            void setPlatformStaticTemplate(const std::string& balltemplate)
113                { this->platformStaticTemplate_ = balltemplate; }
114            const std::string& getPlatformStaticTemplate() const
115                { return this->platformStaticTemplate_; }
116            void setPlatformHMoveTemplate(const std::string& balltemplate)
117                { this->platformHMoveTemplate_ = balltemplate; }
118            const std::string& getPlatformHMoveTemplate() const
119                { return this->platformHMoveTemplate_; }
120            void setPlatformVMoveTemplate(const std::string& balltemplate)
121                { this->platformVMoveTemplate_ = balltemplate; }
122            const std::string& getPlatformVMoveTemplate() const
123                { return this->platformVMoveTemplate_; }
124            void setPlatformDisappearTemplate(const std::string& balltemplate)
125                { this->platformDisappearTemplate_ = balltemplate; }
126            const std::string& getPlatformDisappearTemplate() const
127                { return this->platformDisappearTemplate_; }
128            void setPlatformTimerTemplate(const std::string& balltemplate)
129                { this->platformTimerTemplate_ = balltemplate; }
130            const std::string& getPlatformTimerTemplate() const
131                { return this->platformTimerTemplate_; }
132            void setPlatformFakeTemplate(const std::string& balltemplate)
133                { this->platformFakeTemplate_ = balltemplate; }
134            const std::string& getPlatformFakeTemplate() const
135                { return this->platformFakeTemplate_; }
136            void setProjectileTemplate(const std::string& newTemplate)
137                { this->projectileTemplate_ = newTemplate; }
138            const std::string& getProjectileTemplate() const
139                { return this->projectileTemplate_; }
140            void setSpringTemplate(const std::string& newTemplate)
141                { this->springTemplate_ = newTemplate; }
142            const std::string& getSpringTemplate() const
143                { return this->springTemplate_; }
144            void setRocketTemplate(const std::string& newTemplate)
145                { this->rocketTemplate_ = newTemplate; }
146            const std::string& getRocketTemplate() const
147                { return this->rocketTemplate_; }
148            void setPropellerTemplate(const std::string& newTemplate)
149                { this->propellerTemplate_ = newTemplate; }
150            const std::string& getPropellerTemplate() const
151                { return this->propellerTemplate_; }
152            void setBootsTemplate(const std::string& newTemplate)
153                { this->bootsTemplate_ = newTemplate; }
154            const std::string& getBootsTemplate() const
155                { return this->bootsTemplate_; }
156            void setShieldTemplate(const std::string& newTemplate)
157                { this->shieldTemplate_ = newTemplate; }
158            const std::string& getShieldTemplate() const
159                { return this->shieldTemplate_; }
160            void setFigureTemplate(const std::string& newTemplate)
161                { this->figureTemplate_ = newTemplate; }
162            const std::string& getFigureTemplate() const
163                { return this->figureTemplate_; }
164            void setEnemy1Template(const std::string& newTemplate)
165                { this->enemy1Template_ = newTemplate; }
166            const std::string& getEnemy1Template() const
167                { return this->enemy1Template_; }
168            void setEnemy2Template(const std::string& newTemplate)
169                { this->enemy2Template_ = newTemplate; }
170            const std::string& getEnemy2Template() const
171                { return this->enemy2Template_; }
172            void setEnemy3Template(const std::string& newTemplate)
173                { this->enemy3Template_ = newTemplate; }
174            const std::string& getEnemy3Template() const
175                { return this->enemy3Template_; }
176            void setEnemy4Template(const std::string& newTemplate)
177                { this->enemy4Template_ = newTemplate; }
178            const std::string& getEnemy4Template() const
179                { return this->enemy4Template_; }
180            void setFieldDimension(const Vector2& dimension)
181                { this->width_ = dimension.x; this->height_ = dimension.y; }
182            Vector2 getFieldDimension() const
183                { return Vector2(this->width_, this->height_); }
184            void setSectionLength(const float sectionLength)
185                { this->sectionLength_ = sectionLength; }
186            float getSectionLength() const
187                { return sectionLength_; }
188            void setPlatformSpeed(const float platformSpeed)
189                { this->platformSpeed_ = platformSpeed; }
190            float getPlatformSpeed() const
191                { return platformSpeed_; }
192            void setCameraOffset(const float cameraOffset)
193                { this->cameraOffset_ = cameraOffset; }
194            float getCameraOffset() const
195                { return cameraOffset_; }
196        private:
197            void checkGametype();
198            std::string platformStaticTemplate_;
199            std::string platformHMoveTemplate_;
200            std::string platformVMoveTemplate_;
201            std::string platformDisappearTemplate_;
202            std::string platformTimerTemplate_;
203            std::string platformFakeTemplate_;
204            std::string projectileTemplate_;
205            std::string springTemplate_;
206            std::string rocketTemplate_;
207            std::string propellerTemplate_;
208            std::string bootsTemplate_;
209            std::string shieldTemplate_;
210            std::string figureTemplate_;
211            std::string enemy1Template_;
212            std::string enemy2Template_;
213            std::string enemy3Template_;
214            std::string enemy4Template_;
215            float width_;
216            float height_;
217            float sectionLength_;
218            float platformSpeed_;
219            float cameraOffset_;
220    };
221}
222
223#endif /* _JumpCenterpoint_H__ */
Note: See TracBrowser for help on using the repository browser.