コード例 #1
0
ファイル: FontHandler.cpp プロジェクト: ItsJackson/gqe
  bool FontHandler::LoadFromMemory(const typeAssetID theAssetID, sf::Font& theAsset)
  {
    // Start with a return result of false
    bool anResult = false;

    // TODO: Retrieve the const char* pointer to load data from
    const char* anData = NULL;
    // TODO: Retrieve the size in bytes of the font to load from memory
    size_t anDataSize = 0;
    // TODO: Retrieve the character size for this font
    unsigned int anCharSize = 30;

    // Try to obtain the font from the memory location specified
    if(NULL != anData && anDataSize > 0)
    {
      // Load the font from the memory location specified
#if (SFML_VERSION_MAJOR < 2)
      anResult = theAsset.LoadFromMemory(anData, anDataSize, anCharSize);
#else
      anResult = theAsset.loadFromMemory(anData, anDataSize);
#endif
    }
    else
    {
      ELOG() << "FontHandler::LoadFromMemory(" << theAssetID
        << ") Bad memory location or size!" << std::endl;
    }

    // Return anResult of true if successful, false otherwise
    return anResult;
  }
コード例 #2
0
ファイル: Player.cpp プロジェクト: khaiduk/rogalik
void Player::drawAtributes(sf::RenderWindow& rw) const
{
	static bool firstRun = true;
	static sf::Image tlo;
	static sf::Font font;
	if(firstRun)
	{
		tlo.LoadFromFile("Images/tlo.png");
		firstRun = false;
		font.LoadFromFile("silesiana.otf", 50,  L"A�BC�DE�FGHIJKL�MN�O�PRS�TUWYZ��a�bc�de�fghijkl�mn�o�prs�tuwyz��XxVvQq0123456789~!@#$%^&*()_-[]\\;',./{}:\"<>?=-+ ");
	}
	sf::Sprite tloH(tlo);
	rw.Draw(tloH);
	
	std::wstringstream ss;
	if(selectedAttribute == 0)
	{
		ss << L"Exp: " << xp << L"\n";
		ss << L"> Poziom obrony: " << defLevel << L"\n";
		ss << L"Poziom ataku: " << attLevel << L"\n";
	}
	else
	{
		ss << L"Exp: " << xp << L"\n";
		ss << L"Poziom obrony: " << defLevel << L"\n";
		ss << L"> Poziom ataku: " << attLevel << L"\n";
	}
	sf::String t(ss.str(), font, 30.f);
	t.SetColor(sf::Color(20, 18, 160));
	t.SetPosition(20.f, 20.0);
	rw.Draw(t);
}
コード例 #3
0
ファイル: Drawing.cpp プロジェクト: Monsterovich/SLADE
/* FontManager::initFonts
 * Loads all needed fonts for rendering. SFML 2.x implementation
 *******************************************************************/
