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

Recent Posts

Pages: 1 ... 4 5 [6] 7 8 ... 10
51
For example, in the game shown in the image, which uses the ddraw engine, the smart input method's candidate window is not blocked. What is the reason for this? How can this issue be resolved? Thank you for your reply. I may have described the issue incorrectly earlier. In full-screen mode, the smart input method cannot display the candidate window because it is blocked by SFML.
52
I assume you mean IME.
SFML doesn't really provide any specific support for IME and as I've never worked with it, I can't really give you more insights either.

If possible can you describe the problem a bit more? "cannot expand" isn't very descript and I'm not sure what it means exactly.
53
SFML projects / Re: Shape Wars - A 2d Shooter
« Last post by Herogo3241 on November 28, 2024, 01:38:42 pm »
Thanks
54
SFML projects / Re: Shape Wars - A 2d Shooter
« Last post by Hapax on November 27, 2024, 04:56:36 pm »
Looks good. Congrats :)
55
Graphics / Re: Colour individual triangles in a sf::TriangleStrip
« Last post by Hapax on November 27, 2024, 04:41:17 pm »
You can do this with a triangle strip but it requires duplicate vertices and, if you're doing this often, it may be better to just use separate triangles.

e.g.
I'll assume you have 8 vertices in the example and they are bottom0, top0, bottom1, top1, bottom2, top2, bottom3, top3.

You can use (12 vertices) bottom0, top0, bottom1, top1, top1, bottom1, top2, bottom2, bottom2, top3, bottom3.

This allows change of colour over the doubled vertices.
Note that this works because the doubled vertex as well as the previous (or next) vertex create an infinitely thin triangle so those two triangles (where the colour transitions happen) are invisible.

A possibly simpler version
If you need each triangle pair to be the same direction then you can just duplicate the 2 vertices that represent the edge.
This works because, again, you're "drawing invisible lines".

That would be (12 vertices) bottom0, top0, bottom1, top1, bottom1, top1, bottom2, top2, bottom2, top2, bottom3, top3.
This could be more simple as you're still following the same bottom-to-top and left-to-right formula and you it looks a bit clearer in the code as you're effectively separating the vertices into groups of 4 (per quad).

Here's an image of all three of those examples with your original being the top one (number 1):


(click to show/hide)
56
DotNet / Re: .NET documentation help
« Last post by eXpl0it3r on November 27, 2024, 12:27:19 pm »
Glad you figured it out!

Yeah, currently the Sandcastle solution isn't really viable anymore.
doxygen seems to generate good-enough docs and is easy enough to use.

There's an option issue about this here: https://github.com/SFML/SFML.Net/issues/275
57
General / Re: Linking libraries in MACOS
« Last post by eXpl0it3r on November 25, 2024, 09:34:56 am »
Is @executable_name/../Frameworks the right location then?
Meaning, is the excutable located somewhere in Bubble Popper.app/Contents/XYZ/MyExecutable?
58
SFML projects / 29th of Nov, Launch of Indie 2D MMORPG made with SFML
« Last post by WilliamK2H on November 24, 2024, 08:56:18 pm »
Our free Indie 2D MMORPG, Key To Heaven, Officially Launches Friday, November 29th at 20:00 CET. It's built with VB.NET using SFML for the graphics. The game is available right now on Steam, Microsoft Store and Itchio with a built in countdown timer for the big release. Everybody starts from level 1.

Website: https://key2heaven.com
Discord: https://discord.gg/TmHHJkG
Steam: https://store.steampowered.com/app/1347630/Key_To_Heaven/


Or you can checkout the youtube for the latest videos:

Join the community today and get ready for the journey!
59
General / The problem with collision
« Last post by darkwolf on November 24, 2024, 05:24:07 pm »
I am trying to implement collision detection from the video by javidx9, "Arbitrary Rectangle Collision Detection & Resolution - Complete," but sometimes, when one object touches another, the first object flies off unexpectedly. This might be related to velocity.y = 0, but I’m not sure about the exact cause. I also discovered that in the DynamicRectVsRect function, when multiplying in_rect_vel.x by fElapsedTime (where in_rect_vel.x == 0), it becomes a very small number instead of zero.
Code:

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


