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 | * Cyrill Burgener |
---|
26 | * |
---|
27 | */ |
---|
28 | |
---|
29 | /** |
---|
30 | @file OrxoKart.cc |
---|
31 | @brief Implementation of the OrxoKart class. Sets up the whole Minigame |
---|
32 | */ |
---|
33 | |
---|
34 | #include "OrxoKart.h" |
---|
35 | #include "OrxoKartFlag.h" |
---|
36 | #include "OrxoKartKart.h" |
---|
37 | #include "OrxoKartOrigin.h" |
---|
38 | #include "OrxoKartTile.h" |
---|
39 | #include "core/CoreIncludes.h" |
---|
40 | |
---|
41 | namespace orxonox |
---|
42 | { |
---|
43 | RegisterUnloadableClass(OrxoKart); |
---|
44 | |
---|
45 | OrxoKart::OrxoKart(Context* context) : Gametype(context) |
---|
46 | { |
---|
47 | RegisterObject(OrxoKart); |
---|
48 | |
---|
49 | this->origin_ = nullptr; |
---|
50 | this->numberOfFlags_ = 1; |
---|
51 | this->firstTick_ = true; |
---|
52 | |
---|
53 | this->setHUDTemplate("OrxoKartHUD"); |
---|
54 | } |
---|
55 | |
---|
56 | void OrxoKart::tick(float dt) |
---|
57 | { |
---|
58 | SUPER(OrxoKart, tick, dt); |
---|
59 | |
---|
60 | |
---|
61 | if(this->firstTick_ && this->origin_) |
---|
62 | { |
---|
63 | this->firstTick_ = false; |
---|
64 | |
---|
65 | int n = this->origin_->getNumCells(); |
---|
66 | int s = this->origin_->getCellSize(); |
---|
67 | |
---|
68 | int map_1[] = {1,1,1,1,1,1,1,1,0,0,0 |
---|
69 | ,1,0,0,0,0,0,0,1,1,1,0 |
---|
70 | ,1,0,1,1,1,1,0,0,0,1,1 |
---|
71 | ,1,1,1,0,0,1,1,0,0,0,1 |
---|
72 | ,0,0,0,0,0,0,1,0,1,1,1 |
---|
73 | ,1,1,1,1,1,1,1,0,1,0,0 |
---|
74 | ,1,0,0,0,0,0,0,0,1,0,0 |
---|
75 | ,1,0,0,0,0,0,0,0,1,0,0 |
---|
76 | ,1,1,1,1,1,0,0,0,1,1,1 |
---|
77 | ,0,0,0,0,1,0,0,0,0,0,1 |
---|
78 | ,0,0,0,0,1,1,1,2,1,1,1}; |
---|
79 | |
---|
80 | int map_2[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0, |
---|
81 | 1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0, |
---|
82 | 1,0,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0, |
---|
83 | 1,0,1,0,0,0,0,0,0,0,1,0,1,0,1,1,1,1,1,1,1,1,1,0,0, |
---|
84 | 1,0,1,0,1,1,1,1,1,0,1,0,1,0,1,0,0,0,0,0,0,0,1,0,0, |
---|
85 | 1,0,1,0,1,0,0,0,1,0,1,0,1,0,1,0,1,1,1,1,1,0,1,0,0, |
---|
86 | 1,0,1,0,1,1,1,0,1,0,1,0,1,0,1,0,1,0,0,0,1,0,1,0,0, |
---|
87 | 1,0,1,0,0,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,1,0,1,0,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---|
107 | |
---|
108 | int *levelcodeArray = map_2; |
---|
109 | |
---|
110 | |
---|
111 | //Generate floor according to levelcode |
---|
112 | for(int i=0; i<n; i++){ |
---|
113 | for(int j=0; j<n; j++){ |
---|
114 | if (int type = levelcodeArray[i*n + j]) |
---|
115 | (new OrxoKartTile(origin_->getContext()))->init((n-1-i)*s, j*s, s, type); |
---|
116 | } |
---|
117 | } |
---|
118 | |
---|
119 | //bottom flag |
---|
120 | |
---|
121 | OrxoKartFlag* flag = new OrxoKartFlag(origin_->getContext()); |
---|
122 | flag->init(n, s); |
---|
123 | flag_ = flag; |
---|
124 | |
---|
125 | |
---|
126 | |
---|
127 | |
---|
128 | |
---|
129 | }//firsttick end |
---|
130 | |
---|
131 | |
---|
132 | |
---|
133 | // Check if ship collided with the flag |
---|
134 | if(flag_->getCollided()){ |
---|
135 | OrxoKartKart* player = flag_->getObjectofCollision(); |
---|
136 | orxout() << "Orientation= " << player->getOrientation() << endl; |
---|
137 | player->setPosition(Vector3(80*0, 40, 80*18)); |
---|
138 | player->setOrientation(Quaternion(1, 0, 0, 0)); // 0, 0, 0 |
---|
139 | player->setVelocity(Vector3(0,0,0)); |
---|
140 | player->setAcceleration(Vector3(0,0,0)); |
---|
141 | flag_->setCollided(false); |
---|
142 | |
---|
143 | |
---|
144 | // flag_->destroyLater(); |
---|
145 | // flags_.erase (flags_.begin()+i); |
---|
146 | numberOfFlags_ = 0; |
---|
147 | } |
---|
148 | |
---|
149 | } |
---|
150 | } |
---|