1
General / sf::Sleep doesn't do it's job on SFML 2
« on: July 13, 2011, 12:16:57 pm »
I see. That's cool.
Thank you.
Thank you.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
#include <iostream>
////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main()
{
// Create main window
sf::RenderWindow App(sf::VideoMode(800, 600), "SFML Shapes");
// Clear screen
App.Clear();
// Draw predefined shapes
App.Draw(sf::Shape::Line(10, 10, 710, 100, 15, sf::Color::Red));
App.Draw(sf::Shape::Circle(200, 200, 100, sf::Color::Yellow, 10, sf::Color::Blue));
App.Draw(sf::Shape::Rectangle(350, 200, 600, 350, sf::Color::Green));
// Build a custom convex shape
sf::Shape Polygon;
Polygon.AddPoint(0, -50, sf::Color(255, 0, 0), sf::Color(0, 128, 128));
Polygon.AddPoint(50, 0, sf::Color(255, 85, 85), sf::Color(0, 128, 128));
Polygon.AddPoint(50, 50, sf::Color(255, 170, 170), sf::Color(0, 128, 128));
Polygon.AddPoint(0, 100, sf::Color(255, 255, 255), sf::Color(0, 128, 128));
Polygon.AddPoint(-50, 50, sf::Color(255, 170, 170), sf::Color(0, 128, 128));
Polygon.AddPoint(-50, 0, sf::Color(255, 85, 85), sf::Color(0, 128, 128));
// Disable filling and enable the outline
Polygon.EnableFill(false);
Polygon.EnableOutline(true);
// We can still use the functions common to all SFML drawable objects
Polygon.SetColor(sf::Color(255, 255, 255, 200));
Polygon.Move(300, 300);
Polygon.Scale(3, 2);
Polygon.Rotate(45);
// Draw it
App.Draw(Polygon);
// Finally, display the rendered frame on screen
App.Display();
return EXIT_SUCCESS;
}
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow App(sf::VideoMode(800,600),"lala");
App.UseVerticalSync(true);
sf::Event Event;
sf::Image Image;
Image.LoadFromFile("E:/again_i_try_to/test/bin/Debug/x.bmp");
sf::Sprite Sprite;
Sprite.SetImage(Image);
while(App.IsOpened())
{
while(App.GetEvent(Event))
{
if((Event.Type== sf::Event::KeyPressed) && (Event.Key.Code==sf::Key::Escape))
App.Close();
if(Event.Type==sf::Event::Closed)
App.Close();
}
App.Clear(sf::Color(120,21,34));
Sprite.SetPosition(Event.MouseMove.X,Event.MouseMove.Y);
App.SetCursorPosition(100,100);
App.Draw(Sprite);
App.Display();
}
return EXIT_SUCCESS;
}
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow App(sf::VideoMode(600,300),"test");
sf::Image Image;
Image.LoadFromFile("lol.JPG");
const sf::Input& Input = App.GetInput();
sf::Sprite Sprite(Image);
sf::Event Event;
while (App.IsOpened())
{
/*
while (App.GetEvent(Event))
{
if (Event.Type==sf::Event::Closed)
App.Close();
if ((Event.Type==sf::Event::KeyPressed) && (Event.Key.Code==sf::Key::D))
Sprite.Move(1.5,0);
}
*/
bool Rechts = Input.IsKeyDown(sf::Key::Right);
if(Rechts)
Sprite.Move(1.5,0);
App.Clear(sf::Color(231,32,111));
App.Draw(Sprite);
App.Display();
}
return 0;
}