Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Tetris clone lag after moving window  (Read 1814 times)

0 Members and 2 Guests are viewing this topic.

TmCrafz

  • Newbie
  • *
  • Posts: 4
    • View Profile
Tetris clone lag after moving window
« on: July 14, 2014, 08:48:36 pm »
Hi  :)
I have a little problem with my Tetris clone.
When I move the Window, often my game begin to lag. The framerate fall down to 2-4 fps.
I don´t have any idea what can be the reason of the problem and which part of my code can be part of this.
In my earlier games I didn´t had problems like this.
I use Windows 7, Visual Studio Express 2013 and SFML 2.1.
Thanks for help
Feuerstern


zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Tetris clone lag after moving window
« Reply #1 on: July 14, 2014, 09:45:17 pm »
Show your code where you handle delta time. Or maybe I could try to guess.... zsbzsb pulls out his crystal_ball.exe
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Strelok

  • Full Member
  • ***
  • Posts: 139
    • View Profile
    • GitHub
Re: Tetris clone lag after moving window
« Reply #2 on: July 14, 2014, 10:22:52 pm »
MinimalCodeNotFoundException

TmCrafz

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Tetris clone lag after moving window
« Reply #3 on: July 14, 2014, 11:47:14 pm »
Thanks for the answers.

Show your code where you handle delta time. Or maybe I could try to guess.... zsbzsb pulls out his crystal_ball.exe
I dont use delta time in this game.
I have used frapes to check the frames.

I have find the code who is the problem.
The for loop is to much, and needs to much performance and i lose much fps with this.
But I dont understand why this effect is much higher after moving the window.

bool isStoneOnStoredStone(sf::RectangleShape storedStones[10][22], Stone &actualStone)
{
        for (unsigned y{ 0 }; y != 22; ++y)
                {
                        for (unsigned x{ 0 }; x != 10; ++x)
                        {
                                if ((actualStone.shapeA.getPosition().y + 20.f == storedStones[x][y].getPosition().y && actualStone.shapeA.getPosition().x == storedStones[x][y].getPosition().x) ||
                                        (actualStone.shapeB.getPosition().y + 20.f == storedStones[x][y].getPosition().y && actualStone.shapeB.getPosition().x == storedStones[x][y].getPosition().x) ||
                                        (actualStone.shapeC.getPosition().y + 20.f == storedStones[x][y].getPosition().y && actualStone.shapeC.getPosition().x == storedStones[x][y].getPosition().x) ||
                                        (actualStone.shapeD.getPosition().y + 20.f == storedStones[x][y].getPosition().y && actualStone.shapeD.getPosition().x == storedStones[x][y].getPosition().x))
                                {
                                        return true;
                                }
                        }
                }      
        return false;
}
 

Strelok

  • Full Member
  • ***
  • Posts: 139
    • View Profile
    • GitHub
Re: Tetris clone lag after moving window
« Reply #4 on: July 15, 2014, 03:36:20 am »
Run a profiler and make sure the performance hog is caused by this.
« Last Edit: July 15, 2014, 03:56:23 am by Strelok »