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

Pages: [1] 2
1
Graphics / Re: view.move not smooth enough
« on: December 18, 2014, 07:07:12 am »
Have you tried linear interpolation yet? That's what I use in my 2D platformer and it's very smooth.
Not yet, how to do linear interpolation? Does sfml support it directly? I just can't find from the tutorials.

2
Graphics / Re: view.move not smooth enough
« on: December 18, 2014, 07:05:47 am »
don't use immediate value for move view or other stuff, search inside tutorial or google for use deltatime with sf::Clock.

Like this? But still not smooth enough.
#include "stdafx.h"

int main()
{
        sf::View view(sf::FloatRect(0, 0, 640, 480));
        //view.setViewport(sf::FloatRect(0.25f, 0.25, 0.5f, 0.5f));

        sf::Texture texture;
        texture.loadFromFile("world.png");

        sf::Sprite map(texture);

        sf::Clock clock;
               
        sf::RenderWindow window(sf::VideoMode(1280, 720), "test view");
        window.setFramerateLimit(60);

        sf::RenderTexture render_texture;
        if (!render_texture.create(1280, 720))
        {
                std::cerr << "render_texture.create() failed" << std::endl;
                return -1;
        }

        float speed = 0.1f;

        // run the main loop
        while (window.isOpen())
        {
                sf::Time time_elapsed = clock.restart();

                // handle events
                sf::Event event;
                while (window.pollEvent(event))
                {
                        switch (event.type)
                        {
                        case sf::Event::Closed:
                                window.close();
                                break;
                        default:
                                break;
                        }
                }

                float delta = speed * time_elapsed.asMilliseconds();

                if (sf::Keyboard::isKeyPressed(sf::Keyboard::W))
                {
                        view.move(0, -delta);
                }
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::A))
                {
                        view.move(-delta, 0);
                }
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::S))
                {
                        view.move(0, delta);
                }
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::D))
                {
                        view.move(delta, 0);
                }

                render_texture.clear();
                render_texture.setView(view);
                render_texture.draw(map);
                render_texture.display();
               
                const sf::Texture& texture = render_texture.getTexture();

                sf::Sprite sprite(texture);
                window.draw(sprite);
                window.display();
        }

        return 0;
}
 

3
Graphics / view.move not smooth enough
« on: December 14, 2014, 08:58:02 am »
BTW, if the line below is commented out,  it will be fast enough:
window.setFramerateLimit(60);

-----------------------------------------------------

When navigating on the map, it is not smooth enough, especially when the resolution  of the view is high.
Any way to optimize? Thanks.

int main()
{
        sf::View view(sf::FloatRect(0, 0, 1280, 720));

        sf::Texture texture;
        texture.loadFromFile("world.png");

        sf::Sprite map(texture);

        sf::RenderWindow window(sf::VideoMode(640, 480), "test view");
        window.setFramerateLimit(60);

        // run the main loop
        while (window.isOpen())
        {
                // handle events
                sf::Event event;
                while (window.pollEvent(event))
                {
                        switch (event.type)
                        {
                        case sf::Event::Closed:
                                window.close();
                                break;
                        default:
                                break;
                        }
                }

                if (sf::Keyboard::isKeyPressed(sf::Keyboard::W))
                {
                        view.move(0, -4);
                }
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::A))
                {
                        view.move(-4, 0);
                }
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::S))
                {
                        view.move(0, 4);
                }
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::D))
                {
                        view.move(4, 0);
                }

                window.clear();

                window.setView(view);
                window.draw(map);

                window.display();
        }

        return 0;
}
 

4
If it is just for installing, then no problem.
Some how, I agree that the examples should not be modified, they should be in plan for installing.
My original point is that hoping it is perfect in the viewpoint, I mean when it is as a project, it should be able to compile and run. Now it should not be.

5
OK, this is fine enough to generate the bin files with header files.
If the examples' projects can include the "resources" directories, it'll be better.
It'll e even better if the examples' projects could be run after building in Visual Studio, I mean they can find the dlls.

7
For example, in the example "pong", there is a "resource" directory, in which there are two files (ball.wav & sansation.ttf), after building, in the project directory, there is no "resource" directory, but the directory is of course part of the project.

8
The resource directory is also a part of a project.

9
The issue is that it has been done when installing, why not when generating the solution for vs2013?

10
Its not a problem for anyone with a well structured development environment actually. This "problem" isnt specific to SFML, its how it works for everything, especially on windows.

However, like with *Nix, you can just chuck your dlls into system32 and you dont have this problem anymore, but dont do that.

Its also worth noting that when you link statically, you also do not have this problem, you should consider doing that if this bothers you so much.

But when I run cmake -P cmake_install.cmake, everything needed is copied, including resource directories and all the dlls.

11
Yes, all the misc things, it makes inefficiency.
However it is not a big problem for examples.

12
This is not very efficient, when the example doesn't run, it depends on the error messages from the development tools to solve the problem. Fortunately, the error messages helps here. Copying the resource directory is just a must-to-do, why not copy it automatically? Setting the path to find the dll or copying the dll into the exe directory or any other methods needs decisions. Fortunately these are for examples.

13
Graphics / Re: Does SFML support partially refresh/redraw?
« on: December 10, 2014, 08:05:05 am »
Maybe a little problem, there are at least two solutions for the example to be able to run, e.g. set the environment in debugging in property page or copy the dll into the exe directory, it needs some little comparison to choose a better way. When the example just can not run, it'll depends on the error message of the develop tools, fortunately the error message help in the case. However it is not the most efficient way.

14
When it doesn't running, I have to find the problems, this is not so efficient, if the author can refine the CMake file, it'll be much more efficient for others.

15
Develop Environment:
    Visual Studio 2013
    Windows 7
    Debug

0. In project/property page/Debugging set Environment to ../../lib/Debug
1. copy the resource directory to the project directory if there is one

Why not to make it automatic?
Thanks.

Pages: [1] 2