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 | * Manuel Meier |
---|
24 | * Co-authors: |
---|
25 | * ... |
---|
26 | * |
---|
27 | */ |
---|
28 | |
---|
29 | /** |
---|
30 | @file HoverWall.cc |
---|
31 | @brief Represents one Wall piece in the Hover Game |
---|
32 | */ |
---|
33 | |
---|
34 | #include "HoverWall.h" |
---|
35 | |
---|
36 | #include "core/CoreIncludes.h" |
---|
37 | #include "core/GameMode.h" |
---|
38 | #include "graphics/Model.h" |
---|
39 | #include "gametypes/Gametype.h" |
---|
40 | |
---|
41 | |
---|
42 | |
---|
43 | #include "core/XMLPort.h" |
---|
44 | |
---|
45 | namespace orxonox |
---|
46 | { |
---|
47 | RegisterClass(HoverWall); |
---|
48 | |
---|
49 | HoverWall::HoverWall(Context* context) : StaticEntity(context) |
---|
50 | { |
---|
51 | RegisterObject(HoverWall); |
---|
52 | model_ = NULL; |
---|
53 | cs_ = NULL; |
---|
54 | } |
---|
55 | |
---|
56 | |
---|
57 | /** |
---|
58 | @brief |
---|
59 | Constructor of a HoverWall |
---|
60 | @param x |
---|
61 | x-Coordinate of the Square that the Wall is attached to, 0-9, Origin is Bottom left |
---|
62 | @param y |
---|
63 | y-Coordinate of the Square that the Wall is attached to, 0-9, Origin is Bottom left |
---|
64 | @param orientation |
---|
65 | Wall on the right side (1) or on top (2) of this square, 0-1 |
---|
66 | */ |
---|
67 | HoverWall::HoverWall(Context* context, int x, int y, int orientation) : StaticEntity(context) |
---|
68 | { |
---|
69 | RegisterObject(HoverWall); |
---|
70 | |
---|
71 | int xSize_, zSize_, xPos_, zPos_; |
---|
72 | |
---|
73 | if(orientation == 1){ |
---|
74 | xSize_ = 50; |
---|
75 | zSize_ = 2; |
---|
76 | zPos_ = x*100; |
---|
77 | xPos_ = y*100 -50; |
---|
78 | } |
---|
79 | else{ |
---|
80 | xSize_ = 2; |
---|
81 | zSize_ = 50; |
---|
82 | zPos_ = x*100-50; |
---|
83 | xPos_ = y*100; |
---|
84 | } |
---|
85 | |
---|
86 | |
---|
87 | model_ = new Model(context); |
---|
88 | model_->setMeshSource("CuboidBody.mesh"); |
---|
89 | model_->setScale3D(Vector3(xSize_, 30, zSize_)); |
---|
90 | model_->setPosition(Vector3(xPos_,0,zPos_)); |
---|
91 | |
---|
92 | this->attach(model_); |
---|
93 | |
---|
94 | this->enableCollisionCallback(); |
---|
95 | this->setCollisionResponse(true); |
---|
96 | this->setCollisionType(Static); |
---|
97 | |
---|
98 | cs_ = new BoxCollisionShape(context); |
---|
99 | cs_->setHalfExtents(Vector3(xSize_, 30, zSize_)); |
---|
100 | cs_->setPosition(Vector3(xPos_,0,zPos_)); |
---|
101 | |
---|
102 | this->attachCollisionShape(cs_); |
---|
103 | } |
---|
104 | |
---|
105 | /** |
---|
106 | @brief |
---|
107 | Destructor. |
---|
108 | */ |
---|
109 | HoverWall::~HoverWall() |
---|
110 | { |
---|
111 | |
---|
112 | } |
---|
113 | |
---|
114 | //xml port for loading height and width of the platform, unused |
---|
115 | void HoverWall::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
116 | { |
---|
117 | SUPER(HoverWall, XMLPort, xmlelement, mode); |
---|
118 | } |
---|
119 | |
---|
120 | /** |
---|
121 | @brief |
---|
122 | Is called every tick. |
---|
123 | Handles the movement of the ball and its interaction with the boundaries and bats. |
---|
124 | @param dt |
---|
125 | The time since the last tick. |
---|
126 | */ |
---|
127 | void HoverWall::tick(float dt) |
---|
128 | { |
---|
129 | SUPER(HoverWall, tick, dt); |
---|
130 | |
---|
131 | } |
---|
132 | |
---|
133 | |
---|
134 | } |
---|