int FontManager::initFonts()
{
	// --- Load general fonts ---
	int ret = 0;

	// Normal
	ArchiveEntry* entry = theArchiveManager->programResourceArchive()->entryAtPath("fonts/dejavu_sans.ttf");
	if (entry) ++ret, font_normal.loadFromMemory((const char*)entry->getData(), entry->getSize());

	// Condensed
	entry = theArchiveManager->programResourceArchive()->entryAtPath("fonts/dejavu_sans_c.ttf");
	if (entry) ++ret, font_condensed.loadFromMemory((const char*)entry->getData(), entry->getSize());

	// Bold
	entry = theArchiveManager->programResourceArchive()->entryAtPath("fonts/dejavu_sans_b.ttf");
	if (entry) ++ret, font_bold.loadFromMemory((const char*)entry->getData(), entry->getSize());

	// Condensed Bold
	entry = theArchiveManager->programResourceArchive()->entryAtPath("fonts/dejavu_sans_cb.ttf");
	if (entry) ++ret, font_boldcondensed.loadFromMemory((const char*)entry->getData(), entry->getSize());

	// Monospace
	entry = theArchiveManager->programResourceArchive()->entryAtPath("fonts/dejavu_mono.ttf");
	if (entry) ++ret, font_small.loadFromMemory((const char*)entry->getData(), entry->getSize());

	return ret;
}
コード例 #4
0
ファイル: Player.cpp プロジェクト: khaiduk/rogalik
void Player::drawHud(sf::RenderWindow& rw) const
{
	static bool firstRun = true;
	static sf::Font font;
	if(firstRun) 
	{
		firstRun = false;
		font.LoadFromFile("silesiana.otf", 50,  L"A�BC�DE�FGHIJKL�MN�O�PRS�TUWYZ��a�bc�de�fghijkl�mn�o�prs�tuwyz��XxVvQq0123456789~!@#$%^&*()_-[]\\;',./{}:\"<>?=-+ ");
	}

	sf::Sprite hud(hudimg, sf::Vector2f(0, 350));
	rw.Draw(hud);

	int hbarheight= health * hbarimg.GetHeight();
	sf::Sprite hbar(hbarimg, sf::Vector2f(42, 376 + hbarimg.GetHeight() - hbarheight));
	hbar.SetSubRect(sf::IntRect(0, hbarimg.GetHeight() - hbarheight, hbarimg.GetWidth(), hbarimg.GetHeight()));
	rw.Draw(hbar);

	std::wstring str;
	for(int i=0;i<4;i++)
	{
		if(i<msgList.size())
		str += msgList[i] + L"\n";
	}
	sf::String msgs(str, font, 30);
	msgs.SetColor(sf::Color(120, 10, 10));
	msgs.SetPosition(200, 450);
	rw.Draw(msgs);
}
コード例 #5
0
ファイル: FontHandler.cpp プロジェクト: ItsJackson/gqe
  bool FontHandler::LoadFromFile(const typeAssetID theAssetID, sf::Font& theAsset)
  {
    // Start with a return result of false
    bool anResult = false;

    // Retrieve the filename for this asset
    std::string anFilename = GetFilename(theAssetID);

    // Was a valid filename found? then attempt to load the asset from anFilename
    if(anFilename.length() > 0)
    {
      // Load the asset from a file
#if (SFML_VERSION_MAJOR < 2)
      anResult = theAsset.LoadFromFile(anFilename);
#else
      anResult = theAsset.loadFromFile(anFilename);
#endif
    }
    else
    {
      ELOG() << "FontHandler::LoadFromFile(" << theAssetID
        << ") No filename provided!" << std::endl;
    }

    // Return anResult of true if successful, false otherwise
    return anResult;
  }
コード例 #6
0
	const sf::Font& ResourceManager::getDefaultFont() {
		static sf::Font font;
		static bool loaded = false;

		if (!loaded)
		{
			static const signed char data[] =
					{
#include "Arial.hpp"
					};
			font.loadFromMemory(data, sizeof(data));
			loaded = true;
		}
		return font;
	}
