Example #1
0
void drawScore(sf::RenderWindow& App, Player* player, sf::String& KillCount, 
               sf::String& Timer, sf::String& HP, sf::String& Score, int running_time)
{
    std::stringstream kill, s2, s3, s4;
    kill << player->getKill();

    KillCount.SetText("Kills: " + kill.str());
    App.Draw(KillCount);

    s2 << (int)running_time;
    std::string time_string;
    s2 >> time_string;      

    Timer.SetText("Time: " + time_string);
    App.Draw(Timer);

    s3 << player->getHealth()/100;
    std::string hp_string;
    s3 >> hp_string;

    HP.SetText("HP: " + hp_string);
    App.Draw(HP);

    s4 << player->getKill() + (int)running_time;
    std::string score_string;
    s4 >> score_string;

    Score.SetText("Score: " + score_string);
}
Example #2
0
void Param::lire_Texte(std::ifstream &fichier, sf::String &destination, sf::Font &myFont)
{
    std::string ligne;
    int x, y, z;
    lire_string(fichier, ligne);
    destination.SetText(traduire(ligne.c_str()));
    lire_position(fichier, x, y);
    destination.SetPosition(x, y);
    lire_string(fichier, ligne);
    if(ligne != "default" && !myFont.LoadFromFile(ligne))
    {
        std::cerr << "Erreur lors du chargement de la police '" << ligne << "'" << std::endl;
        myFont = sf::Font::GetDefaultFont();
    }
    else if(ligne == "default")
        myFont = sf::Font::GetDefaultFont();
    lire_int(fichier, x);
    destination.SetSize(x);
    lire_string(fichier, ligne);
    set_police(destination, ligne.c_str());
    lire_couleur(fichier, x, y, z);
    destination.SetColor(sf::Color(x, y, z));
    lire_int(fichier, x);
    destination.SetRotation(x);
}
Example #3
0
    void    InfoBox::draw(sf::RenderWindow& rw)
    {
        glColor3f(0.6, 0.6, 0.6);
        drawRectangle(start_, end_, true);

        static sf::String tx;
        tx.SetText("Status");
        tx.SetFont(sf::Font::GetDefaultFont());
        tx.SetStyle(sf::String::Bold);
        tx.SetPosition(start_[0] + 20, start_[1] + 20);
        tx.SetSize(16);
        rw.Draw(tx);
    }
Example #4
0
int main(){
	string tq;

	for( int i = 255; i--; ){
		tq = (char) i;
		log_string.SetText( sf::Unicode::Text( tq ) );
		char_width[i] = log_string.GetCharacterPos( 1 ).x;
	}


	sf::RenderWindow App(sf::VideoMode( WINDOW_WIDTH, WINDOW_HEIGHT ), "VN System");
	App.SetFramerateLimit(20); //max FPS

	log_setup_1();

	int log_index = 0;
	sf::Event Event;


	vector<_Log> logs;
	load_text_file( logs, "Text.txt");

//	for( int i = 0; i < logs.size() ; ++ i ){
		// cout << logs[i].image_path << endl;
		// cout << logs[i].sound_path << endl;
		// cout << logs[i].name << endl;
		// cout << logs[i].text << endl;
		// cin.get();
//	}


	while (App.IsOpened()){
		while (App.GetEvent(Event)){
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();
			if( Event.Type == sf::Event::KeyPressed ){
				if( Event.Key.Code == sf::Key::Return ){
					if( log_index < logs.size()-1 ) {
						if( logs[ log_index ].image_path != logs[ log_index + 1 ].image_path ){
							VNImageManager.delete_image( logs[ log_index ].image_path );
						}

						log_index++;
					}
				}
			}
        }


		App.Clear( sf::Color( 0,0,0 ) );

		logs[ log_index ].draw( App );

		App.Display();

	}


	return 0;
}