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 - geekz

Pages: [1]
1
General / SFML shows error squiggles even though it works
« on: April 09, 2022, 08:12:52 pm »
I took a break from SFML development for a while and when I went back today, saw C++ extension had some updates so I installed it and I'm getting error squiggles even though the application works. Anyone got idea why? Is it because of the extension? I'd like to get rid of these error squiggles, it's just annoying...

Maybe worth to mention:
  • I use WSL on Visual Studio Code, windows 10
  • The version of VSC I use is 1.66.1
  • I've tried to set ${workspaceFolder}/** in includePath but it still doesn't remove the error squiggles

Screenshot is attached, as you see, the application runs just fine but the SFML errors are everywhere, I just don't understand why.

2
Graphics / Re: sprite move issue
« on: September 02, 2021, 11:05:25 am »
Btw. you should not have your clear/draw/display inside the event loop, otherwise you screen only renders a new frame if there's an event.
Yes, that's what I want right now but I'll change frame render later when there's no event - just testing stuff at this moment.

3
Graphics / Re: sprite move issue
« on: August 31, 2021, 05:43:26 pm »
edit: solved the issue using spaceShipMoveUp.position() instead of .move()

4
Graphics / sprite move issue
« on: August 31, 2021, 12:33:26 pm »
Hi,

currently I have two sprites - a spaceship without flames, and another with flames (when moved upwards). When I press up for first time, it changes to the sprite with flames and moves up without any issue but when I press up for a second time, it just disappears and I get a empty black screen. Anyone here knows why?

My code:
void Game::play(sf::RenderWindow &window) {
    std::cout << "playing the game" << std::endl;
    int startX = 500;
    int startY = 400;

    if (!texture.loadFromFile("pixil-test.png"))
    {
        // error...
        std::cout << "doesnt work" << std::endl;
    }

    // first spaceship
    spaceShip.move(startX, startY);
    spaceShip.setTexture(texture);
    spaceShip.setTextureRect(sf::IntRect(0, 0, 11, 17));

    // second spaceship with rear flames
    spaceShipMoveUp.setTexture(texture);
    spaceShipMoveUp.setTextureRect(sf::IntRect(12, 0, 11, 17));

    window.draw(spaceShip);
    window.display();

    while(window.isOpen()) {
        sf::Event event;
        while(window.pollEvent(event)) {
            if(event.type == sf::Event::Closed) {
                window.close();
            }
            if(event.type == sf::Event::KeyPressed) {
                if(event.key.code == sf::Keyboard::Up) {
                    startY--;
                    window.clear();
                    spaceShipMoveUp.move(startX, startY);
                    window.draw(spaceShipMoveUp);
                    window.display();
                }
                else if(event.key.code == sf::Keyboard::Escape) {
                    window.close();
                }
            }
        }
    }
}

5
thank you <3, and yes I really need to look at pictures better  :P

6
Ah, so I just need to find another picture that is actually transparent and use same code as I have, that's it?

7
Hi everybody,

I'm just learning SFML and I'm having a trouble to load a picture without background - my current screen is black and I'd like to put sprite at screen (the .png picture i have is transparent) but still shows white background under.
Is there any simple way to make the texture/sprite transparent?

My code:
    sf::Texture texture;
    sf::Sprite sprite;
    if (!texture.loadFromFile("spacetest2.png"))
    {
        // error...
        std::cout << "doesnt work" << std::endl;
    }
    sprite.setTexture(texture);
    window.draw(sprite);
    window.display();

I've attached pictures below:

Pages: [1]
anything