Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 10, 2018, 3:36:53 PM (6 years ago)
Author:
merholzl
Message:

added space race improvements

Location:
code/branches/mergeFS18
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/mergeFS18

  • code/branches/mergeFS18/src/modules/gametypes/SpaceRace.cc

    r11721 r12029  
    6969#include "SpaceRaceBot.h"
    7070#include "items/Engine.h"
    71 #include <vector>
     71#include <vector>
     72#include <iostream>
     73#include <string>
    7274
    7375
     
    8385        this->cantMove_ = false;
    8486        this->bTimeIsUp_ = false;
    85 
    8687        this->numberOfBots_ = 5; // quick fix: don't allow default-bots to enter the race
     88        this->bLost =false;
    8789        //we fixed the number of bots in order to have the same starting position all the time !
    8890    }
     
    101103        startpos[4] =-40;
    102104        startpos[5] =100;
    103        
     105         
    104106        startpos[6] =100;
    105107        startpos[7] =-40;
     
    117119
    118120        this->spawnPlayersIfRequested();
     121        this->countdown_mode=true;
    119122        this->cantMove_ = true;
    120123        //players are unable to move while countdown is running
     
    122125        {
    123126            engine->setActive(false);
     127            engine->addSpeedMultiply(1.7);
    124128        }
    125129
     
    138142        }
    139143
    140         std::string message("Use headphones to hear the countdown!");
    141         this->getGametypeInfo()->sendAnnounceMessage(message);
    142         ChatManager::message(message);
    143 
    144         //after 11 seconds , countdownFinished function is called to activate bots` engines
    145         Timer* countdownTimer = new Timer();
    146         countdownTimer->setTimer(11, false, createExecutor(createFunctor(&SpaceRace::countdownFinished, this)));
    147     }
    148 
    149 
    150 
     144        std::string message("Use headphones to hear the countdown! Press W for forward acceleration, press W+space for boost!");
     145
     146        this->getGametypeInfo()->sendAnnounceMessage(message);
     147        ChatManager::message(message);
     148       
     149
     150
     151       
     152    }
     153
     154    // Counter in the beginning of the game
     155    void SpaceRace::tick(float dt) {
     156        SUPER(SpaceRace, tick, dt);
     157       
     158        //countdown_mode is set true,when spawnIfRequested is called
     159        if (countdown_mode) {
     160            //10 seconds will be counted
     161            this->time_passed -= dt;
     162
     163            //orxout() << "time: " <<(int) time_passed << "s" << endl;
     164
     165            std::string message=std::to_string((int)time_passed);
     166            this->getGametypeInfo()->sendAnnounceMessage(message);
     167            if (time_passed <= 1) {
     168
     169                this->countdownFinished();
     170                this->countdown_mode = false;
     171            }
     172        }
     173
     174    }
     175       
     176    void SpaceRace::startmessage(int second){
     177
     178        std::string message=std::to_string(second);
     179        this->getGametypeInfo()->sendAnnounceMessage(message);
     180        ChatManager::message(message);
     181       
     182       
     183
     184    }
    151185
    152186    void SpaceRace::end()
    153187    {
     188       
    154189        this->clock_.capture();
    155190        int s = this->clock_.getSeconds();
    156191        int ms = static_cast<int>(this->clock_.getMilliseconds() - 1000*s);
    157192        std::string message;
    158 
    159193        if (this->bTimeIsUp_)
    160194        {
    161             message = multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds !!\n"
    162                         + "You lose!";
    163         }
     195            message =  "TIME IS UP! YOU LOOSE!";
     196        }
     197       else if(this->bLost){
     198            message = "YOU LOOSE!";
     199
     200       }       
     201       
    164202        else
    165203        {
     
    167205                        + "." + multi_cast<std::string>(ms) + " seconds.";
    168206        }
     207       
    169208        if (!this->hasEnded())
    170209        {
     210
    171211            this->getGametypeInfo()->sendAnnounceMessage(message);
    172212            ChatManager::message(message);
     
    183223        int ms = this->clock_.getMilliseconds() % 1000;
    184224
    185        
    186    
    187         const std::string& message = player->getName() + " reached the checkpoint " + multi_cast<std::string>(checkpoint->getCheckpointIndex() + 1)
     225
     226        std::string message(player->getName() + " reached the checkpoint " + multi_cast<std::string>(checkpoint->getCheckpointIndex() + 1)
     227        + " after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds.");
     228
     229        this->getGametypeInfo()->sendAnnounceMessage(message);
     230        ChatManager::message(message);
     231      /*  const std::string& message = player->getName() + " reached the checkpoint " + multi_cast<std::string>(checkpoint->getCheckpointIndex() + 1)
    188232        + "after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds.";
    189233        this->getGametypeInfo()->sendAnnounceMessage(message);
    190         ChatManager::message(message);
     234        ChatManager::message(message);*/
     235       
    191236
    192237    }
     
    195240    {
    196241
    197         std::string message("RACE STARTED ");
    198         this->getGametypeInfo()->sendAnnounceMessage(message);
    199         ChatManager::message(message);
     242        std::string message("RACE STARTED");
     243        this->getGametypeInfo()->sendAnnounceMessage(message);
     244        ChatManager::message(message);
     245       
    200246
    201247
    202248        for (Engine* engine : ObjectList<Engine>())
    203249            engine->setActive(true);
     250
     251        std::string message2("Press W for forward acceleration, press W+space for boost!");
     252        this->getGametypeInfo()->sendAnnounceMessage(message2);
     253        ChatManager::message(message2);
    204254    }
    205255
Note: See TracChangeset for help on using the changeset viewer.