コード例 #7
0
ファイル: hud.cpp プロジェクト: dho1/Project
void * init () 
{
    sf::Clock sclock;
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");

    char * font_path;
    find_font( &font_path );

    if (!MyFont.loadFromFile(font_path)) 
    {
        printf("error loading font\n");
    }

    setup();
    draw_hud();

    for (int i = 1; i < 6; i++)
        add_slot(i);

    while (window.isOpen()) 
    {
        update(window, sclock);
    }
    return NULL;
}
コード例 #8
0
ファイル: Main.cpp プロジェクト: minhoolee/id-Tech-Files
	Pong() : gameWindow(sf::VideoMode(600, 480), "Pong")
	{
		ball.setFillColor(sf::Color::Cyan);
		ball.setPosition(100.0, 100.0);
		ball.setRadius(10.f);

		p1Paddle.setFillColor(sf::Color::Green);
		p1Paddle.setPosition(10.0, 100.0);
		p1Paddle.setSize(sf::Vector2f(10.0, 100.0));

		p2Paddle.setFillColor(sf::Color::Red);
		p2Paddle.setPosition(580.0, 100.0);
		p2Paddle.setSize(sf::Vector2f(10.0, 100.0));

		p1MovingUp = false;
		p1MovingDown = false;
		p2MovingUp = false;
		p2MovingDown = false;

		ballMovement = sf::Vector2f(ballSpeed, ballSpeed);
		font.loadFromFile("arial.ttf");

		p1ScoreText.setPosition(150, 10);
		p1ScoreText.setFont(font);
		p1ScoreText.setString(std::to_string(p1Score));
		p1ScoreText.setColor(sf::Color::Red);
		p1ScoreText.setCharacterSize(24);

		p2ScoreText.setPosition(450, 10);
		p2ScoreText.setFont(font);
		p2ScoreText.setString(std::to_string(p2Score));
		p2ScoreText.setColor(sf::Color::Red);
		p2ScoreText.setCharacterSize(24);
	}
コード例 #9
0
ファイル: scoring.cpp プロジェクト: vsrz/VHH
void Scoring::Initialize()
{
	font.loadFromFile("./Resources/Fonts/jokerman.ttf");
	points_graphics.setFont(font);
	points_graphics.setCharacterSize(24);
	points_graphics.setString("0");
}
コード例 #10
0
ファイル: main.cpp プロジェクト: amoshyc/sfml-snake
    void init() {
        this->restart();
        // RectangleShapes
        sf::Vector2f unit(unit_w, unit_h);
        stone_view = sf::RectangleShape(unit);
        stone_view.setFillColor(sf::Color(255, 81, 68));
        body_view = sf::RectangleShape(unit);
        body_view.setFillColor(sf::Color(0, 204, 255));
        food_view = sf::RectangleShape(unit);
        food_view.setFillColor(sf::Color(19, 169, 136));

        // font & msg
        if (!font.loadFromFile("Inconsolata-Bold.ttf")) {
            puts("fonts loading error!");
            this->close();
        }
        msg1.setFont(font);
        msg1.setColor(sf::Color::White);
        msg1.setCharacterSize(50);
        msg1.setPosition(80, 100);
        msg2.setFont(font);
        msg2.setColor(sf::Color::White);
        msg2.setCharacterSize(25);
        msg2.setString("Press <Enter> to Replay");
        msg2.setPosition(60, 250);
    }
コード例 #11
0
ファイル: Param.cpp プロジェクト: Neckara/Patcher
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);
}
コード例 #12
0
ファイル: ColoredText.cpp プロジェクト: shtgames/GUI-lib
	void ColoredText::getText(unique_ptr_vector<sf::Text>& target, const sf::Font& font, const unsigned char characterSize)const
	{
		const float TEXT_HEIGHT(font.getLineSpacing(characterSize) + LINE_SPACING);
		sf::Vector2f addPosition(0, 0);
		target.clear();

		getText(target, font, characterSize, TEXT_HEIGHT, addPosition);
	}