bool RayVsRect(sf::Vector2f ray_origin, sf::Vector2f ray_direction, sf::RectangleShape target, sf::Vector2f& contact_point, sf::Vector2f& contact_normal, float& t_hit_time);
bool DynamicRectVsRect(sf::RectangleShape& in, sf::RectangleShape target, sf::Vector2f in_rect_vel, sf::Vector2f& contact_point, sf::Vector2f& contact_normal, float& contact_time, float fElapsedTime);
sf::Vector2f normalize(sf::Vector2f vector);

int main()
{
        sf::RenderWindow window(sf::VideoMode(800, 600), "My window");
        window.setFramerateLimit(60);

        std::vector<sf::RectangleShape> vRects;

        vRects.push_back(sf::RectangleShape());
        vRects[0].setPosition({10.0f, 10.0f});
        vRects[0].setSize({30.0f, 20.0f});
        sf::Vector2f velocity = {0, 0};

        vRects.push_back(sf::RectangleShape());
        vRects[1].setPosition({ 100.0f, 100.0f });
        vRects[1].setSize({ 80.0f, 50.0f });

        sf::RectangleShape sfml_rect;
        sfml_rect.setPosition({100.0, 100.0});
        sfml_rect.setSize({ 200.0, 200.0 });

        sf::CircleShape circle;
        int circle_rad = 5;
        circle.setFillColor(sf::Color::Red);
        circle.setRadius(circle_rad);

        sf::Vector2f ray_point = {20.0f, 20.0f};
        sf::Vector2f ray_direction;
        sf::Vector2i MousePos;

        sf::Vector2f cp, cn;
        float ct;

        float t;

        sf::Vertex normal[2];

        sf::Clock clock;
        float deltaTime;

        while (window.isOpen())
        {
                MousePos = sf::Mouse::getPosition(window);
                ray_point = sf::Vector2f(vRects[0].getPosition().x+vRects[0].getSize().x/2, vRects[0].getPosition().y + vRects[0].getSize().y / 2);
                ray_direction = sf::Vector2f(MousePos.x - ray_point.x, MousePos.y - ray_point.y);
                deltaTime = clock.restart().asSeconds();
                //std::cout << ray_direction.x << &#39;\t&#39; << ray_direction.y << std::endl;

                if (sf::Mouse::isButtonPressed(sf::Mouse::Left)) {
                        sf::Vector2f norm_ray_direction = normalize(ray_direction);
                        velocity += sf::Vector2f(norm_ray_direction.x * 100.0f * deltaTime, norm_ray_direction.y * 100.0f * deltaTime);
                }
                //std::cout << velocity.x << &#39;\t&#39; << velocity.y << std::endl;
               
                for (int i = 1; i < vRects.size(); i++) {
                        if (DynamicRectVsRect(vRects[0], vRects[i], velocity, cp, cn, ct, deltaTime)) {
                                velocity += sf::Vector2f(cn.x * std::abs(velocity.x) * (1-ct), cn.y * std::abs(velocity.y) * (1-ct));
                        }
                }
                vRects[0].move(velocity.x * deltaTime, velocity.y * deltaTime);
                std::cout << velocity.x << &#39;\t&#39; << velocity.y << "\t\t" << vRects[0].getPosition().x << &#39;\t&#39; << vRects[0].getPosition().x << std::endl;
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                        {
                                window.close();
                        }
                }

                window.clear(sf::Color::Black);
                for (int i = 0; i < vRects.size(); i++) {
                        window.draw(vRects[i]);
                }
                window.display();
        }

        return 0;

}

bool RayVsRect(sf::Vector2f ray_origin, sf::Vector2f ray_direction, sf::RectangleShape target, sf::Vector2f& contact_point, sf::Vector2f& contact_normal, float& t_hit_near) {

        sf::Vector2f t_near = sf::Vector2f((target.getPosition().x - ray_origin.x) / ray_direction.x,
                                                                           (target.getPosition().y - ray_origin.y) / ray_direction.y);
        sf::Vector2f t_far = sf::Vector2f((target.getPosition().x + target.getSize().x - ray_origin.x) / ray_direction.x,
                                                                          (target.getPosition().y + target.getSize().y - ray_origin.y) / ray_direction.y);

        std::cout << "ray_direction: " << ray_direction.x << &#39;\t&#39; << ray_direction.y << std::endl;
        std::cout << "t_near: " << t_near.x << &#39;\t&#39; << t_near.y << std::endl;
        std::cout << "t_far: " << t_far.x << &#39;\t&#39; << t_far.y << std::endl;

        if (t_near.x > t_far.x) std::swap(t_near.x, t_far.x);
        if (t_near.y > t_far.y) std::swap(t_near.y, t_far.y);

        if (t_near.x > t_far.y || t_near.y > t_far.x) return false;

        //std::cout << "t_near: " << t_near.x << &#39;\t&#39; << t_near.y << std::endl;

        t_hit_near = std::max(t_near.x, t_near.y);
        float t_hit_far = std::min(t_far.x, t_far.y);

        if (t_hit_far < 0) return false;

        contact_point = ray_origin + t_hit_near * ray_direction;

        if (t_near.x > t_near.y)
        {
                if (ray_direction.x < 0)
                {
                        contact_normal = { 1, 0 };
                }
                else
                {
                        contact_normal = { -1, 0 };
                }
        }
        else if (t_near.x < t_near.y)
        {
                if (ray_direction.y < 0)
                {
                        contact_normal = { 0, 1 };
                }
                else
                {
                        contact_normal = { 0, -1 };
                }
        }

        return true;
}


