Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/TixyTaxyTorxy_HS18/src/modules/TixyTaxyTorxy/TixyTaxyTorxySelecter.cc @ 12064

Last change on this file since 12064 was 12064, checked in by sastocke, 5 years ago

second initial setup

File size: 4.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/**
30    @file TixyTaxyTorxy
31TixyTaxyTorxySelecter.cc
32    @brief This class represents your figure when you play the minigame. Here the movement of the figure, activating items, ... are handled.
33*/
34
35#include "TixyTaxyTorxySelecter.h"
36
37#include "core/CoreIncludes.h"
38#include "graphics/Model.h"
39
40namespace orxonox
41{
42    RegisterClass(TixyTaxyTorxySelecter);
43
44    TixyTaxyTorxySelecter::TixyTaxyTorxySelecter(Context* context) : ControllableEntity(context)
45    {
46        RegisterObject(TixyTaxyTorxySelecter);
47
48        // initialize variables
49        moveUpPressed_ = false;
50        moveDownPressed_ = false;
51        moveLeftPressed_ = false;
52        moveRightPressed_ = false;
53        boostPressed_ = false;
54        buildTower_ = false;
55        setSelectedPosition(0,0);     
56    }
57
58    TixyTaxyTorxySelecter::~TixyTaxyTorxySelecter()
59    {
60
61    }
62
63    void TixyTaxyTorxySelecter::tick(float dt)
64    {
65        SUPER(TixyTaxyTorxySelecter, tick, dt);
66
67        time_ += dt;
68
69        if (hasLocalController() && time_ >= 0.25)
70        {   
71            time_ = 0;
72
73            int selecterPosX = selectedPos_->GetX();
74            int selecterPosY = selectedPos_->GetY();
75
76            if (moveUpPressed_ == true)
77            {               
78                moveUpPressed_ = false;
79                selectedPos_->Set(selecterPosX, selecterPosY + 1);
80                updatePosition();
81            }
82            if (moveDownPressed_ == true)
83            {
84                moveDownPressed_ = false;
85                selectedPos_->Set(selecterPosX, selecterPosY - 1);
86                updatePosition();
87            }
88            if (moveLeftPressed_ == true)
89            {
90                moveLeftPressed_ = false;
91                selectedPos_->Set(selecterPosX - 1, selecterPosY);
92                updatePosition();
93            }
94            if (moveRightPressed_ == true)
95            {
96                moveRightPressed_ = false;
97                selectedPos_->Set(selecterPosX + 1, selecterPosY);
98                updatePosition();
99            }
100            if (boostPressed_ == true)
101            {
102                boostPressed_ = false;
103                buildTower_ = true;
104            }
105        }         
106    }
107
108
109    void TixyTaxyTorxySelecter::moveFrontBack(const Vector2& value)
110    {
111        if (value.x > 0)
112        {
113            moveUpPressed_ = true;
114            moveDownPressed_ = false;
115        }
116        else
117        {
118            moveUpPressed_ = false;
119            moveDownPressed_ = true;
120        }
121    }
122
123    void TixyTaxyTorxySelecter::moveRightLeft(const Vector2& value)
124    {
125        if (value.x > 0)
126        {
127            moveLeftPressed_ = false;
128            moveRightPressed_ = true;
129        }
130        else
131        {
132            moveLeftPressed_ = true;
133            moveRightPressed_ = false;
134        }
135    }
136
137    void TixyTaxyTorxySelecter::rotateYaw(const Vector2& value)
138    {
139    }
140
141    void TixyTaxyTorxySelecter::rotatePitch(const Vector2& value)
142    {
143    }
144
145    void TixyTaxyTorxySelecter::rotateRoll(const Vector2& value)
146    {
147    }
148
149    void TixyTaxyTorxySelecter::fire(unsigned int firemode)
150    {
151    }
152
153    void TixyTaxyTorxySelecter::fired(unsigned int firemode)
154    {
155       
156    }
157
158    void TixyTaxyTorxySelecter::boost(bool bBoost)
159    {
160        if (bBoost == true)
161        {
162            boostPressed_ = true;
163        }
164    }
165
166    void TixyTaxyTorxySelecter::updatePosition()
167    {
168        setPosition(selectedPos_->get3dcoordinate());
169    }
170
171    void TixyTaxyTorxySelecter::setSelectedPosition(TixyTaxyTorxyCoordinate* newPos)
172    {
173        selectedPos_ = newPos;
174        updatePosition();
175    }
176
177    void TixyTaxyTorxySelecter::setSelectedPosition(int x,  int y)
178    {
179        setSelectedPosition(new TixyTaxyTorxyCoordinate(x,y));
180    }
181}
Note: See TracBrowser for help on using the repository browser.