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 ... 723
1
SFML projects / Re: Tail Smash! - Arcade driving game
« on: May 29, 2024, 11:32:24 pm »
That's a pretty cool write up! I especially liked the diagrams :)

2
General / Re: Can't compile when trying to render text
« on: May 29, 2024, 11:31:08 pm »
That's a known issue when using UCRT-based MinGW versions, as the pre-compiled freetype library were compiled with MSVCRT. You can either switch to a MSVCRT-based MinGW version or build SFML's dependencies with your own compiler.

3
General / Re: Keyboard big issue
« on: May 29, 2024, 01:01:52 pm »
What window manager are you using? Is this running wayland or xlib?

4
General / Re: Keyboard big issue
« on: May 29, 2024, 02:09:49 am »
What version of SFML are you using?

5
General / Re: Keyboard big issue
« on: May 28, 2024, 04:55:17 pm »
Set a break point inside the key pressed event body, run the application through a debugger and check what the value of the key code is.

I have a feeling that you either have a different layout configured that you're expecting, so hitting the specific key doesn't actually trigger something. Or you have something installed on Debian that remaps keyboard values.

It's unlikely an SFML issue, since we've been using basically the same code for a long time now.

6
General / Re: Keyboard big issue
« on: May 28, 2024, 04:29:00 pm »
Are you using a special keyboard layout?

So the following example application doesn't work?

#include <SFML/Graphics.hpp>

int main()
{
    auto window = sf::RenderWindow{ { 1920u, 1080u }, "Color Switcher" };
    window.setFramerateLimit(144);

    auto backgroundColor = sf::Color::Black;

    while (window.isOpen())
    {
        for (auto event = sf::Event{}; window.pollEvent(event);)
        {
            if (event.type == sf::Event::Closed)
            {
                window.close();
            }
            else if (event.type == sf::Event::KeyPressed && event.code == sf::Keyboard::R)
            {
                backgroundColor = sf::Color::Red;
            }
            else if (event.type == sf::Event::KeyRelease && event.code == sf::Keyboard::G)
            {
                backgroundColor = sf::Color::Green;
            }
        }

        window.clear(backgroundColor);
        window.display();
    }
}

If you use SFML 2.6, can you try scancodes instead?

7
General / Re: Keyboard big issue
« on: May 28, 2024, 03:57:55 pm »
That's some interesting code formatting :D
(Btw. you don't need a semicolon after an if-body)

When you say for "letters" are you passing in as key for example sf::Keyboard::A?

8
General / Re: Keyboard big issue
« on: May 28, 2024, 03:16:25 pm »
Can you share some minimal and compiable code that reproduces the issue?

9
General / Re: error during initialisation of SFML
« on: May 27, 2024, 02:09:15 pm »
Just in case someone finds this post or the original poster checks again.

Those kinds of errors are usually an indication that a wrong runtime library was used.
Runtime libraries have to match 100% between that one used with SFML and then one that gets linked into your application.
This means, one needs to make sure to use the exact same compiler version (not just GCC version, but the whole configuration!). Or even simpler, build SFML with your compiler, that guarantees it matches. See also the SFML CMake Template.

10
The application needs the permission, not the terminal or XCode as far as I know.
If you recompile or change the application name, the permission might be removed, but I'm not sure how macOS hands this out.

Either way, I still highly recommend to track keyboard states via events.

11
On macOS in order to use sf::Keyboard::isKeyPressed you'll need to give monitoring permission to the application.
Alternatively, you can use the KeyPressed event that doesn't need any additional permission.

12
If you moved it inside the player, then you can draw the hitpoint inside the player's Draw call and apply the transformation there.
At some point, you need to have code that says it's relative to X ;D

13
SFML development / Re: Font/Text Direction
« on: May 26, 2024, 12:13:40 am »
If you want to PR that change, I'm sure we'd accept it for SFML 3.

My question was more, whether that on its own is really enough/useful if you do want to create your own custom text with vertical layout, or whether one would also need other adjustments.

14
What you can do for relative positioning is set a relative position on the HitPoint, then pass the transform of your player to the HitPoint and a multiply the transform of the HitPoint with the one of the Player, essentially applying all the transformations of the player to the HitPoint.

I also highly recommend to make use of Drawable and Tansformable.
Here's an example, since you seem to use  C#, I've also written in in C#:

using SFML.Graphics;
using SFML.System;
using SFML.Window;

var player = new Player();
player.Position = new Vector2f(75, 150);

var hitPoint = new HitPoint();
hitPoint.Position = new Vector2f(2, -10);

var window = new RenderWindow(new VideoMode(200, 200), "SFML.Net Test");
window.SetFramerateLimit(144);
window.Closed += (_, _) => { window.Close(); };
window.KeyPressed += (_, eventArgs) =>
{
    const int speed = 2;

    var direction = eventArgs.Code switch
    {
        Keyboard.Key.Left => -1,
        Keyboard.Key.Right => 1,
        _ => 0
    };

    player.Position += new Vector2f(direction * speed, 0);
};

while (window.IsOpen)
{
    window.DispatchEvents();
    window.Clear();
    window.Draw(player);
    window.Draw(hitPoint, new RenderStates(player.Transform));
    window.Display();
}

public class Player : Transformable, Drawable
{
    private readonly RectangleShape _shape;

    public Player()
    {
        _shape = new RectangleShape(new Vector2f(20, 20));
        _shape.FillColor = Color.Green;
    }
   
    public void Draw(RenderTarget target, RenderStates states)
    {
        states.Transform *= Transform;
        target.Draw(_shape, states);
    }
}

public class HitPoint : Transformable, Drawable
{
    private readonly RectangleShape _shape;

    public HitPoint()
    {
        _shape = new RectangleShape(new Vector2f(16, 4));
        _shape.FillColor = Color.Red;
    }
   
    public void Draw(RenderTarget target, RenderStates states)
    {
        states.Transform *= Transform;
        target.Draw(_shape, states);
    }
}

15
General / Re: I need help with this
« on: May 24, 2024, 10:43:46 pm »
For the table's side, you'd have to provide Box2D a table size minus the radius of the cue ball on each side, then do a line cast. If the line hits the wall, you know that ball would hit the side.

For ball to ball, it's a bit trickier, since balls can hit a different angles. Not sure what options Box2D provides here, but circle to circle collision check is really simple. If the distance of points is smaller than the combined radi of the two circles, you have a collision.

Pages: [1] 2 3 ... 723