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

Pages: [1] 2 3 4
1
General / Re: Jerky gameplay
« on: December 15, 2014, 11:05:53 pm »
Thanks for the input, just tested without frame-rate limit
You should never use both vsync and frame-rate limit both in the same program. They interact badly and if that's what you were doing (which I get the impression you were, since vsync is usually the best way to counter tearing), it is not surprising that you were having issues. This is well documented btw.

I know about this, I am not using both, enabling v-sync doesn't work for me anyways even though my display driver is setup properly.

2
General / Re: Jerky gameplay
« on: December 15, 2014, 05:46:07 pm »
Thanks for the input, just tested without frame-rate limit and then it is pretty much smooth and the tearing doesnt happen that often. Also the borders of the square become kinda fuzzy when moving and sharp when not moving but that is because you are moving using floating points I guess. So it seems like the program is skipping frames, is this normal or is it just me?

3
General / Re: Jerky gameplay
« on: December 15, 2014, 10:20:18 am »
Well let me try to explain it in more detail:

When I stand still there is no problem, no flashy things or screen tearing (only visible on the sprite.) When I move the character it moves in the given direction but then it becomes slightly jerky like it seems to skip a couple of pixels so it isn't smooth maybe because it skips a couple of frames? Or just skips the pixels in general maybe due to using floats? Also another effect appears where it looks like the Sprite is tearing for instance when I move to the right the top half would be something like 2 pixels to the left and the bottom half 2 pixels to the right and then it becomes normal again. It seems this tearing and jerkiness appear at random intervals.

It seems like other people have no problems with my code? I have updated SFML and my graphics driver so maybe it is a bug that has to do this the support of my video-card / processor? Games like League of Legends run fine for instance. I posted my computer stats in an earlier post.

4
General / Re: Jerky gameplay
« on: December 14, 2014, 09:43:00 pm »
How would you go about this using deltatime?
You could round() or floor() the value when setting the sprite position if you want to keep it to an integer value.
This can improve the sprite's display quality but is more likely to cause jerky movement than to solve it.
'

Alright, do you have any insight in my problem? You seem like a well established community member, ever stumbled across something like this?

5
General / Re: Jerky gameplay
« on: December 14, 2014, 12:56:47 pm »
How would you go about this using deltatime? Because that is a floating point number. In my example my player velocity.x would be something like 1.5.

6
General / Re: Jerky gameplay
« on: December 13, 2014, 11:08:36 pm »
I am not sure if this will help but this is my DxDiag, anyone got an idea what causes the tearing and jerky movement?

7
General / Re: Jerky gameplay
« on: December 13, 2014, 02:22:11 pm »
Your example is not jerky on my machine.

You could try logging the time per frame and see if it ever jumps to a large or small amount than the average. Maybe your machine is having a hard time keep the framerate at 60fps?

Timed my timestep with setFramerateLimit(60)

8
General / Re: Jerky gameplay
« on: December 11, 2014, 01:50:21 am »
Hihi, no I know how to seperate the logic and render and to apply a fixed timestep. But again this does not resolve the issue. Maby its my machine? I am really not sure. It seems everyone else can run it just fine? I can play League of Legends on all low settings with 60 fps and super smooth, but can't have a square move across my screen without being sometimes 'jerky' and the 'tearing'. So weird.

9
General / Re: Jerky gameplay
« on: December 10, 2014, 10:38:46 pm »
Your example is not jerky on my machine.

You could try logging the time per frame and see if it ever jumps to a large or small amount than the average. Maybe your machine is having a hard time keep the framerate at 60fps?

Yeah I will check that tomorrow and post back, do you experience any 'tearing' in the shape at any point?

