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

Pages: [1] 2 3 ... 722
1
Window / Re: Problem handling multiple key stroke
« on: May 13, 2024, 03:50:10 pm »
Your keyboard probably doesn't handle n-key rollover, but has a cheap implementation that will only allow 4-5 keys to be pressed in certain areas of your keyboard.
You're probably receiving some key pressed events, just not necessarily the up and down keys you've configured.

What keyboard do you have?

Try mapping the keys further apart, e.g. WASD for one player and arrow keys for the other.

2
General / Re: Can you integrate allegro into an sfml window?
« on: May 13, 2024, 03:00:16 pm »
Maybe it's possible somehow, but I feel if you have the knowledge to hack those two libraries together, you might as well use a video playback library instead or if you must, port Allegro's addon to SFML.

3
If you use SelbaWard as a library, make sure you're linking it.
If you just want to include the specific files, make sure you've add the *.cpp files to your project.

4
You could just use a vertex array, set the texture position and vertex position.

But this will lead to a potentially unwanted distortion, since the vertex array is made up of two triangles, that are shaped independently.

You may instead want to use Hapax's Elastic Sprite: https://github.com/Hapaxia/SelbaWard/wiki/Elastic-Sprite

5
Graphics / Re: Align the text perfectly centered inside any shape
« on: May 13, 2024, 08:32:39 am »
To center text, you also need to consider its local bounds, for example like this:

#include <iostream>
#include <SFML/Graphics.hpp>

int main()
{
    auto window = sf::RenderWindow{{800, 600, 32}, "SFML Window"};
    window.setFramerateLimit(60);

    auto font = sf::Font{};
    if (!font.loadFromFile("OpenSans.ttf"))
    {
        std::cerr << "Could not load font\n";
        return -1;
    }

    auto rectangle = sf::RectangleShape{ {300.f, 100.f} };
    rectangle.setOutlineThickness(1.f);
    rectangle.setOutlineColor(sf::Color::Green);
    rectangle.setPosition({ 200.f, 200.f });
    rectangle.setFillColor(sf::Color::Transparent);

    auto text = sf::Text{ "Test 1234", font };
    text.setOrigin(text.getGlobalBounds().getSize() / 2.f + text.getLocalBounds().getPosition());
    text.setPosition(rectangle.getPosition() + (rectangle.getSize() / 2.f));

    auto globalBounds = text.getGlobalBounds();
    auto localBounds = text.getLocalBounds();

    std::cout << "(" << globalBounds.left << ", " << globalBounds.top << ") (" << globalBounds.width << ", " << globalBounds.height << ")\n";
    std::cout << "(" << localBounds.left << ", " << localBounds.top << ") (" << localBounds.width << ", " << localBounds.height << ")\n";

    while (window.isOpen())
    {
        for (auto event = sf::Event{}; window.pollEvent(event);)
        {
            if (event.type == sf::Event::Closed)
            {
                window.close();
                return 0;
            }
        }

        window.clear();
        window.draw(rectangle);
        window.draw(text);
        window.display();
    }
}
 

6
Do you want to cut out this kind of shape from a texture?

7
Not sure it will give you the wanted effect, but you can pass the shader as render state during the draw call of the text object itself: window.draw(text, shader) (this should implicitly construct a sf::RenderState).

but with this i have a black background on my text
You'll need to clear the RenderTexture with a transparent color (alpha = 0).
You may then want to render the text without any blending (i.e. without alpha blending) to prevent colored outlines.

Alternatively, you can also take a look at Hapax's Spinning card: https://github.com/Hapaxia/SelbaWard/wiki/Spinning-Card

8
Graphics / Re: Tile-based graphic using Sprites.. right?
« on: May 09, 2024, 09:51:46 am »
When talking about tiling it's mostly thought of as a flat 2D space. Isometric rendering requires a lot of special rules, that on a 2D grid doesn't necessarily apply, thus my suggestion to search more around the term isometric.

Searching online i've found this https://www.sfml-dev.org/tutorials/2.4/graphics-vertex-array.php , i think is exctly what i was looking for probably, rigt?
Yes, this shows you how to utilize a vertex array.

This might also be useful: https://www.binpress.com/creating-city-building-game-with-sfml/

9
Graphics / Re: Tile-based graphic using Sprites.. right?
« on: May 08, 2024, 08:18:31 am »
The term you're looking for is "isometric".

You can use sprites, but you may run into performance issues down the line, so you may consider starting off with vertex arrays.

The difficult part is correctly calculating which tile needs to be rendered on top of what other tile, depending if something is below or above or infront.

10
SFML projects / Re: VALA-vapi binding sfml
« on: May 07, 2024, 07:55:05 am »
I've never used Vala, but looks quite similar to the C languages.

If you want, you could open a PR to add it to the binding page: https://github.com/SFML/SFML-Website

11
Graphics / Re: How do I disable font smoothing?
« on: May 03, 2024, 07:19:09 am »
Also make sure you're rendering text only on integer position and choose the fitting font size, i.e. never scaling the text.

12
System / Re: Fail to Build Project
« on: May 02, 2024, 04:23:27 pm »
Make sure your configuration is for the correct compiler architecture (Win32 vs x64) and config (Debug vs Release). Note how no SFML libraries are listed above.

Also don't delete %(AdditionalLibraryDirectories) from the Additional Library Directory, otherwise the linker might fail to find system libraries.

13
System / Re: Fail to Build Project
« on: May 02, 2024, 03:51:13 pm »
Double check the config with the tutorial, you must have done some mistake somewhere to get the shown error output.

Provide the verbose build output, so we can see the complete configuration: https://www.sfml-dev.org/faq.php#tr-grl-verbose-ide

14
System / Re: Fail to Build Project
« on: May 02, 2024, 03:06:19 pm »
How are you linking SFML?

15
System / Re: Fail to Build Project
« on: May 02, 2024, 02:55:20 pm »
Are you #include-ing the lib file instead of a header file?

You need to provide more information on what you're doing in order for us to help and not just make random guesses.

Pages: [1] 2 3 ... 722