Hi everyone,
I just got SFML installed so I was playing around with the code that the tutorial provided, I was just wondering why this code only outputs variable a and not variables a+b;
#include "SFML/Graphics.hpp"
#include <string>
#include <iostream>
using namespace std;
int main()
{
string a = "hello", b="again";
sf::RenderWindow window(sf::VideoMode(600, 200), "SFML works!");
sf::Text text(a + b);
while (window.isOpen())
{
sf::Text text(a);
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(text);
window.display();
}
return 0;
}
I was just trying to see if I could add strings together within text(), which I would need to do if I tried to make a game. Is it possible to do calculations inside of a function from SFML, or do I have to do the calculations first and only output the one variable that contains the result?
Woops, solved that on my own, dumb mistake on my part.
I can't remove this post now, there's some sort of error message. sorry.
error message;
You cannot delete your own topics in this board. Check to make sure this topic wasn't just moved to another board.
Well, while I have you here, why isn't rect() working for me?
#include "SFML/Graphics.hpp"
#include <string>
#include <iostream>
using namespace std;
int main()
{
string a = "hello", b="again";
sf::RenderWindow window(sf::VideoMode(600, 200), "SFML works!");
sf::Text text(a + b);
while (window.isOpen())
{
sf::Text text(a + b);
sf::Rect rect(20,30,200,80);
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(text);
window.display();
}
return 0;
}