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

Pages: [1] 2 3 ... 8
1
Tried a few levels via HTML 5 version and I must say I'm impressed by this project, good job!

2
Hi,

liked your video.
Just an idea to make the gameplay instantly more satisfying could be to trigger sounds for goals and missed goals / saves (from the player's perspective), e.g.,

https://www.videvo.net/royalty-free-sound-effects/goal/
Ambiance: "Soccer 18"
Goal: "Cheering Crowd 03" (or mix/vary multiple ones)
Miss: "Sweden Crowd"

Really like the ball sound effects already, though.

Of course, any other source could work, too :-)

3
General / Re: How to approach multiple windows over multiple threads
« on: February 02, 2020, 01:43:15 pm »
Hi,

take my information with a grain of salt, but I seem to remember the windows message loop must be run from the main thread, and from the main thread only. In other words, you cannot create a window and handle events from another thread.

Correct me if I'm wrong...

4
General / Re: Direction of collision
« on: January 18, 2020, 10:31:51 am »
The direction you can get from your movement vector (You can compute the angle of the movement vector which would give you the direction). However, this is likely not failsafe.

You need a way of finding out if your sprite2 (or Sprite) is the wall or the floor. Then you know for sure if it was the floor or a wall.

If I understand you correctly, you are using a single sprite which serves as a wall and moves into the floor as well, correct? In that case, using the direction still isn't failsafe. You could either fall onto the wall with a pretty steep angle, but still be hitting the wall, or you could touch the floor with a pretty flat angle, but still touch the floor.

I would suggest maybe using the height of the player as a metric, let's say the player is standing on the floor. The difference of the y coordinate and the bottom of the floor is maybe 100px. If you detect a collision, check the height difference of the player. If it's < 110px you hit the floor, else the wall.

Another option would be separating the sprite from multiple bounding boxes, or splitting the sprite into two separate ones, so that they still look connected in-game, but are in reality two separate sprites.

That's my thought process without seeing any actual code.

5
I built SFML like so:

Code: [Select]
cmake .. -G"MSYS Makefiles" -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS:BOOL=FALSE -DSFML_USE_STATIC_STD_LIBS:BOOL=TRUE -DCMAKE_INSTALL_PREFIX:PATH=/mingw64/
make -j
make install

I'm using the official cmake files from /lib/cmake/SFML/. which are from the Github repo.

6
Hi,

this is my CMakeLists.txt:

Code: [Select]
add_executable(foo
  main.cpp
)

set(SFML_STATIC_LIBRARIES TRUE)
find_package(SFML 2.5 COMPONENTS graphics audio REQUIRED)

target_link_libraries(foo sfml-graphics sfml-audio)

However, I get the following errors (it shows the same error like ten times):
Code: [Select]
-- Found SFML 2.5.1 in X:/msys64/mingw64/lib/cmake/SFML
-- Configuring incomplete, errors occurred!
See also "X:/msys64/home/Programming/cpp/Simulation/build/CMakeFiles/CMakeOutput.log".
CMake Error at X:/msys64/mingw64/lib/cmake/SFML/SFMLConfigDependencies.cmake:38 (set_property):
  set_property could not find TARGET Vorbis.  Perhaps it has not yet been
  created.
Call Stack (most recent call first):
  X:/msys64/mingw64/lib/cmake/SFML/SFMLConfigDependencies.cmake:74 (sfml_bind_dependency)
  X:/msys64/mingw64/lib/cmake/SFML/SFMLConfig.cmake:117 (include)
  src/CMakeLists.txt:6 (find_package)

vorbis is installed in MSYS2 and I can link it as well (libvorbis.a). The package is:
mingw64/mingw-w64-x86_64-libvorbis

I built SFML like so:

Code: [Select]
cmake .. -G"MSYS Makefiles" -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS:BOOL=FALSE -DSFML_USE_STATIC_STD_LIBS:BOOL=TRUE -DCMAKE_INSTALL_PREFIX:PATH=/mingw64/
make -j
make install

And my project like so:
Code: [Select]
mkdir -p build
cd build
cmake .. -G"MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release
make -j

If I edit SFMLConfigDependencies.cmake and remove everything searching for "Vorbis", and manually link the libraries, it works:

Code: [Select]
target_link_libraries(SkyDrive sfml-graphics sfml-audio vorbis vorbisenc vorbisfile ogg)

