Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

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.


Messages - Junalista

Pages: [1]
1
Graphics / Re: Issue with LoadFromFile
« on: January 22, 2024, 10:59:14 am »
Thx for ur help
It is working now

2
Graphics / Re: Issue with LoadFromFile
« on: January 21, 2024, 08:01:52 pm »
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&#39;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




3
Graphics / Issue with LoadFromFile
« on: January 20, 2024, 03:47:44 pm »
I'm new with sfml, i finished by installing sfml on visual studio 2022 after many tries!
Now i hv tested the code given by the site it fucntionning correctly!
Show windows with the circle!
Now i wanted to test LoadFromFile but it say it has no definition!
So i tried other function has isKeyPressed this one work pefectly
So i dont understand why LoadFromFile not working, i hv tried also SetTexture and i get the same error!
Can someone help me please?


Pages: [1]