Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11042


Ignore:
Timestamp:
Jan 4, 2016, 6:31:29 PM (8 years ago)
Author:
landauf
Message:

use only default constructor (with context, but no other arguments)

Location:
code/branches/presentationHS15/src/modules/hover
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentationHS15/src/modules/hover/Hover.cc

    r11041 r11042  
    7575            //Outer Walls
    7676            for(int i = 0; i<numCells; i++){
    77                 new HoverWall(origin_->getContext(), 0,        i+1,      cellSize, cellHeight, 1);
    78                 new HoverWall(origin_->getContext(), numCells, i+1,      cellSize, cellHeight, 1);
    79                 new HoverWall(origin_->getContext(), i+1,      0,        cellSize, cellHeight, 2);
    80                 new HoverWall(origin_->getContext(), i+1,      numCells, cellSize, cellHeight, 2);
     77                (new HoverWall(origin_->getContext()))->init(0,        i+1,      cellSize, cellHeight, 1);
     78                (new HoverWall(origin_->getContext()))->init(numCells, i+1,      cellSize, cellHeight, 1);
     79                (new HoverWall(origin_->getContext()))->init(i+1,      0,        cellSize, cellHeight, 2);
     80                (new HoverWall(origin_->getContext()))->init(i+1,      numCells, cellSize, cellHeight, 2);
    8181            }
    8282
     
    8585                for(int x=0; x<numCells; x++){
    8686                    switch(levelcode[ y * numCells + x ]){
    87                         case 1: new HoverWall(origin_->getContext(), x+1, numCells-y, cellSize, cellHeight, 1);
     87                        case 1: (new HoverWall(origin_->getContext()))->init(x+1, numCells-y, cellSize, cellHeight, 1);
    8888                                break;
    89                         case 3: new HoverWall(origin_->getContext(), x+1, numCells-y, cellSize, cellHeight, 1);
    90                         case 2: new HoverWall(origin_->getContext(), x+1, numCells-y, cellSize, cellHeight, 0);
     89                        case 3: (new HoverWall(origin_->getContext()))->init(x+1, numCells-y, cellSize, cellHeight, 1);
     90                        case 2: (new HoverWall(origin_->getContext()))->init(x+1, numCells-y, cellSize, cellHeight, 0);
    9191                        default: break;
    9292                    }
     
    9696            //Generate 5 flags randomly
    9797            for ( int i = 0; i < 5; i++ )
    98                 flagVector_.push_back(new HoverFlag(origin_->getContext(), rand()%numCells, rand()%numCells, cellSize));
     98            {
     99                HoverFlag* flag = new HoverFlag(origin_->getContext());
     100                flag->init(rand()%numCells, rand()%numCells, cellSize);
     101                flagVector_.push_back(flag);
     102            }
    99103
    100104            flags_ = flagVector_.size();
  • code/branches/presentationHS15/src/modules/hover/HoverFlag.cc

    r11041 r11042  
    4848    {
    4949        RegisterObject(HoverFlag);
    50         model_ = NULL;
    51         cs_ = NULL;
     50
     51        this->model_ = NULL;
     52        this->cs_ = NULL;
     53        this->collided_ = false;
     54
     55        this->enableCollisionCallback();
     56        this->setCollisionResponse(true);
     57        this->setCollisionType(Static);
    5258    }
    5359
    5460    /**
    5561    @brief
    56         Constructor that expects two coordinate-values in the range 0-9
     62        Initializes the flag.
    5763    @param xCoordinate
    5864        X-Coordinate of the flage, 0-9, origin is bottom left
     
    6066        Y-Coordinate of the flage, 0-9, origin is bottom left
    6167    */
    62     HoverFlag::HoverFlag(Context* context, int xCoordinate, int yCoordinate, int cellSize) : StaticEntity(context)
     68    void HoverFlag::init(int xCoordinate, int yCoordinate, int cellSize)
    6369    {
    64         RegisterObject(HoverFlag);
    65         enableCollisionCallback();
    66         model_ = NULL;
    67         cs_ = NULL;
    68 
    69         model_ = new Model(context);
     70        model_ = new Model(this->getContext());
    7071        model_->setMeshSource("ss_flag_eu.mesh");
    7172        model_->setScale3D(Vector3(5, 5, 5));
     
    7475        this->attach(model_);
    7576
    76         this->enableCollisionCallback();
    77         this->setCollisionResponse(true);
    78         this->setCollisionType(Static);
    79 
    80         cs_ = new BoxCollisionShape(context);
     77        cs_ = new BoxCollisionShape(this->getContext());
    8178        cs_->setHalfExtents(Vector3(5, 5, 5));
    8279        cs_->setPosition(Vector3(xCoordinate*cellSize*1.0f + cellSize/2,0.0f,yCoordinate*cellSize*1.0f + cellSize/2));
    8380
    8481        this->attachCollisionShape(cs_);
    85         this->collided_ = false;
    86 
    8782    }
    8883
  • code/branches/presentationHS15/src/modules/hover/HoverFlag.h

    r11041 r11042  
    4747        public:
    4848            HoverFlag(Context* context);
    49             HoverFlag(Context* context, int xCoordinate, int yCoordinate, int cellSize);
    5049            virtual ~HoverFlag();
     50
     51            void init(int xCoordinate, int yCoordinate, int cellSize);
    5152
    5253            virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint);           
  • code/branches/presentationHS15/src/modules/hover/HoverWall.cc

    r11041 r11042  
    4545    {
    4646        RegisterObject(HoverWall);
    47         model_ = NULL;
    48         cs_ = NULL;
     47
     48        this->model_ = NULL;
     49        this->cs_ = NULL;
     50
     51        this->enableCollisionCallback();
     52        this->setCollisionResponse(true);
     53        this->setCollisionType(Static);
    4954    }
    50 
    5155
    5256    /**
    5357    @brief
    54         Constructor of a HoverWall
     58        Destructor.
     59    */
     60    HoverWall::~HoverWall()
     61    {
     62
     63    }
     64
     65    /**
     66    @brief
     67        Initializes a HoverWall
    5568    @param x
    5669        x-Coordinate of the Square that the Wall is attached to, 0-9, Origin is Bottom left
     
    6073            Wall on the right side (1) or on top (2) of this square, 0-1       
    6174    */
    62     HoverWall::HoverWall(Context* context, int x, int y, int cellSize, int cellHeight, int orientation) : StaticEntity(context)
     75    void HoverWall::init(int x, int y, int cellSize, int cellHeight, int orientation)
    6376    {
    64         RegisterObject(HoverWall);
    65 
    6677        int xSize_, zSize_, xPos_, zPos_;
    6778
     
    8091
    8192
    82         model_ = new Model(context);
     93        model_ = new Model(this->getContext());
    8394        model_->setMeshSource("CuboidBody.mesh");
    8495        model_->setScale3D(Vector3(xSize_*1.0f, cellHeight*1.0f, zSize_*1.0f));
     
    8798        this->attach(model_);
    8899
    89         this->enableCollisionCallback();
    90         this->setCollisionResponse(true);
    91         this->setCollisionType(Static);
    92 
    93         cs_ = new BoxCollisionShape(context);
     100        cs_ = new BoxCollisionShape(this->getContext());
    94101        cs_->setHalfExtents(Vector3(xSize_*1.0f, cellHeight*1.0f, zSize_*1.0f));
    95102        cs_->setPosition(Vector3(xPos_*1.0f, 0.0f, zPos_*1.0f));
     
    97104        this->attachCollisionShape(cs_);
    98105    }
    99 
    100     /**
    101     @brief
    102         Destructor.
    103     */
    104     HoverWall::~HoverWall()
    105     {
    106 
    107     }
    108106}
  • code/branches/presentationHS15/src/modules/hover/HoverWall.h

    r11041 r11042  
    4646    {
    4747        public:
    48             HoverWall(Context* context);           
    49             HoverWall(Context* context, int x, int y, int cellSize, int cellHeight, int orientation);
     48            HoverWall(Context* context);
    5049            virtual ~HoverWall();
     50
     51            void init(int x, int y, int cellSize, int cellHeight, int orientation);
    5152
    5253        private:
Note: See TracChangeset for help on using the changeset viewer.