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

Pages: [1]
When I move the camera left/right some green/blue stripes appear.

With VGA screens nothing happens, but with HDMI screens always happens. I had been looking for help in older posts of this forum, and it seems to be an old SFML issue which could be "fixed" rounding the center of the camera to an integer value per frame.

This works great with pixel movement games, but im using box2d and the result of this its crappy.

This is how my game prototype looks without rounding the center of the camera:

And this is how it looks rounding the center of the camera (notice that the "cookie" shakes):

There is an option that fixes the problem of the lines and does not affect the precision of movements?

General / Re: How do i read keyboard keys for every kind of keyboard?
« on: August 15, 2022, 05:24:40 pm »
Thank you, sf::TextEntered is able to read correctly all of my keyboard's keys :), but it will work for every kind of keyboard?

General / How do i read keyboard keys for every kind of keyboard?
« on: August 14, 2022, 05:08:54 pm »
I have been using SFML for a while, and for games its great. But now im working in a text editor and there is a small issue: when i try to read a key like semicolon or tilde, turn out to be other keys on my keyboard.

I guess this happens because my keyboard doesn't have the same key distribution as the english ones (im from Spain and here we have the ñ and ç key).

I fixed the problem by changing the sf::Keyboard::Key code for each key on my keyboard, pressing each key to find out. Now my program can be used by English and Spanish keyboards, but I would like that other types of keyboards could also be adapted (for example Japanese, Arabic...).

Is there any way to know what value sf::Keyboard::Key really has in these cases?

General / I can't load my game resources into SFML with CMake
« on: December 24, 2021, 07:01:34 pm »
I am programming a little game in C ++ using Visual Studio Code with CMake as the Build System. So far there hadn't been any problem with accessing resources, but since I decided to tidy up my project by organizing it in directories, my GetTexture, GetSoundBuffer and GetFont functions are unable to load images from the Resources folder.

Obviously I know that when saving the files in different directories, I had to update the paths. So what at first was "Resources / image.png" became "../../../Resources/image.png", (which did work for all #include directives) but when I run the game I only see the black screen and console showing me messages like Failed to load image "../../../Resources/image.png". Reason: Unable to open file.

I've tried over and over again to rearrange the project but every time I compile this happens. I don't know much about CMake and I don't know if the problem is with my CMakeLists.txt file or with my previously mentioned functions, which I doubt as they worked perfectly before.


sf::Texture& Game::GetTexture(std::string _fileName)
    auto iter = textures.find(_fileName);
    if (iter != textures.end())
        return *iter->second;
    TexturePtr texture = std::make_shared<sf::Texture>();
    textures[_fileName] = texture;
    return *texture;

sf::SoundBuffer& Game::GetSoundBuffer(std::string _fileName)
     auto iter = sounds.find(_fileName);
     if (iter != sounds.end())
         return *iter->second;
     SoundBufferPtr sound = std::make_shared<sf::SoundBuffer>();
     sound->loadFromFile(_fileName);      sounds[_fileName] = sound;
    return *sound;


sf::Font& Game::GetFont(std::string _fileName)
    auto iter = fonts.find(_fileName);
    if (iter != fonts.end())
        return *iter->second;

    FontPtr font = std::make_shared<sf::Font>();
    fonts[_fileName] = font;
    return *font;


cmake_minimum_required(VERSION 3.18)
set(PROJECT_NAME "MyGame")

set(SFML_DIR "${CMAKE_CURRENT_LIST_DIR}/libs/SFML-2.5.1/lib/cmake/SFML")

file(GLOB ALL_REQUIRED_DLL "libs/required_dlls/*.dll")



add_executable(${PROJECT_NAME} ${SOURCE_FILES})

find_package(SFML 2.5.1 COMPONENTS system window graphics network audio REQUIRED)
target_link_libraries(${PROJECT_NAME} sfml-audio sfml-graphics sfml-window sfml-system)

The organization of the project is as follows:

    (Cmake build stuff) 

    (All engine codes, no problem here)

              (All .h files)
              (All .cpp files, here is where i call GetTexture, GetSoundBuffer 
              and GetFont)

      (All the images, sounds and fonts) 


To all this, it is also worth mentioning that I am using Linux.

Pages: [1]