Пример #1
0
/* Builds an ascii string for the passed in time */
void	getAsciiTime( char *psText, UDWORD time )
{
UDWORD	hours,minutes,seconds;

	getTimeComponents(time,&hours,&minutes,&seconds);
	constructTime(psText,hours,minutes,seconds);
}
Пример #2
0
// Builds an ascii string for the passed in components 4:02:23 for example.
void getAsciiTime(char *psText, unsigned time)
{
	int hours, minutes, seconds, milliseconds;
	getTimeComponents(time, &hours, &minutes, &seconds, &milliseconds);

	char const *hourColon = hours != 0? ":" : "";

	bool showMs = gameTimeGetMod() < Rational(1, 4);
	if (showMs)
	{
		sprintf(psText, "%.0d%s%02d:%02d.%03d", hours, hourColon, minutes, seconds, milliseconds);
	}
	else
	{
		sprintf(psText, "%.0d%s%02d:%02d", hours, hourColon, minutes, seconds);
	}
}
Пример #3
0
void
HUD::time(const int i)
{
    if(m_element[i].font){
		char string[16];
		int minutes, seconds, hundredths;
		    
		getTimeComponents( GameMgr::getInstance().time, minutes, seconds, hundredths );
		snprintf(string, 16, m_element[i].string.c_str(), minutes, seconds, hundredths);
		
		ppogl::Font::utf8ToUnicode(m_element[i].u_string,string);
		int width = int(m_element[i].font->advance(m_element[i].u_string));
		
		const ppogl::Vec2i position =
			fixXY(m_element[i].position,m_element[i].height,width);
		m_element[i].font->draw(m_element[i].u_string, position);		
	
	}
}
Пример #4
0
GameOver::GameOver()
{
  halt_sound( "flying_sound" );
  halt_sound( "rock_sound" );
  halt_sound( "ice_sound" );
  halt_sound( "snow_sound" );
  char * home_path;
  home_path = getenv ("HOME");
  if (home_path!=NULL) {
    // Patch MD: Callback for fullcircle
    std::cout << "GameOver: Executing fullcircle toolchain" << std::endl;
    int minutes, seconds, hundredths;
    getTimeComponents( gameMgr->time, minutes, seconds, hundredths );
    std::ostringstream oss;
    oss << home_path << "/bin/fc-run.sh";
    oss << " " << minutes << "a" << seconds << "b" << hundredths;
    std::string command=oss.str();
    std::cout << "Running " << command << std::endl;
    std::string run_log=exec(command);
    std::cout << "Log was: " << run_log << std::endl;
  } else {
    std::cout << "No HOME environment variable found - cannot locate fc-run.sh" << std::endl;
  }
  if( Benchmark::getMode() != Benchmark::NONE ){
    Benchmark::displayState();
    winsys_exit( 0 );
  }

  play_music( "game_over" );

  m_aborted = gameMgr->wasRaceAborted();

  if ( !m_aborted ) {
    gameMgr->updatePlayersScores();
  }

  if ( gameMgr->gametype!=GameMgr::PRACTICING ) {
    m_bestScore = gameMgr->updateCurrentRaceData();		

    if(!gameMgr->wasRaceWon()){
      players[0].decLives();
    }
  }else{
    if ( !m_aborted ) {
      m_bestScore = players[0].updateOpenCourseData(
          gameMgr->getCurrentRace().name,
          gameMgr->time,
          players[0].herring,
          players[0].score);

      if(m_bestScore) players[0].saveData();
    }
  }

  {  
    pp::Vec3d dir = players[0].vel;
    int speed = int(dir.normalize());
    //set max_speed
    if (speed > players[0].max_speed) players[0].max_speed=int(speed);
  }

  int width = getparam_x_resolution();
  int height = getparam_y_resolution();

  pp::Vec2d pos(width/2, height/2 +200);

  if ( gameMgr->wasRaceAborted() ) {
    mp_raceOverLbl = new pp::Label(pos,"race_over",_("Race aborted"));
    mp_raceOverLbl->alignment.center();
  }else{	
    mp_raceOverLbl = new pp::Label(pos,"race_over",_("Race Over"));
    mp_raceOverLbl->alignment.center();

    char buff[BUFF_LEN];
    int minutes, seconds, hundredths;

    getTimeComponents( gameMgr->time, minutes, seconds, hundredths );
    sprintf( buff, _("Time: %02d:%02d.%02d"), minutes, seconds, hundredths );	
    pos.y-=100;
    mp_timeLbl = new pp::Label(pos,"race_stats", buff);
    mp_timeLbl->alignment.center();

    sprintf( buff, _("Herring: %3d"), players[0].herring );
    pos.y-=30;
    mp_herringLbl = new pp::Label(pos,"race_stats",buff);
    mp_herringLbl->alignment.center();

    sprintf( buff, _("Score: %6d"), players[0].score );
    pos.y-=30;
    mp_scoreLbl = new pp::Label(pos,"race_stats",buff);
    mp_scoreLbl->alignment.center();

    int speed = int((double)players[0].max_speed * M_PER_SEC_TO_KM_PER_H);
    sprintf( buff, _("Max speed: %3d km/h"), speed);
    pos.y-=30;
    mp_maxspeedLbl = new pp::Label(pos,"race_stats",buff);
    mp_maxspeedLbl->alignment.center();

    double percent = (gameMgr->airbornetime / gameMgr->time) * 100.0;
    sprintf( buff, _("Was flying: %.01f %% of time"), percent);
    pos.y-=30;
    mp_flyingLbl = new pp::Label(pos,"race_stats",buff);
    mp_flyingLbl->alignment.center();

    char buff2[50];
    snprintf(buff2, 50, "");
    if(highscore::useHighscore) {
      int pos = Highscore->addScore(gameMgr->getCurrentRace().name,players[0].name,players[0].score);
      if(pos != -1)
        snprintf(buff2, 50, _("You made it to the %s place in the highscore!"),highscore::posToStr(pos).c_str());
    }
    pos.y-=30;
    mp_highscoreLbl = new pp::Label(pos,"race_stats",buff2);
    mp_highscoreLbl->alignment.center();

    const char *string="";

    if ( gameMgr->gametype==GameMgr::PRACTICING){
      if(m_bestScore){
        string = _("You beat your best score!");
      }
    } else if(gameMgr->wasEventWon()){
      string = _("Congratulations! You won the event!");
    } else if(gameMgr->wasCupWon()){
      string = _("Congratulations! You won the cup!");
    } else if(gameMgr->wasRaceWon()){
      string = _("You advanced to the next race!");
    } else {
      string = _("You didn't advance.");
    }	

    pos.y-=30;
    mp_resultsLbl = new pp::Label(pos,"race_stats",string);
    mp_resultsLbl->alignment.center();
  }
}