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

Pages: [1]
1
General / Gameloops and timing, smooth rotation
« on: December 13, 2011, 05:06:42 pm »
Quote from: "Atomical"
try the built in window.SetFrameratelimit(FPS)


No this didn't work, also the gameloop is already limited by the FPS.
Any other ideas?

2
General / Gameloops and timing, smooth rotation
« on: November 28, 2011, 04:17:53 pm »
Oops my bad, sleep_time should be an integer: new code

From the output it looks to me like everything is working as expected.
Every (40 +- 1) ms the sprite is rotated by 3.6 degrees, I don't understand why the rotation looks so choppy.
Code: [Select]
0, 1
3.6, 40
7.2, 80
10.8, 120
14.4, 161
18, 201
21.6, 241
25.2, 281
28.8, 320
32.4, 361
36, 401
39.6, 441
43.2, 481
46.8, 521
50.4, 561
54, 601
57.6, 640
61.2, 681
64.8, 720
68.4, 760
72, 801
75.6, 841
79.2, 880
82.8, 921
86.4, 961
90, 1000

3
General / Gameloops and timing, smooth rotation
« on: November 27, 2011, 11:27:42 pm »
Ok, I implemented the game loop FPS dependent on Constant Game Speed from the blog article deWiTTERS Game Loop in C++ with SFML2.

It has the same issues.

4
General / Gameloops and timing, smooth rotation
« on: November 25, 2011, 11:09:14 pm »
Goal
Move or rotate a sprite smoothly on the screen with SFML2.

Implementation
This code should rotate the SFML logo sfml-small.png.
Code: [Select]
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "Gameloops and timing");
    window.EnableVerticalSync(true);

    sf::Texture image;
    if (!image.LoadFromFile("sfml-small.png")) {
        return EXIT_FAILURE;
    }
    sf::Sprite sprite(image);
    sprite.Move(window.GetWidth() / 2.0, window.GetHeight() / 2.0);

    const sf::Uint32 FPS = 50;
    const sf::Uint32 SKIP_TICKS = 1000 / FPS;
    sf::Uint32 sleep_time = 0;
    sf::Clock clock;
    sf::Uint32 next_game_tick = clock.GetElapsedTime();

    while (window.IsOpened())
    {
        sf::Event event;
        while (window.PollEvent(event))
        {
            if (event.Type == sf::Event::Closed) {
                window.Close();
            }
        }

        sprite.Rotate(90.f / FPS);

        window.Clear();
        window.Draw(sprite);
        window.Display();

        next_game_tick += SKIP_TICKS;
        sleep_time = next_game_tick - clock.GetElapsedTime();
        if (sleep_time >= 0) {
            sf::Sleep(sleep_time);
        } else {
            // running behind
        }
    }

    return EXIT_SUCCESS;
}


Observations
  • The sprite sometimes randomly jumps back when it should rotate continiously with constant angular velocity
  • The problem is independent of the programming language or operating system
  • I noticed similar issues in a lot of games and physics simulations
Help
What am I doing wrong? Is it inaccurate timing, or is vsync not working? I have no clue what's going on.

5
Graphics / sf::Image default constructor warnings with gdb (Mac OS X)
« on: April 02, 2010, 09:30:15 pm »
Hello, I get some warnings if I step into the default sf::Image constructor when debugging with gdb. (only in Mac OS X Snow Leopard)
Here's the minimal code, using the SFML 1.5 libraries:

Code: [Select]

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow App(sf::VideoMode(640, 480, 32), "SFML Graphics");

    sf::Image image; // this line of code produces warnings

    while (App.IsOpened())
    {
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            if (Event.Type == sf::Event::Closed)
                App.Close();
        }

        App.Clear();
        App.Display();
    }

    return EXIT_SUCCESS;
}



And this is one of a lot of very similar warnings when debugging: (all warnings would fill the entire page probably)

Code: [Select]

warning: Could not find object file "/Users/lucas/release-sfml-1.5/SFML-1.5-sdk-macosx/build/xcode/build/SFML.build/Release/sfml-graphics.build/Objects-normal/i386/Color.o" - no debug information available for "/Users/lucas/release-sfml-1.5/SFML-1.5-sdk-macosx/build/xcode/../../src/SFML/Graphics/Color.cpp".


Note that I don't even have a user named lucas on my system... so what do you think?

Pages: [1]
anything