コード例 #13
0
void rendering::render_time(sf::RenderWindow& screen,const GameInfo& stats)
{
   static sf::Text text;
   static sf::Font f;

   f.loadFromFile("../data/Font/Loma.ttf");

   text.setFont(f);
   text.setColor(sf::Color::Red);
   text.setCharacterSize(24);
   text.setPosition(700,100);
   text.setString(stats.GetFormattedElapsed());
   screen.draw(text);

   text.setString(std::to_string(stats.getFps()));
   text.setPosition(700,125);
   screen.draw(text);
}
コード例 #14
0
ファイル: menu.cpp プロジェクト: TarasJan/Sleepwalker
	virtual void init()
	
	
	{
		dt=0;
		select_switch = 0.2;
		
		if (!standard_font.loadFromFile("fonts/Unique.ttf"))
{
    // error...
}
	//	darken = sf::RectangleShape(sf::Vector2f(800,400));
		
//sfx
if (!buffer.loadFromFile("sfx/Blip 007.wav"))

{
     //error
}
blip.setBuffer(buffer);


		if(!title.loadFromFile("gfx/title.png"))std::cout<<"Error"<<std::endl;

		t**s.setTexture(title);
		t**s.setOrigin(50,8);
		t**s.setScale(sf::Vector2f(3,3));
		t**s.setPosition(400,100);
		
		sf::FloatRect tempt ;
		
		for(int i =0 ; i<4;i++)
		{
			selector[i].setFont(standard_font);
			selector[i].setCharacterSize(28);
			 
		
		// dla centrowania obiektow
		
			tempt = selector[i].getGlobalBounds();
			selector[i].setOrigin(sf::Vector2f(tempt.width/2,tempt.height/2));
			
			selector[i].setPosition(350,150+30*i);
		}
		
		selector[0].setString("Start game");
		selector[1].setString("Info");
		selector[2].setString("Highscores");
		selector[3].setString("Exit");
		
		
		selector[0].setColor(sf::Color(0,127,127));
		
		timer.restart();
		
		};
コード例 #15
0
ファイル: GI.cpp プロジェクト: LEiden94/No-Man-Left-Behind
	bool initalize(sf::RenderWindow*& rw){
		//renderWindow = rw = new sf::RenderWindow(sf::VideoMode(1920, 1080, 32), "SFML", sf::Style::Fullscreen);
		renderWindow = rw = new sf::RenderWindow(sf::VideoMode(1280, 720, 32), "NMLB");
		drawCalls = frameCount = 0;

		cameraX = TARGET_WIDTH / 2;
		cameraY = TARGET_HEIGHT / 2;
		cameraZ = 1.0f;

		return menuFont.loadFromFile(c::fontDir.child("Arial.ttf").path());
	}
コード例 #16
0
ファイル: WindowCreateThing.hpp プロジェクト: 3991/Game-25486
int WindowCreateThing::load() {
    if(!font.loadFromFile("arial.ttf")){
        std::cerr << "Error loading arial.png" << std::endl;
        return (-1);
    }

    if(!textureFolder.loadFromFile("folder.png")) {
        std::cerr << "Error loading folder.png" << std::endl;
        return (-1);
    }
    return 0;
}
コード例 #17
0
namespace OstrichRiders
{
	static sf::Font defFont;
	static bool init = true;

#ifdef __linux__
	std::string FindDefaultFont()
	{
		std::string answer("/usr/share/fonts/liberation/LiberationSans-Regular.ttf");
		FcFontSet	*fs;
		FcPattern   *pat;
		FcResult	result;
		if (!FcInit())
		{
			return answer;
		}
		pat = FcNameParse((FcChar8 *)"LiberationSans-Regular.ttf");
		FcConfigSubstitute(0, pat, FcMatchPattern);
		FcDefaultSubstitute(pat);

		fs = FcFontSetCreate();
		FcPattern   *match;
		match = FcFontMatch(0, pat, &result);
		if (match)
		{
			FcChar8 *file;
			if (FcPatternGetString(match, FC_FILE, 0, &file) == FcResultMatch)
			{
				answer = (const char *)file;
			}
			FcPatternDestroy(match);
		}
		FcPatternDestroy(pat);
		FcFini();
		return answer;
	}
#endif