10
General / Re: Jerky gameplay
« on: December 10, 2014, 03:16:13 pm »
Still have not resolved this problem. I have no clue what causes this. So here a very minimal example. It is harder to see with shapes instead of images but it is still there, some sort of image/sprite tearing (maby screen tearing but the background is not moving so can't confirm if it applies to everything) and sometimes it is a bit 'jerky'

EDIT: Updating SFML (10-12-2014) from GitHub also did not help.

#include <SFML/Graphics.hpp>

int main() {
  sf::RenderWindow window(sf::VideoMode(800, 600), "Jycerian", sf::Style::Close);
  window.setFramerateLimit(60);

  bool isMovingUp = false;
  bool isMovingDown = false;
  bool isMovingLeft = false;
  bool isMovingRight = false;

  sf::RectangleShape rect;
  rect.setSize(sf::Vector2f(32, 16));
  rect.setFillColor(sf::Color::Red);
  rect.setOutlineThickness(3);
  rect.setOutlineColor(sf::Color::Black);

  float moveSpeed = 100.f;

  sf::Clock clock;
  while (window.isOpen()) {
    sf::Event event;
    while (window.pollEvent(event)) {
      if (event.type == sf::Event::Closed)
        window.close();

      if (event.type == sf::Event::KeyPressed) {
        if (event.key.code == sf::Keyboard::W)
          isMovingUp = true;
        if (event.key.code == sf::Keyboard::S)
          isMovingDown = true;
        if (event.key.code == sf::Keyboard::A)
          isMovingLeft = true;
        if (event.key.code == sf::Keyboard::D)
          isMovingRight = true;
      }

      if (event.type == sf::Event::KeyReleased) {
        if (event.key.code == sf::Keyboard::W)
          isMovingUp = false;
        if (event.key.code == sf::Keyboard::S)
          isMovingDown = false;
        if (event.key.code == sf::Keyboard::A)
          isMovingLeft = false;
        if (event.key.code == sf::Keyboard::D)
          isMovingRight = false;
      }
    }

    sf::Vector2f velocity(0, 0);
    if (isMovingUp)
      velocity.y = -moveSpeed;
    if (isMovingDown)
      velocity.y = moveSpeed;
    if (isMovingLeft)
      velocity.x = -moveSpeed;
    if (isMovingRight)
      velocity.x = moveSpeed;

    rect.move(velocity * clock.restart().asSeconds());

    window.clear(sf::Color::White);
    window.draw(rect);
    window.display();
  }
}

11
General / Re: Jerky gameplay
« on: November 25, 2014, 09:58:48 am »
everyone just tells em to enable v-sync..which I have.
If it's a problem that v-sync that could solve, it's possible that v-sync is not getting used. Remember that SFML just tells your graphics driver that it thinks it should use v-sync; it's up to your graphics card's drivers whether or not to listen (there are often settings to tell the driver to listen to apps - you may need to make sure they aren't getting overridden).

Thanks, didn't think about it that much. Checked my AMD settings and it's set to off unless specified by an application so that should be ok I suppose.

12
General / Re: Jerky gameplay
« on: November 24, 2014, 09:52:07 am »
I think I see what you mean by "jerky". This has been posted about on the forum before, actually. I'm not sure what the solution was, if there was one.

I have a request for you. Add this line of code:
window.setTitle("*");
(I put it before window.setView(camera);)
Let me know if anything changes.

Yeah I searched the forum but could't really find anything that would help me because everyone just tells em to enable v-sync..which I have. Also the setTitle did not change anything :C

13
General / Re: Jerky gameplay
« on: November 23, 2014, 07:26:37 pm »
Also has this weird jerky movement and screen tearing in another game I made but I decided to ignore it. Now I finally want to fix it somehow so I am able to get smooth gameplay in my next game.

I have an Asus k52n laptop running windows 7 64bit.

Cpu: AMD Athlon X2 P320 2,1GHz
Memory: 4 GB
Videocard: AMD Radeon HD 4200

Example:

#include <SFML/Graphics.hpp>

// 1 second / 60
const sf::Time timePerFrame = sf::seconds( 1.f / 60.f );

int main() {
  // Init window
  sf::RenderWindow window( sf::VideoMode( 720, 540 ), "Demo" );
  window.setVerticalSyncEnabled( true );

  // Init variables
  float playerSpeed = 200.f;
  bool isMovingUp = false;
  bool isMovingDown = false;
  bool isMovingLeft = false;
  bool isMovingRight = false;

  // Load images
  sf::Texture background_tex;
  if ( !background_tex.loadFromFile( "background.png" ) ) {
    // Error handling..
  }

  sf::Texture player_tex;
  if ( !player_tex.loadFromFile( "player.png" ) ) {
    // Error handling..
  }

  // Setup sprites
  sf::Sprite background;
  background.setTexture( background_tex );

  sf::Sprite player;
  player.setTexture( player_tex );
  player.setOrigin( player.getLocalBounds().width / 2,
    player.getLocalBounds().height / 2 );

  // Create view and set size equal to window
  sf::View camera;
  camera.setSize( sf::Vector2f(window.getSize()) );

  // Main loop, update at 60. Render at unlimited but locked
  // with v-sync at 60.
  sf::Clock clock;
  sf::Time timeSinceLastUpdate = sf::Time::Zero;
  while ( window.isOpen() ) {
    timeSinceLastUpdate += clock.restart();
    while ( timeSinceLastUpdate > timePerFrame ) {
      timeSinceLastUpdate -= timePerFrame;

      // event handling
      sf::Event event;
      while ( window.pollEvent( event ) ) {
        if ( event.type == sf::Event::Closed )
          window.close();

        if ( event.type == sf::Event::KeyPressed ) {
          if ( event.key.code == sf::Keyboard::Up )
            isMovingUp = true;
          else if ( event.key.code == sf::Keyboard::Down )
            isMovingDown = true;
          else if ( event.key.code == sf::Keyboard::Left )
            isMovingLeft = true;
          else if ( event.key.code == sf::Keyboard::Right )
            isMovingRight = true;
        }

        if ( event.type == sf::Event::KeyReleased ) {
          if ( event.key.code == sf::Keyboard::Up )
            isMovingUp = false;
          else if ( event.key.code == sf::Keyboard::Down )
            isMovingDown = false;
          else if ( event.key.code == sf::Keyboard::Left )
            isMovingLeft = false;
          else if ( event.key.code == sf::Keyboard::Right )
            isMovingRight = false;
        }
      }

      // update logic
      camera.setCenter( player.getPosition() );

      sf::Vector2f movement( 0.f, 0.f );
      if ( isMovingUp )
        movement.y -= playerSpeed;
      if ( isMovingDown )
        movement.y += playerSpeed;
      if ( isMovingLeft )
        movement.x -= playerSpeed;
      if ( isMovingRight )
        movement.x += playerSpeed;

      player.move( movement * timePerFrame.asSeconds());
    }

    // render
    window.setView( camera );

    window.clear();
    window.draw( background );
    window.draw( player );
    window.display();
  }
  return 0;
}
 

14
General / Re: Jerky gameplay
« on: November 19, 2014, 09:58:00 pm »
Here is a small example that should run reasonably smooth and without tearing. Does it?
Just tried this out. Needs more balls  :P
The ball doesn't collide properly with the window edge. I suggest you change the ball's origin from:
ball.setOrigin(ball_radius / 2, ball_radius / 2);
to
ball.setOrigin(ball.getRadius(), ball.getRadius());
to correctly use the filled circle's radius (ball_radius - 4) to position the origin.

An easy oversight to make  ;)

Please keep it on-topic ;) that is not my example hihi.

15
General / Re: Jerky gameplay
« on: November 19, 2014, 04:07:13 pm »
Here is a small example that should run reasonably smooth and without tearing. Does it?

Also pretty jerky on my machine, windows 7. Can you run my executable smoothly?

Pages: [1] 2 3 4
anything