So I'm just going to assume there is a problem with the CMake config, since CMake can find the required dependencies without problems if I specify them manually (vorbis, vorbisenc, vorbisfile, ogg). Am I missing something?

Thank you!

7
SFML projects / Re: Cendric: An RPG Platformer
« on: March 30, 2018, 05:33:17 pm »
Hey congratulations on getting so much work done and actually staying at it for so long. Really impressive. I'm installing the game right now gonna try it out later.

8
Hi,

I came across something very puzzling while working with sockets. Check out the following example:
   
#include <iostream>

#include <SFML/Network.hpp>

int main()
{
    sf::TcpListener l;
    l.listen(2017);

    sf::TcpSocket sock;
    if (sock.connect(sf::IpAddress::LocalHost, 2017) == sf::Socket::Done)
        std::cout << "Connected!\n";

    if (sock.connect({1,2,3,4}, 2017) == sf::Socket::Done)
        std::cout << "???\n";

    char ch;
    std::cin >> ch;
}
This gives me
Connected!
???

I would very much expect the second call to connect to fail. Can anyone explain what's going on? Is this a bug? I understand that further calls to connect disconnect the socket first, but the second connection should obviously fail.

Edit:
Equally confusing behaviour, I would expect the second call to connect to succeed, yet I get no output:
    sf::TcpListener l;
    l.listen(2017);

    sf::TcpSocket s;
    if (s.connect({1,2,3,4}, 2017, sf::milliseconds(200)) == sf::Socket::Done)
        std::cout << "???\n";

    if (s.connect(sf::IpAddress::LocalHost, 2017) == sf::Socket::Done)
        std::cout << "Connected\n";

    char ch;
    std::cin >> ch;

I'm compiling with mingw-w64 GCC 7.2.0 on Windows 10 with SFML from github master


I'm trying to loop through a range of IpAddresses e.g. 192.168.178.2 - 192.168.178.99 and attempt to connect with the same socket for each address. At first I thought I was making some mistake using multiple threads, but then I tried a small example in a single main().

Edit2:
Calling disconnect seems to work for me to "handle" a failed connection, kind of like this:
   
sf::Uint8 b1{192}, b2{168}, b3{178};
socks.push_back(std::make_unique<sf::TcpSocket>());
for (sf::Uint8 b4 = 2; b4 < 100; ++b4) {
    if (socks.back()->connect({b1,b2,b3,b4}, port, sf::milliseconds(100)) == sf::Socket::Done) {
        chat.queue("Connected");
        socks.push_back(std::make_unique<sf::TcpSocket>());
    } else
        socks.back()->disconnect();
}

9
SFML projects / Re: Kroniax available in the Play store!
« on: January 05, 2017, 02:28:52 pm »
Hi, just checking in here, I downloaded again on my new phone and passed lv6. Feels good man. Cheers!

10
#include"SFML\Graphics.hpp"
#include<iostream>

int main()
{
    sf::RenderWindow window(sf::VideoMode(640, 480), "CHECK",sf::Style::Default);
    std::cout << "WORKS";
    sf::Texture text;
    text.loadFromFile("bahamut.png");
    sf::Sprite sprite;
    sf::Clock frap;
    sprite.setTexture(text);

    constexpr float speed = 1;  // fyi, this is in "pixels per second", so quite slow to say the least

    while (window.isOpen())
    {
        float fps = frap.restart().asSeconds();
        sf::Vector2f movements;  // default constructed to {0.f, 0.f}

        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::A))
        {
            movements = {-speed * fps, 0.f};
        }
        else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::D))
        {
            movements = {speed * fps, 0.f};
        }
        else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::S))
        {
            movements = {0.f, speed * fps};
        }
        else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::W))
        {
            movements = {0.f, -speed * fps};
        }

        sprite.move(movements);

        window.clear();
        window.draw(sprite);
        window.display();

    }
    return 0;
}
 
If you look at the minimal example here
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    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();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}
You shall realize that you lack event handling in your program. This cannot work. The bare minimum is polling events and checking for sf::Event::Closed. Try fixing that and format your code properly, that will make finding the problem easier.

EDIT: Maybe fix highlighting to highlight 'constexpr' and such? Just a suggestion.

