Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 6, 2017, 12:52:38 PM (7 years ago)
Author:
pascscha
Message:

Asteroid Clusters

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.h

    r11503 r11529  
    4141#include "tools/Timer.h"
    4242
     43
    4344namespace orxonox
    4445{
     46
     47    struct Circle{
     48        int r;
     49        int x;
     50        int y;
     51        Circle(int new_r, int new_x, int new_y){
     52            r=new_r;
     53            x=new_x;
     54            y=new_y;
     55        }
     56        Circle(){
     57            r=0;
     58            x=0;
     59            y=0;
     60        }
     61    };
    4562
    4663    class _FlappyOrxExport FlappyOrx : public Deathmatch
     
    5370            virtual void addBots(unsigned int amount) override{} //<! overwrite function in order to bypass the addbots command
    5471
    55             void spawnEnemy();
    56 
     72            void updatePlayerPos(int x);
     73            void createAsteroid(Circle &c);
     74            void asteroidField(int x, int y, float slope);
     75            void spawnTube();
     76           
    5777            void setCenterpoint(FlappyOrxCenterPoint* center);
    5878
     
    7191            bool bEndGame;
    7292            bool bShowLevel;
     93            std::queue<int> tubes;
     94            int spawnDistance;
     95            int tubeOffsetX;
    7396        private:
    7497            void toggleShowLevel(){bShowLevel = !bShowLevel;}
     98
     99            const static int nAst = 7;
     100            Circle Asteroids[nAst];
     101
     102            void ClearAsteroids(){
     103                for(int i = 0; i<this->nAst; i++){
     104                    Asteroids[i].r=0;
     105                }
     106            }
     107
     108           
     109            bool Collision(Circle &c1, Circle &c2){
     110                if(c1.r==0 || c2.r==0)
     111                    return false;
     112                int x = c1.x - c2.x;
     113                int y = c1.y - c2.y;
     114                int r = c1.r + c2.r;
     115
     116                return x*x+y*y<r*r*1.5;
     117            }
     118
     119            int addIfPossible(Circle c){
     120                int i;
     121                for(i=0; i<this->nAst && this->Asteroids[i].r!=0;i++){
     122                    if(Collision(c,this->Asteroids[i])){
     123                        return 0;
     124                    }
     125                }
     126                if(i==nAst)
     127                    return 2;
     128                this->Asteroids[i].x=c.x;
     129                this->Asteroids[i].y=c.y;
     130                this->Asteroids[i].r=c.r;
     131                createAsteroid(c);
     132                return 1;
     133            }
     134           
     135           
     136
    75137            FlappyOrxShip* getPlayer();
    76138            WeakPtr<FlappyOrxCenterPoint> center_;
     
    84146            int point;
    85147            bool b_combo;
     148            std::string Asteroid5[6] = {"Asteroid3_1","Asteroid3_2","Asteroid3_3","Asteroid3_4","Asteroid3_5","Asteroid3_6"};
     149            std::string Asteroid10[6] = {"Asteroid6_1","Asteroid6_2","Asteroid6_3","Asteroid6_4","Asteroid6_5","Asteroid6_6"};
     150            std::string Asteroid15[6] = {"Asteroid9_1","Asteroid9_2","Asteroid9_3","Asteroid9_4","Asteroid9_5","Asteroid9_6"};
     151            std::string Asteroid20[6] = {"Asteroid12_1","Asteroid12_2","Asteroid12_3","Asteroid12_4","Asteroid12_5","Asteroid12_6"};
     152
     153
     154
    86155    };
    87156}
Note: See TracChangeset for help on using the changeset viewer.