6
« on: March 21, 2010, 05:30:00 pm »
not a problem at all .. the below is the code ..
#include <SFML/Graphics.hpp>
#include<SFML/Audio.hpp>
#include<iostream>
int main()
{
// Create the main window
sf::RenderWindow App(sf::VideoMode(640, 480), "Rahul.Reincarnated ");
// Load a sprite to display
sf::Image Image;
if (!Image.LoadFromFile("image2.png"))
return EXIT_FAILURE;
sf::Sprite Sprite(Image);
// Adding some music to program
sf::Music Music;
if (!Music.OpenFromFile("hydrate.ogg"))
return EXIT_FAILURE;
// Create a graphical string to display
sf::Font Arial;
if (!Arial.LoadFromFile("arial.ttf"))
return EXIT_FAILURE;
sf::String Text("\t \t \t \t \t \t \t \t \t \t OpenGL Project \n \t \t \t \t \t \t \t \t By Rahul & Pooja ", Arial, 50);
// Play it
Music.Play();
const int SCROLL_SPEED = 20; // rendering 20 pixesl per second
Text.SetY(40); // text positions is above the screen
// std::cout<< Text.GetPosition();
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
App.Close();
}
// Clear screen
App.Clear();
// Draw the sprite
App.Draw(Sprite);
// Draw the string
App.Draw(Text);
// Increase Y Axis to move down
Text.Move( 0 ,App.GetFrameTime() * SCROLL_SPEED) ;
//Text.Move ( 10,100);
if( Text.GetPosition().y > 400 )
Text.SetPosition( 0.f, 10 );
// Update the window
App.Display();
// Loop while the music is playing
}
std::cout<<" thank you for using the program ";
getchar();
return EXIT_SUCCESS;
}