Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8911


Ignore:
Timestamp:
Nov 2, 2011, 1:23:26 PM (12 years ago)
Author:
eceline
Message:

countdown

Location:
code/branches/spaceraceTwo/src/modules/gametypes
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/spaceraceTwo/src/modules/gametypes/CMakeLists.txt

    r8706 r8911  
    22  SpaceRace.cc
    33  RaceCheckPoint.cc
     4  SpaceRaceManager.cc
    45)
    56
  • code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.cc

    r8898 r8911  
    2929#include "SpaceRace.h"
    3030
     31#include "items/Engine.h"
     32
    3133#include "core/CoreIncludes.h"
    3234#include "chat/ChatManager.h"
     
    4648        this->bTimeIsUp_ = false;
    4749        this->numberOfBots_ = 0;
    48        
     50        this->cantMove_=false;
    4951    }
    5052   
     
    8890
    8991    void SpaceRace::start()
    90     {   int i=0;
    91         for(ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it)
    92         {this->maxSpeedBack_[i]=it->getMaxSpeedBack();
    93         this->maxSpeedFront_[i]=it->getMaxSpeedFront();
    94         this->maxSpeedLeftRight_[i]=it->getMaxSpeedLeftRight();
    95         this->maxSpeedUpDown_[i]=(it->getMaxSpeedUpDown());
    96        
    97         it->setMaxSpeedBack(0);
    98         it->setMaxSpeedFront(0);
    99         it->setMaxSpeedLeftRight(0);
    100         it->setMaxSpeedUpDown(0);
    101        
    102         i++;
    103         }
    104         //Gametype::start();
    105         this->addBots(this->numberOfBots_);
    106    this->spawnPlayersIfRequested();
    107    
    108        
    109        Gametype::checkStart();
    110        
    111         i=0;
    112      for(ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it)
    113         {
    114         it->setMaxSpeedBack(this->maxSpeedBack_[i]);
    115          it->setMaxSpeedFront(this->maxSpeedFront_[i]);
    116          it->setMaxSpeedLeftRight(this->maxSpeedLeftRight_[i]);
    117          it->setMaxSpeedUpDown(this->maxSpeedUpDown_[i]);
    118          i++;
    119          
     92    {
     93                           this->spawnPlayersIfRequested(); Gametype::checkStart();
     94                           this->cantMove_=true;
     95         
     96                 for(ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it)
     97                                {if(it->getMaxSpeedFront()>0){this->maxSpeedBack_=it->getMaxSpeedBack();
     98                                this->maxSpeedFront_=it->getMaxSpeedFront();
     99                                this->maxSpeedLeftRight_=it->getMaxSpeedLeftRight();
     100                                this->maxSpeedUpDown_=(it->getMaxSpeedUpDown());
     101                                 }
     102                                it->setMaxSpeedBack(0);
     103                                it->setMaxSpeedFront(0);
     104                        it->setMaxSpeedLeftRight(0);
     105                                it->setMaxSpeedUpDown(0);
     106                                 
     107                               
     108                                }
     109                               
     110                               this->addBots(this->numberOfBots_);
     111       
     112    }
     113   
     114    void SpaceRace::tick(float dt){
     115    SUPER(SpaceRace,tick,dt);
     116   
     117    if(!this->isStartCountdownRunning() && this->cantMove_){
     118   
     119        for(ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it)
     120                                {
     121                                it->setMaxSpeedBack(this->maxSpeedBack_);
     122                                 it->setMaxSpeedFront(this->maxSpeedFront_);
     123                                 it->setMaxSpeedLeftRight(this->maxSpeedLeftRight_);
     124                                 it->setMaxSpeedUpDown(this->maxSpeedUpDown_);
     125                }
     126                this->cantMove_= false;
     127               
     128                std::string message("The match has started! Reach the check points as quickly as possible!");
     129        const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
     130        ChatManager::message(message);         
    120131     
    121         }
    122                 delete &this->maxSpeedBack_;
    123                 delete &this->maxSpeedFront_;
    124                 delete &this->maxSpeedLeftRight_;
    125                 delete &this->maxSpeedUpDown_;
    126         std::string message("The match has started! Reach the check points as quickly as possible!");
    127         const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
    128         ChatManager::message(message);
    129      
     132    }
     133     
     134   
    130135    }
    131136
  • code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h

    r8898 r8911  
    3434#include <set>
    3535#include <string>
    36 #include <vector>
     36# include <vector>
    3737
    3838#include <util/Clock.h>
     
    6969        void tick(float dt);
    7070        protected:
    71 
     71               
    7272        private:
    73         std::vector<float> maxSpeedBack_; std::vector<float> maxSpeedFront_; std::vector<float> maxSpeedLeftRight_; std::vector<float> maxSpeedUpDown_;
     73        float maxSpeedBack_; float maxSpeedFront_; float maxSpeedLeftRight_; float maxSpeedUpDown_;
     74        bool cantMove_;
    7475            int checkpointsReached_; //The current number of check points reached by the player.
    7576            std::set<float> scores_; //The times of the players are saved in a set.
Note: See TracChangeset for help on using the changeset viewer.