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

Pages: [1]
1
Keep pressing the left arrow key super fast and you would see that the blowing cycle is not complete. (he should hold his axe upside once between each cycle).

2
I have tried your solution. But sadly the problem still persists :'(

3
Can we expect android/ios support in SFML 3? About when is it gonna come out?

4
General / Update same sprite over several textures over several frames
« on: January 24, 2022, 09:25:25 am »
Asking for help to the experienced developers.

What I have: I have a single sprite. And I have created a standalone single file program to demonstrate my case.

About the sprite: That sprite is supposed to be a woodcutter. He is panting. When the left arrow key is pressed, he would blow his axe. For this purpose, I have 4 different textures of the woodcutter so that I can use them on the same sprite depending on the passed time and user input.

My problem: So far, my program works. But not as expected. The process of "blowing the axe" does not work perfectly as expected I mean is a bit sluggish and don't update correctly. I am sure I am doing something wrong or not following the most preffered way. Run it once and you would know what I am talking about. If anyone kind enough, please edit my code (62 lines total) so that everything works perfectly :'(

I have uploaded the 4 textures here in google site. You can directly download them and get them on work.
https://sites.google.com/view/metalinmyveins

The program is here:
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>

int main()
{
  sf::RenderWindow window{sf::VideoMode{1366, 768}, "Test", sf::Style::Fullscreen};
  window.setMouseCursorVisible(false);
  window.setKeyRepeatEnabled(false);
 
  sf::Clock clock;
  sf::Time timeLag1{sf::Time::Zero};
  sf::Time timeLimit1{sf::seconds(0.3f)};
  bool flag{true};

  bool blow{false};
  int blowMotionCounter{0};
  sf::Clock blowClock;
  sf::Time blowTimeLag{sf::Time::Zero};
  sf::Time blowTimeLimit{sf::seconds(0.06f)};

  sf::Texture p11, p12, p13, p14;
  p11.loadFromFile("player11.png");
  p12.loadFromFile("player12.png");
  p13.loadFromFile("player13.png");
  p14.loadFromFile("player14.png");
 
  sf::Sprite sp;

  while (window.isOpen())
  {
    sf::Event event;
    while (window.pollEvent(event))
    {
      if (event.type == sf::Event::Closed){ window.close(); break; }
      if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)){ window.close(); break; }
      if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)){ blow = true; break; }
    }

    timeLag1 += clock.restart();
    blowTimeLag += blowClock.restart();
    if (timeLag1 > timeLimit1)
    {
      timeLag1 = sf::Time::Zero;
      if (flag and !blow){ flag = false; sp.setTexture(p12); }
      else if (!flag and !blow){ flag = true; sp.setTexture(p11); }
      sp.setScale(0.3, 0.3);
    }

    if (blowTimeLag > blowTimeLimit)
    {
      blowTimeLag = sf::Time::Zero;
      if (blow and blowMotionCounter == 0){ ++blowMotionCounter; sp.setTexture(p13); }
      else if (blow and blowMotionCounter == 1){ ++blowMotionCounter; sp.setTexture(p14); }
      else if (blow and blowMotionCounter == 2){ blowMotionCounter = 0; blow = false; sp.setTexture(p13); }
    }

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

5
General / Is there a working way to develop simple SFML game for android?
« on: January 08, 2022, 04:42:46 am »
The title says it all. Is it possible in any way? The doc says "....and soon for android and ios". How much time does it mean by soon?

6
General / Re: I can't load my game resources into SFML with CMake
« on: January 01, 2022, 09:23:37 pm »
If I understand you correctly, SFML is unable to access the resources in your program. I have a workaround in mind. Although I am not sure if it would work or not. Just try it and let me know.

Suppose you have all your resources in a folder called 'media' which is situated in cmake source path. Then simply add this line in your CMakeLists.txt.
.....
.....
set(CMAKE_CXX_STANDARD 17)
# add this line
include_directories(${CMAKE_SOURCE_DIR}/media)
.....
.....
 

Now you should be able to access the resources from anywhere of your programs if you have done the other cmake parts correctly. For example you should be able to load your resources like this:
someTexture.loadFromFile("media/Graphics/background.png");
 

Tell me if it worked.
(But how come you are using linux? I see you linking dlls)