bool DynamicRectVsRect(sf::RectangleShape& in, sf::RectangleShape target, sf::Vector2f in_rect_vel, sf::Vector2f& contact_point, sf::Vector2f& contact_normal, float& contact_time, float fElapsedTime)
{
        if (in_rect_vel.x == 0 && in_rect_vel.y == 0)
                return false;

        sf::RectangleShape expanded_target;
        expanded_target.setPosition(sf::Vector2f(target.getPosition().x - in.getSize().x / 2, target.getPosition().y - in.getSize().y / 2));
        expanded_target.setSize(target.getSize() + in.getSize());

        std::cout << "rect_vel: " << in_rect_vel.x * fElapsedTime << &#39;\t&#39; << in_rect_vel.y * fElapsedTime << std::endl;
        std::cout << "deltaTime: " << fElapsedTime << std::endl;
        if (RayVsRect(sf::Vector2f(in.getPosition().x + in.getSize().x / 2, in.getPosition().y + in.getSize().y / 2), in_rect_vel * fElapsedTime, expanded_target, contact_point, contact_normal, contact_time))
        {
                std::cout << "contact_time: " << contact_time << std::endl;
                if (contact_time <= 1.0f)
                {
                        return true;
                }
        }

        return false;
}

sf::Vector2f normalize(sf::Vector2f vector) {
        float lenght = sqrt(pow(vector.x, 2) + pow(vector.y, 2));
        return sf::Vector2f(vector.x/lenght, vector.y/lenght);
}
60
Hello everyone, I have designed an RPG online game that cannot expand the input method candidate window in full screen mode. No matter what setting I try, it cannot expand, but it works normally on other engines and can display input method candidate windows. This is my code. Please provide suggestions

void   StartInDrawText(int sX, int sY, uint32 iLen, char* pBuffer, bool bIsHide, int right)
{
        m_InputStatus = TRUE;
        m_iInputX = sX;
        m_iInputY = sY;
        m_pInputBuffer = pBuffer;
        ZeroMemory(m_cEdit, sizeof(m_cEdit));
        m_inputMaxLen = iLen;
        m_iInputX2 = right;
   G_hEditWnd = CreateWindow(RICHEDIT_CLASS, NULL, WS_POPUP | ES_SELFIME, sX - 5, sY - 1, iLen * 12, 16, g_window, (HMENU)0, g_instance, NULL);

        SetWindowText(G_hEditWnd, m_pInputBuffer);
        SendMessage(G_hEditWnd, EM_EXLIMITTEXT, 0, iLen - 1);
        SendMessage(G_hEditWnd, EM_SETLANGOPTIONS, 0, ~IMF_AUTOFONT);
        COMPOSITIONFORM composform;
        composform.dwStyle = CFS_POINT;
        composform.ptCurrentPos.x = sX;
        composform.ptCurrentPos.y = sY;
        HIMC hImc = ImmGetContext(g_window);
        ImmSetCompositionWindow(hImc, &composform);
        int StrLen = strlen(m_pInputBuffer);
        SendMessage(G_hEditWnd, EM_SETSEL, StrLen, StrLen);

 
}


I tried, SetWindowPos(G_hEditWnd, HWND_TOPMOST, sX - 5, sY - 1, iLen * 12, 16, SWP_NOACTIVATE);
I have also tried GPT's answer, but it cannot solve the problem. The input method is still blocked by the SFML game window. Request assistance.
Pages: 1 ... 4 5 [6] 7 8 ... 10