	sf::Font &GetDefaultFont()
	{
		if (init)
		{
			bool success = defFont.loadFromFile(JOUST_FONT);
			if (!success)
			{
				printf("Failed to load font %s\n", JOUST_FONT);
				exit(1);
			}
			init = false;
		}
		return defFont;
	}
}
コード例 #18
0
ファイル: jabs.cpp プロジェクト: TarasJan/Sleepwalker
	virtual void init()
	
	
	{
		dt=0;
		
		
		if (!standard_font.loadFromFile("fonts/Unique.ttf"))
{
    // error...
}
		darken = sf::RectangleShape(sf::Vector2f(800,400));
		

		
		tit.setFont(standard_font); 


		tit.setString("Made by");

		explain.setFont(standard_font);
		explain.setString("Just a bored slacker");
		explain.setCharacterSize(36);
		explain.setPosition(260,320);

		tit.setCharacterSize(24);

		
		// dla centrowania obiektow
		
		sf::FloatRect tempt = tit.getGlobalBounds();

		
		tit.setOrigin(sf::Vector2f(tempt.width/2,tempt.height/2));

		
		tit.setPosition(400,120);


if (!tex.loadFromFile("gfx/jabslogo.png"))
	
	{
		std::cout<<"Fuckup"<<std::endl;
		}

		spr.setTexture(tex);
		spr.setPosition(334,144);

		
		timer.restart();
		
		};
コード例 #19
0
	void set_font()
	{
		
		assert(m_file_name != "");
		
		if (!m_font.loadFromFile(m_file_name))
		{
				
			std::cout << m_file_name << " not found!\n";
				
		}
		 
	}
コード例 #20
0
void initTexts()
{
    if (!font.loadFromFile("arial.ttf"))cout << "error";
    endText.setFont(font);
    endText.setString("Game Over");
    endText.setCharacterSize(50);
    endText.setColor(sf::Color( 156, 39, 176));
    endText.setPosition(SIZE/2-100,SIZE/2-100);
    scoreText.setFont(font);
    scoreText.setCharacterSize(50);
    scoreText.setColor(sf::Color(255,255,255));
    scoreText.setPosition(SIZE/2-200,SIZE/2);
}
コード例 #21
0
ファイル: observer.hpp プロジェクト: xeloni/ProjetsClion
	// Constructeur & destructeur
	Observer(const sf::Vector2f& center)
	{
		//sf::Font font;
		assert(_font.loadFromFile("vera.ttf") == true);
		_text.setColor(sf::Color::White);
		_text.setFont(_font);
		_text.setCharacterSize(50);
		_text.setStyle(sf::Text::Italic);
		_border.setPosition(center);
		_border.setOutlineColor(sf::Color::White);
		_border.setOutlineThickness(2.0);
		_border.setFillColor(sf::Color::Transparent);
	}
コード例 #22
0
ファイル: wingame.cpp プロジェクト: TarasJan/Sleepwalker
	virtual void init()
	
	
	{
		dt=0;
		
		
		if (!standard_font.loadFromFile("fonts/Unique.ttf"))
{
    // error...
}
		darken = sf::RectangleShape(sf::Vector2f(800,400));
		

		
		tit.setFont(standard_font); 
		score.setFont(standard_font); 

		std::stringstream ss;
		ss << your_score;
		std::string str = ss.str();
		
		
		tit.setString("Congrats! You beat the game\nIt took you:");
		
		score.setString(str + " seconds");


		tit.setCharacterSize(24);
		score.setCharacterSize(24);

		
		// dla centrowania obiektow
		
		sf::FloatRect tempt = tit.getGlobalBounds();
		sf::FloatRect tempr = score.getGlobalBounds();

		
		tit.setOrigin(sf::Vector2f(tempt.width/2,tempt.height/2));
		score.setOrigin(sf::Vector2f(tempr.width/2,tempr.height/2));

		
		tit.setPosition(400,150);
		score.setPosition(400,200);

		score.setColor(sf::Color(0,127,127));

		
		timer.restart();
		
		};
