#include"SFML\Graphics.hpp"
#include<iostream>
int main()
{
sf::RenderWindow window(sf::VideoMode(640, 480), "CHECK",sf::Style::Default);
std::cout << "WORKS";
sf::Texture text;
text.loadFromFile("bahamut.png");
sf::Sprite sprite;
sf::Clock frap;
sprite.setTexture(text);
constexpr float speed = 1; // fyi, this is in "pixels per second", so quite slow to say the least
while (window.isOpen())
{
float fps = frap.restart().asSeconds();
sf::Vector2f movements; // default constructed to {0.f, 0.f}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::A))
{
movements = {-speed * fps, 0.f};
}
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::D))
{
movements = {speed * fps, 0.f};
}
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::S))
{
movements = {0.f, speed * fps};
}
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::W))
{
movements = {0.f, -speed * fps};
}
sprite.move(movements);
window.clear();
window.draw(sprite);
window.display();
}
return 0;
}
If you look at the minimal example here
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
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;
}
You shall realize that you lack event handling in your program. This cannot work. The bare minimum is polling events and checking for sf::Event::Closed. Try fixing that and format your code properly, that will make finding the problem easier.
EDIT: Maybe fix highlighting to highlight 'constexpr' and such? Just a suggestion.