This is the starting code i use to load my png file as u can see loadFromFile is in white color as it cannot find it!
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <iostream>
#include <string>
sf::Texture spaceshipTexture;
sf::Sprite spaceship;
if (!spaceshipTexture.loadFromFile("spaceship.png")) {
// Handle error if the texture fails to load
}
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600), "Shoot'em up game");
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();
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) {
shape.move(-5.0f, 0.0f);
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) {
shape.move(5.0f, 0.0f);
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) {
shape.move(0.0f, -5.0f);
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) {
shape.move(0.0f, 5.0f);
}
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
if there is a mistake in my code help me pls
i join in attachment screenshot of visual studio
I use the last version of sfml 2.6.1 32bit Visual C++ 17 (2022)
I put sfml inlcude directory in Additional Include Directories from C/C++
I put -d.lib file in debug configuration in Additional Dependencies from linker