PC Igrice (SFML-based)
Forum Tehnologija PC


Edy   19.05.2013 u 19:55

i za kraj da kažem da pravim jednu igricu sa nazivom Fire Racer GS polako ne žurim kad stignem kuckam malo ... evo vam odmah primjer, to je funkcija iz jedne klase koja prikazuje splash screen.. postavit ću igricu ako je ikad završim pored toga, bit će openSource :xD evo:
[code]
// odavde

int splashScreen::showSplash()
{ /* Displays the splash screen - can fade to a second image if needed */

/* create the window */
sf::RenderWindow window(sf::VideoMode(win_width,win_height), this->appName,0);
window.setFramerateLimit(20);

/* load the main image and create the sprites */
sf::Texture txtr1;
if(!txtr1.loadFromFile(this->PathToImg1))
{
MessageBox(NULL, "Could not open image file for splash screen!", NULL, 0);
return EXIT_FAILURE;
}
sf::Sprite sprite1(txtr1);

int alpha=255; // alpha start value for second image
sf::Sprite spriteFadeTo; // create the second sprite
sf::Texture gamelogo;

if(this->PathToImg2 !="") // if set, loads the second image
{ // and sets the sprite for it
if(!gamelogo.loadFromFile(this->PathToImg2))
{
MessageBox(NULL, "Could not open image file for splash screen!", NULL, 0);
return EXIT_FAILURE;
}
spriteFadeTo.setTexture(gamelogo);
}
sf:lock sahat; // creates a clock



/* SPLAHS LOOP */
while (window.isOpen())
{
sf::Time proslo =sahat.getElapsedTime();
window.clear();

if(this->PathToImg2 !="") // if set, fades to that image
{
sf:olor haa(255,255,255,alpha);
sprite1.setColor(haa);
window.draw(spriteFadeTo);

/* change the alpha value with every loop
so the image fades slowly away */
if(proslo.asSeconds()>=5)
{
if (alpha>18)
alpha-=18;
else
alpha=0;
}
}

if(proslo.asSeconds()>=18) // after 18 secs
return EXIT_SUCCESS; // stops the loop and ends the splash screen

window.draw(sprite1);
window.display(); // display the splash

} // end of Splash loop
return EXIT_SUCCESS;
}
//dovde
[/code]
prikaži ceo post
Ovo je zadnji post sa prethodne strane.
Edy Edy   19.05.2013 u 19:58

morao sam ovu zadnju funkciju da stavim u tag za php pošto ovaj drugi ne radi ovo zadnje je samo definicija metode showSplash() u klasi splashScreen neću da otkrivam previše za sada... PS ako ima neko iskustva nek me slobodno ispravi ili poboljša kod ;) nije nešto, početnik sam jbg a i nije se fino postavio, ljepše izgleda u IDEu
**N-e-k-s** **N-e-k-s**   21.05.2013 u 17:17

svaka čast Edy

Forum početna