コード例 #23
0
ファイル: Renderer.cpp プロジェクト: spacechase0/SFGUI
sf::Vector2f Renderer::LoadFont( const sf::Font& font, unsigned int size, sf::Color background_color_hint, sf::Color foreground_color_hint ) {
	// Get the font face that Laurent tries to hide from us.
	struct FontStruct {
		void* font_face; // Authentic SFML comment: implementation details
		void* unused1;
		int* unused2;

		// Since maps allocate everything non-contiguously on the heap we can use void* instead of Page here.
		mutable std::map<unsigned int, void*> unused3;
		mutable std::vector<sf::Uint8> unused4;
	};

	void* face;

	// All your font face are belong to us too.
	memcpy( &face, reinterpret_cast<const char*>( &font ) + sizeof( sf::Font ) - sizeof( FontStruct ), sizeof( void* ) );

	FontID id( face, size );

	std::map<FontID, sf::Vector2f>::iterator iter( m_font_offsets.find( id ) );

	if( iter != m_font_offsets.end() ) {
		return iter->second;
	}

	// Make sure all the glyphs we need are loaded.
	for( sf::Uint32 codepoint = 0; codepoint < 512; ++codepoint ) {
		font.getGlyph( codepoint, size, false );
	}

	sf::Image image = font.getTexture( size ).copyToImage();

	sf::Vector2f offset = LoadImage( image, background_color_hint, foreground_color_hint, true );

	m_font_offsets[id] = offset;

	return offset;
}
コード例 #24
0
ファイル: Presentation.hpp プロジェクト: 3991/Game-25486
void Presentation::drawIntro(sf::RenderWindow &window){
     sf::Font ibm;
    sf::Font font;
    if (!ibm.loadFromFile("ibm.ttf")) {
        std::cerr << "Error loading ibm.ttf" << std::endl;
        //return (-1);
    }
    sf::Text textTitleIntro;
    textTitleIntro.setFont(ibm);
    textTitleIntro.setString("HELLO");
    textTitleIntro.setCharacterSize(100);
    textTitleIntro.setColor(sf::Color::White);
    textTitleIntro.setOrigin(textTitleIntro.getLocalBounds().left+textTitleIntro.getLocalBounds().width/2.0f, textTitleIntro.getLocalBounds().top+textTitleIntro.getLocalBounds().height/2.0f);
    textTitleIntro.setPosition(window.getSize().x/2, textTitleIntro.getLocalBounds().height/1.5f);


   window.draw(textTitleIntro);


    TCHAR nameBuf[MAX_COMPUTERNAME_LENGTH + 2];
    DWORD nameBufSize;

    nameBufSize = sizeof nameBuf - 1;
    if (GetUserName(nameBuf, &nameBufSize) == TRUE) {
    //_tprintf(_T("Your computer name is %s\n"), nameBuf);
    }
    //std::cout << nameBuf << std::endl;
    strcpy (str,"HELLO (C) ");
    strcat (str,nameBuf);

    if (!font.loadFromFile("arial.ttf")) {
        std::cerr << "Error loading arial.ttf" << std::endl;
        //return (-1);
    }
    sf::Text textSubTitleIntro;
    textSubTitleIntro.setFont(font);
    textSubTitleIntro.setString(str);
    textSubTitleIntro.setCharacterSize(25);
    textSubTitleIntro.setColor(sf::Color::White);
    textSubTitleIntro.setPosition(20, window.getSize().y/2);
    window.draw(textSubTitleIntro);

    sf::Text textContinueIntro;
    textContinueIntro.setFont(font);
    textContinueIntro.setString("Space to continue or Esc to cancel");
    textContinueIntro.setCharacterSize(25);
    textContinueIntro.setColor(sf::Color::White);
    textContinueIntro.setPosition(20, window.getSize().y/3);
    window.draw(textContinueIntro);
}
コード例 #25
0
	sf::Font &GetDefaultFont()
	{
		if (init)
		{
			bool success = defFont.loadFromFile(JOUST_FONT);
			if (!success)
			{
				printf("Failed to load font %s\n", JOUST_FONT);
				exit(1);
			}
			init = false;
		}
		return defFont;
	}