7
General / Memory leak in SFML 2.5.1 hello world program in Ubuntu 20.04
« on: January 01, 2022, 08:59:49 pm »
So I was testing the memory usage of SFML hello world program. This is the program:
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Window/Event.hpp>
#include <SFML/Window/Keyboard.hpp>
#include <SFML/Window/VideoMode.hpp>
#include <SFML/Window/WindowStyle.hpp>

int main()
{
  sf::RenderWindow window{sf::VideoMode{1366, 768}, "Test", sf::Style::Fullscreen};

  while (window.isOpen())
  {
    sf::Event event;
    while (window.pollEvent(event))
    {
      if (event.type == sf::Event::Closed){ window.close(); }
      if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)){ window.close(); }
    }

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

I did this to compile it:
clang++ test.cxx -o vimbin -O2 -std=c++20 -Wall -ggdb3 -lsfml-graphics -lsfml-window -lsfml-system

Then I did this to check for any memory leaks using valgrind:
valgrind --leak-check=full ./vimbin

This is the portion of valgrind output after I ran the binary under valgrind for 10 seconds:
==10183== HEAP SUMMARY:
==10183==     in use at exit: 209,042 bytes in 2,764 blocks
==10183==   total heap usage: 924,026 allocs, 921,262 frees, 56,553,314 bytes allocated

==10183== LEAK SUMMARY:
==10183==    definitely lost: 352 bytes in 1 blocks
==10183==    indirectly lost: 3,056 bytes in 21 blocks
==10183==      possibly lost: 0 bytes in 0 blocks
==10183==    still reachable: 205,634 bytes in 2,742 blocks
==10183==         suppressed: 0 bytes in 0 blocks
==10183== Reachable blocks (those to which a pointer was found) are not shown.
==10183== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==10183==
==10183== For lists of detected and suppressed errors, rerun with: -s
==10183== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 2 from 2)
 

And this is the portion of valgrind output after I ran the binary under valgrind for about 60 seconds:
==10245== HEAP SUMMARY:
==10245==     in use at exit: 215,890 bytes in 2,800 blocks
==10245==   total heap usage: 1,152,687 allocs, 1,149,887 frees, 54,421,989 bytes allocated

==10245== LEAK SUMMARY:
==10245==    definitely lost: 592 bytes in 2 blocks
==10245==    indirectly lost: 9,664 bytes in 56 blocks
==10245==      possibly lost: 0 bytes in 0 blocks
==10245==    still reachable: 205,634 bytes in 2,742 blocks
==10245==         suppressed: 0 bytes in 0 blocks
==10245== Reachable blocks (those to which a pointer was found) are not shown.
==10245== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==10245==
==10245== For lists of detected and suppressed errors, rerun with: -s
==10245== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 2 from 2)
 

So my questions are: Should I be worried about it? Are the leaks caused by SFML itself or any other library that SFML is dependant on?

8
General / Re: Cross compiling SFML project in ubuntu
« on: December 20, 2021, 04:10:32 pm »
Look I need help :'( This is my new approach:

1. i686-w64-mingw32-g++ -DSFML_STATIC -c -I/usr/local/include main.cxx
2. i686-w64-mingw32-g++ main.o -L/usr/local/lib -lFLAC -lfreetype -logg -lopenal32 -lsfml-audio-s -lsfml-graphics-s -lsfml-system -lsfml-network -lsfml-window -lvorbis -lvorbisenc -lvorbisfile

