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

Pages: [1]
1
General / fps spikes
« on: May 08, 2014, 02:13:29 am »
hello guys, Im not sure if I post this thread in correct category but I hope I do.

basically, my movement isn't smooth. I believe this happens because of huge fps spikes



...and here comes the code(which is very simple)
http://pastebin.com/qCkbWj0t

some more informations:
- i5
- gt330m
- ssd ocz drive
- windows 8.1
- visual studio express 2013
- sfml 2.1 built by me using cmake
- no difference between static or dynamic libs or release/debug


2
General / Re: diagonal movement = little shaking
« on: January 23, 2014, 06:37:04 am »
hello again.

I should have said this before but I have class Engine which has "update" method.

I have changed few things and now it looks like this:
void CEngine::run()
{
        while (window->isOpen())
        {
                handleEvents()
                update(m_deltatime.getElapsedTime());
                m_deltatime.restart();
                render();
        }
}

void CEngine::update(sf::Time deltatime)
{
        m_player->update(deltatime.asSeconds());
}

Player "update" method:
void CPlayer::update(float deltatime)
{
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
        {
                m_sprite.setTextureRect(sf::IntRect(42, 0, 42, 42));
                m_vel.y = -169;
        }

        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
        {
                m_sprite.setTextureRect(sf::IntRect(0, 0, 42, 42));
                m_vel.y = 169;
        }

        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
        {
                m_sprite.setTextureRect(sf::IntRect(84, 0, 42, 42));
                m_vel.x = -169;

        }

        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
        {
                m_sprite.setTextureRect(sf::IntRect(126, 0, 42, 42));
                m_vel.x = 169;
        }


        if ((m_vel.x != 0) && (m_vel.y != 0)) m_vel /= sqrt(2.f);
        m_sprite.move(m_vel.x*deltatime, m_vel.y*deltatime);

        if (m_vel.x != 0) m_vel.x = 0;
        if (m_vel.y != 0) m_vel.y = 0;


}

Slight difference, maybe I have to live with that :D

3
General / diagonal movement = little shaking
« on: January 23, 2014, 04:30:20 am »
hello everyone!
I have a problem with my movement system.

        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
        {
                m_sprite.setTextureRect(sf::IntRect(42, 0, 42, 42));
                m_vel.y = -4;
        }

        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
        {
                m_sprite.setTextureRect(sf::IntRect(0, 0, 42, 42));
                m_vel.y = 4;
        }

        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
        {
                m_sprite.setTextureRect(sf::IntRect(84, 0, 42, 42));
                m_vel.x = -4;

        }

        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
        {
                m_sprite.setTextureRect(sf::IntRect(126, 0, 42, 42));
                m_vel.x = 4;
        }


        if ((m_vel.x != 0) && (m_vel.y != 0)) m_vel /= sqrt(2.f);
        m_sprite.move(m_vel.x, m_vel.y);

        if (m_vel.x != 0) m_vel.x = 0;
        if (m_vel.y != 0) m_vel.y = 0;
        }

My movement is very smooth when I move in straight lines but in other cases my character starts shaking.
I believe this line
if ((m_vel.x != 0) && (m_vel.y != 0)) m_vel /= sqrt(2.f);
is responsible for this issue. However I can't just delete it but I also want to get rid of this little shaking. Any ideas how can I do that?



Pages: [1]
anything