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

Pages: [1]
1
Graphics / Re: App freezes after few seconds
« on: June 03, 2020, 11:09:43 am »
void Game::GameLoop()
{
    sf::Event currentEvent;
    while(mainWindow.pollEvent(currentEvent))
    {
        if (currentEvent.type == sf::Event::Closed)
            mainWindow.close();

        switch(gameState)
        {
            case Game::ShowingMenu:
            {
                ShowMenu();
                break;
            }
            case Game::ShowingSplash:
            {
                ShowSplashScreen();
                break;
            }
            case Game::Playing:
            {
                while(gameState!=ShowingMenu)
                {
                    mainWindow.clear(sf::Color(80,70,200));
                    player1.Draw(mainWindow);
                    mainWindow.display();

                    if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
                    {
                        ShowMenu();
                        gameState = ShowingMenu;
                        cout << 1;
                    }
                    else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
                    {
                        player1.mirror(false);
                        mainWindow.clear(sf::Color(80,70,200));
                        player1.moving(-2,0);
                        player1.Draw(mainWindow);
                        mainWindow.display();
                        cout << 2;
                    }
                    else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
                    {
                        player1.mirror(true);
                        mainWindow.clear(sf::Color(80,70,200));
                        player1.moving(2,0);
                        player1.Draw(mainWindow);
                        mainWindow.display();
                        cout << 3;
                    }
                }

                if(currentEvent.type == sf::Event::Closed)
                    gameState=Game::Exiting;
            }
        }
    }
}

2
Graphics / App freezes after few seconds
« on: June 02, 2020, 10:36:33 pm »
Hi.

After running a program, I get freeze thing (Aplication stops to response) and I have to terminate it by system manager. In CodeBlocks it says
Process returned -805306369 (0xCFFFFFFF)

case Game::Playing:
{
    while(gameState!=ShowingMenu)
    {
        mainWindow.clear(sf::Color(80,70,200));
        player1.Draw(mainWindow);
        mainWindow.display();

        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
        {
            ShowMenu();
            gameState = ShowingMenu;
            cout << 1;
        }
        else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
        {
            player1.mirror(false);
            mainWindow.clear(sf::Color(80,70,200));
            player1.moving(-2,0);
            player1.Draw(mainWindow);
            mainWindow.display();
            cout << 2;
        }
        else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
        {
            player1.mirror(true);
            mainWindow.clear(sf::Color(80,70,200));
            player1.moving(2,0);
            player1.Draw(mainWindow);
            mainWindow.display();
            cout << 3;
        }
    }

    if(currentEvent.type == sf::Event::Closed)
        gameState=Game::Exiting;
}
 

it works fine in about 5-10 seconds, and after it hangs (freezes). What can couse such behaviour?

Thanks Mike.

3
General discussions / Re: Init of static member object
« on: May 24, 2020, 05:56:10 pm »
I get error:

... error: use of deleted function 'sf::RenderWindow::RenderWindow(const sf::RenderWindow&)'|
... note: 'sf::RenderWindow::RenderWindow(const sf::RenderWindow&)' is implicitly deleted because the default definition would be ill-formed:|

4
General discussions / Re: Init of static member object
« on: May 24, 2020, 05:33:25 pm »
I tried, but there is no static constructor defined for RenderWindow :(

5
General discussions / Init of static member object
« on: May 24, 2020, 04:42:14 pm »
Hi.

I have class in which I have static member, which is RenderWindow object. How can I initialize it?

class A
{
  public:
  static sf::RenderWindow window;
};

How Can I init it in my program?
Thanks

Pages: [1]