0 Members and 1 Guest are viewing this topic.
#include <SFML/Graphics.hpp>int main(){ // Create the main window sf::RenderWindow window(sf::VideoMode(800, 600, 32), "SFML Test"); sf::Color red(255, 0, 0, 255); sf::Shape line; line.Line(0, 0, window.GetWidth(), window.GetHeight(), 5, red); sf::Shape rectangle; rectangle.Rectangle(100, 100, window.GetWidth() - 200, window.GetHeight() - 200, red); sf::Shape polygon; float cx = window.GetWidth() * 0.5f; polygon.AddPoint(cx - 1, 0, red); polygon.AddPoint(cx + 1, 0, red); polygon.AddPoint(cx + 1, window.GetHeight() * 1, red); polygon.AddPoint(cx - 1, window.GetHeight() * 1, red); while (window.IsOpened()) { // Process events sf::Event Event; while (window.PollEvent(Event)) { // Close window if (Event.Type == sf::Event::KeyPressed && Event.Key.Code == sf::Keyboard::Escape) window.Close(); if (Event.Type == sf::Event::Closed) window.Close(); } // Clear screen window.Clear(); window.Draw(line); window.Draw(rectangle); window.Draw(polygon); // Update the window window.Display(); } return 0;}
line = sf::Shape::Line(0, 0, App.GetWidth(), App.GetHeight(), 5, red);rectangle = sf::Shape::Rectangle(100, 100, App.GetWidth() - 200, App.GetHeight() - 200, red);
#include <SFML/Graphics.hpp>int main(){ // Create the main window sf::RenderWindow window(sf::VideoMode(800, 600, 32), "SFML Test"); sf::Shape line = sf::Shape::Line(0, 0, window.GetWidth(), window.GetHeight(), 5, sf::Color::Red); sf::Shape rectangle = sf::Shape::Rectangle(200, 200, window.GetWidth() - 400, window.GetHeight() - 400, sf::Color::Green); sf::Shape circle = sf::Shape::Circle(window.GetWidth() / 2, window.GetHeight() / 2, window.GetHeight() / 5, sf::Color::Blue); sf::Shape polygon; float cx = window.GetWidth() * 0.5f; polygon.AddPoint(cx - 1, 0, sf::Color::White); polygon.AddPoint(cx + 1, 0, sf::Color::White); polygon.AddPoint(cx + 1, window.GetHeight() * 1, sf::Color::White); polygon.AddPoint(cx - 1, window.GetHeight() * 1, sf::Color::White); while (window.IsOpened()) { // Process events sf::Event Event; while (window.PollEvent(Event)) { // Close window if (Event.Type == sf::Event::KeyPressed && Event.Key.Code == sf::Keyboard::Escape) window.Close(); if (Event.Type == sf::Event::Closed) window.Close(); } // Clear screen window.Clear(); // Draw objects window.Draw(line); window.Draw(rectangle); window.Draw(circle); window.Draw(polygon); // Update the window window.Display(); } return 0;}
sf::Shape Line = sf::Shape::Line(X1, Y1, X2, Y2, Thickness, Color, [Outline], [OutlineColor]);sf::Shape Circle = sf::Shape::Circle(X, Y, Radius, Color, [Outline], [OutlineColor]);sf::Shape Rect = sf::Shape::Rectangle(X1, Y1, X2, Y2, Color, [Outline], [OutlineColor]);