11
General / Re: Disable SFML error messages
« on: January 02, 2017, 05:58:17 pm »
Hello,

thank you for your replies, I have a much better grasp of the SFML error printing now and the tools necessary to change it for my needs.

The premade class also works nicely, thank you.

12
General / Re: How to switch between Menu and Game screens efficiently?
« on: January 02, 2017, 01:10:31 am »
You can see an example of using States in the code from the SFML Game Dev Book, here:
https://github.com/SFML/SFML-Game-Development-Book/tree/master/05_States
Pay special attention to the classes State and StateStack

13
General / [Solved] Disable SFML error messages
« on: January 02, 2017, 12:56:58 am »
Hi,

how can I stop SFML from writing to my console?  In my case, I would like to handle sf::UdpSocket::bind() failing in my own way by using another Port.  However, SFML always prints an error message to my console, which I do not want in this case.

14
Graphics / Re: HBITMAP --> sf::Texture/sf::Image using ::loadFromMemory
« on: November 27, 2016, 06:47:57 pm »
Hi Laurent,

I just tried simply passing the pixel array to update and the result looks pretty good.

I think I have to switch the R and B portions, since windows does this the other way around.

However, everything is still upside down and inside out. Not sure what went wrong there.

Anyways thanks for your reply, I think I can work with that.

15
Graphics / HBITMAP --> sf::Texture/sf::Image using ::loadFromMemory
« on: November 27, 2016, 03:03:04 pm »
Hello,

I need a quick hint on how to properly load e.g. an sf::Texture from memory with the loadFromMemory function. Specifically, I am not sure what precisely the function expects (some data and its size - ok - but what data?). The docs state "load from a file in memory" - does this mean I must construct a .bmp file in memory and pass the pointer to the first byte of the entire file + the size of the file to loadFromMemory?

The error:
Failed to load image from memory. Reason: Image not of any known type, or corrupt

How I obtain my HBITMAP:
OpenClipboard(nullptr);
if (!IsClipboardFormatAvailable(CF_BITMAP))
{
    std::cerr << "No Bitmap in clipboard\n";
    return -1;
}
HBITMAP bmp = (HBITMAP)GetClipboardData(CF_BITMAP);
CloseClipboard();

Here is my code, as you can see I cluelessly use GetDIBits, but I don't know how to load the sf::Image properly.

bool SFMLLoadHBitmapAsImage(HBITMAP bitmap, sf::Image image)
{
    HDC deviceContext = GetDC(nullptr);
    if (!deviceContext)
    {
        return false;
    }
   
    //Create BITMAPINFO variable, set size
    BITMAPINFO bmpInfo{};
    bmpInfo.bmiHeader.biSize = sizeof(bmpInfo.bmiHeader);

    //Get the BITMAPINFO structure from the bitmap
    // I believe this populates the BITMAPINFOHEADER portion of BITMAPINFO
    if (!GetDIBits(deviceContext, bitmap, 0, 0, nullptr, &bmpInfo, DIB_RGB_COLORS))
    {
        return false;
    }

    BYTE *pixels = new BYTE[bmpInfo.bmiHeader.biSizeImage];
    bmpInfo.bmiHeader.biCompression = BI_RGB;

    if (!GetDIBits(deviceContext, bitmap, 0, bmpInfo.bmiHeader.biHeight, (LPVOID)pixels, &bmpInfo, DIB_RGB_COLORS))
    {
        return false;
    }

    if (!image->loadFromMemory(?, ?)) // <-- Not sure what goes here
    {
        return false;
    }

    delete[] pixels;
    ReleaseDC(nullptr, deviceContext);
    return true;
}

I pretty much am trying to update the code from here https://www.codeproject.com/tips/527353/load-an-hbitmap-into-sfml-sf-image-container for SFML2.

This feels like an intuitive solution, but it gives said error:
if (!image->loadFromMemory(pixels, bmpInfo.bmiHeader.biSizeImage))
{
    return false;
}
My guess is this is missing something, since the function isn't called loadFromPixels anymore.

I have about 20+ Tabs of msdn open and am actively trying to understand this hot mess of DDBs and DIBs, until then maybe someone shall ease my pain and point me in the right direction. If I find the solution beforehand I'll make sure to update my post.

Kind Regards,
Raincode

Pages: [1] 2 3 ... 8
anything