コード例 #26
0
ファイル: CircleSphere.cpp プロジェクト: ahinh93/Programs
void init()
{
    int major,minor;
    v.getOpenGLVersion(&major,&minor);

    cout <<"Opengl version supported : "<<major<<"."<<minor<<endl;
    v.getGLSLVersion(&major,&minor);
    cout << "GLSL version supported : "<<major<<"."<<minor << endl;
    //delegate to our view class to do all the initializing
    v.initialize();

	if (!font.loadFromFile("resources/GARA.ttf"))
		return;

}
コード例 #27
0
ファイル: main.cpp プロジェクト: cyclohexanamine/shipbrain
	int init()
	{
		scrw = 800; scrh = 600;
		mouse_wheel = 0;
		
		window = new sf::RenderWindow(sf::VideoMode(scrw, scrh), "thing");
		window->setVerticalSyncEnabled(true);
		
		view = new sf::View(sf::FloatRect(-40, 30, 80, -60));
		noview = new sf::View(sf::FloatRect(0, 0, scrw, scrh));
		window->setView(*view);
		
		arial.loadFromFile("arial.ttf");
		
		return 0;
	}
コード例 #28
0
ファイル: VN_1.0.cpp プロジェクト: rmxhaha/phantasia
	void init_char_width(){
		if (!PTSANS.loadFromFile("PTN57F.ttf" )) return;
		PTSANS_loaded = true;

		string tq;
		
		int tmp = log_string.getPosition().x;
		
		for( int i = 255; i--; ){
			tq = (char) i;
			log_string.setString( tq );
			char_width[i] = log_string.findCharacterPos( 1 ).x - tmp;
		}


	}
コード例 #29
0
ファイル: GameManager.cpp プロジェクト: Keruto/Breakfree
int main()
{
	window.create(sf::VideoMode(800, 600), "Breakfree");
	window.setVerticalSyncEnabled(true);
	//, sf::Style::Close|sf::Style::Titlebar);
	
	if (!font.loadFromFile("Nirmala.ttf"))
		return EXIT_FAILURE;

	Levels lv;
	Paddle pad;
	InputManager input;
	
	while (window.isOpen())
	{
		switch (level)
		{
		case 0:
			lv.loadLv0();
			break;
		}
		while (playing)
		{
			input.ExecuteEvents(window);
			
			pad.Update();
			

			window.clear(); // ------draw graphics here-------

			sf::Text text("Score: " + std::to_string(score), font, 20);
			text.setPosition(660, 220);
			window.draw(text);

			lv.Draw(window);

			window.draw(pad.sprite);
			window.draw(pad.ball);

			window.display(); // -----------------------
		}
	}

	return 0;
}
コード例 #30
0
ファイル: hud.hpp プロジェクト: K0teu/Squares-War
        hud()
        {
            tex_paskaHp[ 0 ].loadFromFile( "gfx/pasek_hpTlo.png" );
            tex_paskaHp[ 1 ].loadFromFile( "gfx/pasek_hp.png" );
            tex_paskaBonusu[ 0 ].loadFromFile( "gfx/pasek_bonusTlo.png" );
            tex_paskaBonusu[ 1 ].loadFromFile( "gfx/pasek_bonus.png" );
            spr_paskaHp.setTexture( tex_paskaHp[ 0 ] );
            spr_paskaBonusu.setTexture( tex_paskaBonusu[ 0 ] );
            tex_tla.loadFromFile( "gfx/tlo0.png" );
            czcionka.loadFromFile( "font/Barme Reczny.ttf" );
            tekst.setFont( czcionka );
            tekst.setCharacterSize( 18 );
            timer[ 0 ] = 0;
            timer[ 1 ] = 0;
            typ_bonusu = 0;
            alphaPaskaBonusu = 0.0001;
//            spr_paskaBonusu.setColor( sf::Color( 255, 255, 255, alphaPaskaBonusu ) );
        }