16
General discussions / Re: Goodbye
« on: May 13, 2019, 09:52:56 pm »
I'd like to echo the thanks for all of the work that you've put into SFML. You've helped make this project one of the best open source projects in existence.
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.
#include <iostream>
#include <string>
#include <SFML/Graphics.hpp>
#include <cmath>
int main()
{
sf::RenderWindow window;
window.create(sf::VideoMode(800, 600), "TITLE", sf::Style::Close | sf::Style::Resize);
window.setFramerateLimit(60);
sf::Font font;
if (!font.loadFromFile("Enchanted Land_0.otf"))
{
}
sf::Text text;
text.setFillColor(sf::Color::Red);
text.setFont(font);
sf::Event events;
sf::Clock clock;
while (window.isOpen())
{
sf::Time time = clock.getElapsedTime();
const int countdownNumberOfSeconds = 10;
const int timeleft = countdownNumberOfSeconds - std::floor(time.asSeconds());
text.setString(std::to_string(timeleft));
if (timeleft <= 0)
{
text.setString("GAME OVER");
text.setPosition(window.getSize().x / 2, window.getSize().y / 2);
}
while (window.pollEvent(events))
{
if (events.type == sf::Event::Closed)
{
window.close();
}
if (events.type == sf::Event::KeyPressed)
{
if (events.key.code == sf::Keyboard::A)
{
window.close();
}
}
}
window.clear(sf::Color::Blue);
window.draw(text);
window.display();
}
}
It's also not very useful for anything but the very simplest case. A rich text component or even just multiline component with text alignment would make a big difference here.
This is by far my biggest gripe. I find myself often having to do a lot of tinkering with sf::Text and wondering why I have to write my own functions for things like multi-line text centering. When I asked about it a couple years ago I was told to do it myself. Yeah, that's fine, I'm happy to do it, but it seems like there's a bit of functionality missing from sf::Text that is not just specific to my needs, but rather features that most users would want. I can see why these features might be low priority, but they don't even seem to be on the roadmap anywhere.
sf::RenderWindow window(sf::VideoMode(1920, 1080, 24), "SFML", sf::Style::Fullscreen);
#include <SFML/Graphics.hpp>
#include <iostream>
int main()
{
// sf::RenderWindow window(sf::VideoMode(1920, 1080, 32), "SFML", sf::Style::Fullscreen);
sf::RenderWindow window(sf::VideoMode::getDesktopMode(), "SFML", sf::Style::Fullscreen);
window.setVerticalSyncEnabled(true);
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
sf::Clock clock;
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
float currentTime = clock.getElapsedTime().asSeconds();
float fps = 1.f / (currentTime);
clock.restart();
std::cout << std::to_string(fps) << std::endl;
}
return 0;
}
sf::RenderWindow window(sf::VideoMode(1920, 1080, 32), "SFML", sf::Style::Fullscreen);
sf::RenderWindow window(sf::VideoMode::getDesktopMode(), "SFML", sf::Style::Fullscreen);
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode::getDesktopMode(), "SFML", sf::Style::Fullscreen);
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
Ah so it's more or less just zoomed in.