Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.h @ 11595

Last change on this file since 11595 was 11595, checked in by pascscha, 6 years ago

cleanup

File size: 6.3 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 *      Florian Zinggeler
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file FlappyOrx.h
31    @brief Gametype.
32    @ingroup FlappyOrx
33*/
34
35#ifndef _FlappyOrx_H__
36#define _FlappyOrx_H__
37
38#include "flappyorx/FlappyOrxPrereqs.h"
39
40#include "gametypes/Deathmatch.h"
41#include "tools/Timer.h"
42#include <vector>
43
44namespace orxonox
45{
46    struct Circle{
47        int r;
48        int x;
49        int y;
50        Circle(int new_r, int new_x, int new_y){
51            r=new_r;
52            x=new_x;
53            y=new_y;
54        }
55        Circle(){
56            r=0;
57            x=0;
58            y=0;
59        }
60    };
61
62    class _FlappyOrxExport FlappyOrx : public Deathmatch
63    {
64        public:
65            FlappyOrx(Context* context);
66
67            virtual void start() override;
68            virtual void end() override;
69            virtual void death();
70            virtual void addBots(unsigned int amount) override{} //<! overwrite function in order to bypass the addbots command
71
72            void updatePlayerPos(int x);
73            void createAsteroid(Circle &c);
74            void asteroidField(int x, int y, float slope);
75            void spawnTube();
76           
77            void setCenterpoint(FlappyOrxCenterPoint* center);
78
79            int getLives(){return this->lives;}
80            int getLevel(){return this->level;}
81            int getPoints(){return this->point;}
82            int getMultiplier(){return this->multiplier;}
83
84            void costLife();
85            void levelUp();
86            void addPoints(int numPoints);
87            // checks if multiplier should be reset.
88            void comboControll();
89
90            bool isDead();
91            void setDead(bool value);
92
93            FlappyOrxShip* getPlayer();
94           
95            int lives;
96            int multiplier;
97            bool bEndGame;
98            bool bShowLevel;
99            bool bIsDead;
100            bool firstGame;
101            std::string sDeathMessage;
102            std::queue<int> tubes;
103            std::queue<MovableEntity*> asteroids;
104            int spawnDistance;
105            int tubeOffsetX;
106           
107        private:
108            void toggleShowLevel(){bShowLevel = !bShowLevel;}
109           
110            const static int nAst = 7;
111            Circle Asteroids[nAst];
112
113            void ClearAsteroids(){
114                for(int i = 0; i<this->nAst; i++){
115                    Asteroids[i].r=0;
116                }
117            }
118
119           
120            bool Collision(Circle &c1, Circle &c2){
121                if(c1.r==0 || c2.r==0)
122                    return false;
123                int x = c1.x - c2.x;
124                int y = c1.y - c2.y;
125                int r = c1.r + c2.r;
126
127                return x*x+y*y<r*r*1.5;
128            }
129
130            int addIfPossible(Circle c){
131                int i;
132                for(i=0; i<this->nAst && this->Asteroids[i].r!=0;i++){
133                    if(Collision(c,this->Asteroids[i])){
134                        return 0;
135                    }
136                }
137                if(i==nAst)
138                    return 2;
139                this->Asteroids[i].x=c.x;
140                this->Asteroids[i].y=c.y;
141                this->Asteroids[i].r=c.r;
142                createAsteroid(c);
143                return 1;
144            }
145           
146           
147
148            WeakPtr<FlappyOrxCenterPoint> center_;
149            WeakPtr<FlappyOrxShip> player;
150
151            Timer enemySpawnTimer;
152            Timer comboTimer;
153            Timer showLevelTimer;
154            //Context* context;
155            int level;
156            int point;
157            bool b_combo;
158
159            const int NUM_ASTEROIDS = 5;
160
161
162           const std::string Asteroid5[5] = {"Asteroid3_1","Asteroid3_2","Asteroid3_3","Asteroid3_4","Asteroid3_5"};
163           const std::string Asteroid10[5] = {"Asteroid6_1","Asteroid6_2","Asteroid6_3","Asteroid6_4","Asteroid6_5"};
164           const std::string Asteroid15[5] = {"Asteroid9_1","Asteroid9_2","Asteroid9_3","Asteroid9_4","Asteroid9_5"};
165           const std::string Asteroid20[5] = {"Asteroid12_1","Asteroid12_2","Asteroid12_3","Asteroid12_4","Asteroid12_5"};
166           
167            std::vector<std::string> DeathMessage10 = {
168                "You should really try that again",
169                "You can do better, can you?",
170                "Hey maybe you get a participation award, that's good isn't it?",
171                "Congratulations, you get a medal, a wooden one",
172                "That was flappin bad!",
173                "Getting closer to something",
174                "Well, that was a waste of time"};
175            std::vector<std::string> DeathMessage30 = {
176                "Getting better!",
177                "Training has paid off, huh?",
178                "Good average!",
179                "That was somehow enjoyable to watch",
180                "Flappin average",
181                "That wasn't crap, not bad"};
182            std::vector<std::string> DeathMessage50 = {
183                "Flappin great",
184                "Good job!",
185                "Okay, we give you a shiny medal, not a golden one, tough",
186                "Maybe you should do that professionally",
187                "That was really good,!",
188                "We are proud of you"};
189            std::vector<std::string> DeathMessageover50 = {
190                "You're flappin amazing",
191                "Fucking great job",
192                "Wow, we're really impressed",
193                "We will honor you!",
194                "Please do that again!",
195                "Take that golden medal! You've earned it"};
196           
197
198
199
200    };
201}
202
203#endif /* _FlappyOrx_H__ */
Note: See TracBrowser for help on using the repository browser.