output:
/usr/bin/i686-w64-mingw32-ld: main.o:main.cxx:(.text+0x7b): undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
/usr/bin/i686-w64-mingw32-ld: main.o:main.cxx:(.text+0xaa): undefined reference to `sf::String::String(char const*, std::locale const&)'
/usr/bin/i686-w64-mingw32-ld: main.o:main.cxx:(.text+0x132): undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
/usr/bin/i686-w64-mingw32-ld: main.o:main.cxx:(.text+0x160): undefined reference to `sf::Window::isOpen() const'
/usr/bin/i686-w64-mingw32-ld: main.o:main.cxx:(.text+0x188): undefined reference to `sf::Window::pollEvent(sf::Event&)'
/usr/bin/i686-w64-mingw32-ld: main.o:main.cxx:(.text+0x1a6): undefined reference to `sf::Window::close()'
/usr/bin/i686-w64-mingw32-ld: main.o:main.cxx:(.text+0x1db): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
/usr/bin/i686-w64-mingw32-ld: main.o:main.cxx:(.text+0x1f4): undefined reference to `sf::RenderTarget::clear(sf::Color const&)'
/usr/bin/i686-w64-mingw32-ld: main.o:main.cxx:(.text+0x204): undefined reference to `sf::Window::display()'
/usr/bin/i686-w64-mingw32-ld: main.o:main.cxx:(.text+0x216): undefined reference to `sf::RenderWindow::~RenderWindow()'
/usr/bin/i686-w64-mingw32-ld: main.o:main.cxx:(.text+0x2a5): undefined reference to `sf::RenderWindow::~RenderWindow()'
collect2: error: ld returned 1 exit status

NOTE: I also tried this way:
i686-w64-mingw32-g++ main.o /usr/local/lib/libFLAC.a /usr/local/lib/libfreetype.a /usr/local/lib/libogg.a .........

Still same result.

Why can't the linker detect the archive files? Those files (libogg.a, libfreetype.a libsfml-system-s.a etc etc) are in /usr/local/lib. I am not finding any clue about what should I do now.

9
General / Re: Cross compiling SFML project in ubuntu
« on: December 20, 2021, 11:02:59 am »
I just added '#define SFML_STATIC' on the top of main.cxx. Now the errors are even more bigger (undefined reference to glClearColor, glMatrixMode etc etc). Are these errors caused by unmatched compiler version?

10
General / Cross compiling SFML project in ubuntu
« on: December 20, 2021, 10:32:12 am »
Hello I am trying to cross compile a simple SFML hello world program in ubuntu using mingw compiler.

What I did:
1. Created a test directory (mkdir sfmltest)
2. Moved the test program main.cxx in sfmltest (mv ~/main.cxx sfmltest)
3. Unzipped the windows build of SFML (GCC 7.3.0 MinGW (SEH) - 64-bit)
4. Copied the dlls of bin/ folder in sfmltest
5. Copied the include/ directory in /usr/local/include
6. Copied the lib/ directory in /usr/local/lib

7. Then I did this:
    x86_64-w64-mingw32-g++ main.cxx -o binary.exe -I/usr/local/include -L/usr/local/lib -lsfml-audio-s -lsfml-graphics-s -lsfml-network-s -lsfml-system-s -lsfml-window-s

8. And this is the output:
    /usr/bin/x86_64-w64-mingw32-ld: /tmp/ccBIUR3s.o:main.cxx:(.text+0x34): undefined reference to `__imp__ZN2sf9VideoModeC1Ejjj'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccBIUR3s.o:main.cxx:(.text+0x67): undefined reference to `__imp__ZN2sf6StringC1EPKcRKSt6locale'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccBIUR3s.o:main.cxx:(.text+0xe8): undefined reference to `__imp__ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccBIUR3s.o:main.cxx:(.text+0x116): undefined reference to `__imp__ZNK2sf6Window6isOpenEv'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccBIUR3s.o:main.cxx:(.text+0x132): undefined reference to `__imp__ZN2sf6Window9pollEventERNS_5EventE'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccBIUR3s.o:main.cxx:(.text+0x14d): undefined reference to `__imp__ZN2sf6Window5closeEv'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccBIUR3s.o:main.cxx:(.text+0x17b): undefined reference to `__imp__ZN2sf5ColorC1Ehhhh'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccBIUR3s.o:main.cxx:(.text+0x196): undefined reference to `__imp__ZN2sf12RenderTarget5clearERKNS_5ColorE'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccBIUR3s.o:main.cxx:(.text+0x1a6): undefined reference to `__imp__ZN2sf6Window7displayEv'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccBIUR3s.o:main.cxx:(.text+0x1bb): undefined reference to `__imp__ZN2sf12RenderWindowD1Ev'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccBIUR3s.o:main.cxx:(.text+0x206): undefined reference to `__imp__ZN2sf12RenderWindowD1Ev'
collect2: error: ld returned 1 exit status

So what's wrong here? My end target is to create a statically linked standalone binary which will run in windows.

Pages: [1]