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 - MichelangeloSFML/

Pages: [1] 2
1
Graphics / Re: Jittery 98 sprites
« on: August 21, 2022, 11:19:21 am »
Thank you sir, I took a quick glance at the link & it looks like it is what I may need exactly.

I have to say that at vsync on & 120HZ (VRR) the 98 images are handled phenomenally on the system. Now I also tried drawing 300+ that are off the screen to the left & right and I did not see a performance hit. How does SFML handle sprites that are drawn off screen?  Images off screen are not really drawn, but only the setPosition calculations are performed or are they actually drawn?

It is hard to believe I don't get a dip in FPS or image stability of the 98 middle images that I do see when I include 100+ images drawn off screen to the L & R (300+ images).

2
Graphics / Re: Jittery 98 sprites
« on: August 18, 2022, 06:21:47 pm »
Thanks. I am testing in debug mode.

I had already tried the NVidia threaded optimization to off & still the same jittery results. What does work for me is vsync on & 120HZ and my tv set to VRR, but not vsync on & 60HZ.

With vsync on & 120HZ I am able to render all the sprites without any jitter. But I would love to be able to get 60FPS to work without vsync & tv on 60HZ (no VRR).

My video card: GTX 1050 Ti
My tv: Sony - 43" class X85J 4K Model:KD43X85J
HDMI on input 3 (eARC/ARC)

When I wake up later I will try another input on my tv.

3
Graphics / Re: Jittery 98 sprites
« on: August 18, 2022, 09:52:42 am »
Here is code with only 1 image & still the same problem of jittery movement.

#include <iostream>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>

using namespace sf;
using namespace std;

int main()
{
    //******************  WINDOW ******************
    Vector2f resolution;
    resolution.x = VideoMode::getDesktopMode().width;
    resolution.y = VideoMode::getDesktopMode().height;

    VideoMode vm(resolution.x, resolution.y);

    RenderWindow window(vm, "TEST", Style::Default);
    window.setFramerateLimit(60);


    //****************** TEXTURES/SPRITES   ******************
    Texture texture;
    texture.loadFromFile("graphics/Image1.png");

    Sprite sprite1;
    sprite1.setTexture(texture);
    sprite1.setScale(.5, .5);
    sprite1.setPosition(0, 400);



    //******************  TEXT  ******************



    //****************** CONFIG  ******************
    Clock clock;

    Time timeSinceLastUpdate = Time::Zero;
    const Time TIME_PER_FRAME = seconds(1.0f / 60.0f);

    const float SPEED_MOVING = 600.0f;

    while (window.isOpen())
    {
        //**********************************************************
        //*******************   KEYBOARD/MOUSE   *******************
        //**********************************************************
        Event event;

        while (window.pollEvent(event))
        {

        }

        //ESC to exit game
        if (Keyboard::isKeyPressed(Keyboard::Escape))
            window.close();

        //**********************************************************
        //*******************       UPDATE       *******************
        //**********************************************************

        timeSinceLastUpdate += clock.restart();
     
        //cout << TIME_PER_FRAME.asSeconds() << endl;

        while (timeSinceLastUpdate > TIME_PER_FRAME)
        {
            timeSinceLastUpdate -= TIME_PER_FRAME;


            if (sprite1.getGlobalBounds().left < -200)
            {
                sprite1.setPosition(2040 , sprite1.getPosition().y);
            }

            sprite1.setPosition(sprite1.getPosition().x - SPEED_MOVING * TIME_PER_FRAME.asSeconds(), sprite1.getPosition().y);
        }

        //**********************************************************
        //*******************       RENDER        *******************
        //**********************************************************
        window.clear();

        window.draw(sprite1);

        window.display();
    }

    return 0;
}

 

4
Graphics / Re: Jittery 98 sprites
« on: August 17, 2022, 01:11:44 pm »
I removed the vector<Sprite> from this one & implemented them as individual objects and yet still it jitters, so it is not the vector. I cannot even get 1 image to move across without stuttering/jitttering at one point or another at 60FPS.

I tried the method from the book & I also tried the method where you just multiply by good old dt.asSeconds() & still the same. I even tried setting a FloatRectangle to the getGlobalBounds() & then setPosition() and still no go.

Code: [Select]
#include <iostream>
#include<vector>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>

using namespace sf;
using namespace std;

float m_SpeedMoving = 600.0f;

int main()
{
    //******************  WINDOW ******************
    Vector2f resolution;
    resolution.x = VideoMode::getDesktopMode().width;
    resolution.y = VideoMode::getDesktopMode().height;

    VideoMode vm(resolution.x, resolution.y);

    RenderWindow window(vm, "TEST", Style::Default);
    window.setFramerateLimit(60);


    //******************    ******************
    Texture texture;
    texture.loadFromFile("graphics/Image1.png");

    Sprite sprite1;
    sprite1.setTexture(texture);
    sprite1.setScale(.5, .5);
    sprite1.setPosition(0, 400);
   
    Sprite sprite2;
    sprite2.setTexture(texture);
    sprite2.setScale(.5, .5);
    sprite2.setPosition(0, 480);

    Sprite sprite3;
    sprite3.setTexture(texture);
    sprite3.setScale(.5, .5);
    sprite3.setPosition(0, 560);

    Sprite sprite4;
    sprite4.setTexture(texture);
    sprite4.setScale(.5, .5);
    sprite4.setPosition(0, 640);

    Sprite sprite5;
    sprite5.setTexture(texture);
    sprite5.setScale(.5, .5);
    sprite5.setPosition(0, 720);


    //FloatRect RectFloatSprite1 = sprite1.getGlobalBounds();
    //FloatRect RectFloatSprite2 = sprite2.getGlobalBounds();
    //FloatRect RectFloatSprite3 = sprite3.getGlobalBounds();
    //FloatRect RectFloatSprite4 = sprite4.getGlobalBounds();
    //FloatRect RectFloatSprite5 = sprite5.getGlobalBounds();
    //FloatRect RectFloatSprite = sprite.getGlobalBounds();



    //******************  TEXT  ******************



    //****************** CONFIG  ******************
    Clock clock;

    Time timeSinceLastUpdate = Time::Zero;
    Time TIME_PER_FRAME = seconds(1.0f / 60.0f);
   

    bool isMovingLeft = false;
    bool isMovingRight = false;

    while (window.isOpen())
    {
        //**********************************************************
        //*******************   KEYBOARD/MOUSE   *******************
        //**********************************************************
        Event event;                       

        //NEEDED, to prevent intial screen blue circle
        while (window.pollEvent(event))
        {

        }

        //ESC to exit game
        if (Keyboard::isKeyPressed(Keyboard::Escape))
            window.close();


        ////*******************   KEYS   *******************
        //Time dt = clock.restart();

        if (Keyboard::isKeyPressed(Keyboard::Left))
        {
            isMovingLeft = true;

            //sprite1.setPosition(sprite1.getPosition().x - m_SpeedMoving * dt.asSeconds(), sprite1.getPosition().y);
            //sprite2.setPosition(sprite2.getPosition().x - m_SpeedMoving * dt.asSeconds(), sprite2.getPosition().y);
            //sprite3.setPosition(sprite3.getPosition().x - m_SpeedMoving * dt.asSeconds(), sprite3.getPosition().y);
            //sprite4.setPosition(sprite4.getPosition().x - m_SpeedMoving * dt.asSeconds(), sprite4.getPosition().y);
            //sprite5.setPosition(sprite5.getPosition().x - m_SpeedMoving * dt.asSeconds(), sprite5.getPosition().y);

            //RectFloatSprite1.left = RectFloatSprite1.left - m_SpeedMoving * dt.asSeconds();
            //RectFloatSprite2.left = RectFloatSprite2.left - m_SpeedMoving * dt.asSeconds();
            //RectFloatSprite3.left = RectFloatSprite3.left - m_SpeedMoving * dt.asSeconds();
            //RectFloatSprite4.left = RectFloatSprite4.left - m_SpeedMoving * dt.asSeconds();
            //RectFloatSprite5.left = RectFloatSprite5.left - m_SpeedMoving * dt.asSeconds();
            ////RectFloatSprite.left = RectFloatSprite.left - m_SpeedMoving * dt.asSeconds();

            //sprite1.setPosition(RectFloatSprite1.left, RectFloatSprite1.top);
            //sprite2.setPosition(RectFloatSprite2.left, RectFloatSprite2.top);
            //sprite3.setPosition(RectFloatSprite3.left, RectFloatSprite3.top);
            //sprite4.setPosition(RectFloatSprite4.left, RectFloatSprite4.top);
            //sprite5.setPosition(RectFloatSprite5.left, RectFloatSprite5.top);
            //sprite.setPosition(RectFloatSprite.left, RectFloatSprite.top);
        }
        else
        {
            isMovingLeft = false;
        }

        if (Keyboard::isKeyPressed(Keyboard::Right))
        {
            isMovingRight = true;

            //sprite1.setPosition(sprite1.getPosition().x + m_SpeedMoving * dt.asSeconds(), sprite1.getPosition().y);
            //sprite2.setPosition(sprite2.getPosition().x + m_SpeedMoving * dt.asSeconds(), sprite2.getPosition().y);
            //sprite3.setPosition(sprite3.getPosition().x + m_SpeedMoving * dt.asSeconds(), sprite3.getPosition().y);
            //sprite4.setPosition(sprite4.getPosition().x + m_SpeedMoving * dt.asSeconds(), sprite4.getPosition().y);
            //sprite5.setPosition(sprite5.getPosition().x + m_SpeedMoving * dt.asSeconds(), sprite5.getPosition().y);

            //RectFloatSprite1.left = RectFloatSprite1.left + m_SpeedMoving * dt.asSeconds();
            //RectFloatSprite2.left = RectFloatSprite2.left + m_SpeedMoving * dt.asSeconds();
            //RectFloatSprite3.left = RectFloatSprite3.left + m_SpeedMoving * dt.asSeconds();
            //RectFloatSprite4.left = RectFloatSprite4.left + m_SpeedMoving * dt.asSeconds();
            //RectFloatSprite5.left = RectFloatSprite5.left + m_SpeedMoving * dt.asSeconds();
            ////RectFloatSprite.left = RectFloatSprite.left + m_SpeedMoving * dt.asSeconds();

            //sprite1.setPosition(RectFloatSprite1.left, RectFloatSprite1.top);
            //sprite2.setPosition(RectFloatSprite2.left, RectFloatSprite2.top);
            //sprite3.setPosition(RectFloatSprite3.left, RectFloatSprite3.top);
            //sprite4.setPosition(RectFloatSprite4.left, RectFloatSprite4.top);
            //sprite5.setPosition(RectFloatSprite5.left, RectFloatSprite5.top);
            //sprite.setPosition(RectFloatSprite.left, RectFloatSprite.top);
        }
        else
        {
            isMovingRight = false;
        }

        //**********************************************************
        //*******************       UPDATE       *******************
        //**********************************************************
       
        timeSinceLastUpdate += clock.restart();
        //Time dt = clock.restart();

        //cout << TIME_PER_FRAME.asSeconds() << endl;

        while (timeSinceLastUpdate > TIME_PER_FRAME)
        {
            timeSinceLastUpdate -= TIME_PER_FRAME;

            if (isMovingLeft)
            {
                sprite1.setPosition(sprite1.getPosition().x - m_SpeedMoving * TIME_PER_FRAME.asSeconds(), sprite1.getPosition().y);
                //sprite2.setPosition(sprite2.getPosition().x - m_SpeedMoving * TIME_PER_FRAME.asSeconds(), sprite2.getPosition().y);
                //sprite3.setPosition(sprite3.getPosition().x - m_SpeedMoving * TIME_PER_FRAME.asSeconds(), sprite3.getPosition().y);
                //sprite4.setPosition(sprite4.getPosition().x - m_SpeedMoving * TIME_PER_FRAME.asSeconds(), sprite4.getPosition().y);
                //sprite5.setPosition(sprite5.getPosition().x - m_SpeedMoving * TIME_PER_FRAME.asSeconds(), sprite5.getPosition().y);

                //RectFloatSprite1.left = RectFloatSprite1.left - m_SpeedMoving * TIME_PER_FRAME.asSeconds();
                //RectFloatSprite2.left = RectFloatSprite2.left - m_SpeedMoving * TIME_PER_FRAME.asSeconds();
                //RectFloatSprite3.left = RectFloatSprite3.left - m_SpeedMoving * TIME_PER_FRAME.asSeconds();
                //RectFloatSprite4.left = RectFloatSprite4.left - m_SpeedMoving * TIME_PER_FRAME.asSeconds();
                //RectFloatSprite5.left = RectFloatSprite5.left - m_SpeedMoving * TIME_PER_FRAME.asSeconds();
                ////RectFloatSprite.left = RectFloatSprite.left - m_SpeedMoving * TIME_PER_FRAME.asSeconds();

                //sprite1.setPosition(RectFloatSprite1.left, RectFloatSprite1.top);
                //sprite2.setPosition(RectFloatSprite2.left, RectFloatSprite2.top);
                //sprite3.setPosition(RectFloatSprite3.left, RectFloatSprite3.top);
                //sprite4.setPosition(RectFloatSprite4.left, RectFloatSprite4.top);
                //sprite5.setPosition(RectFloatSprite5.left, RectFloatSprite5.top);
                //sprite.setPosition(RectFloatSprite.left, RectFloatSprite.top);

            }

            if (isMovingRight)
            {
                sprite1.setPosition(sprite1.getPosition().x + m_SpeedMoving * TIME_PER_FRAME.asSeconds(), sprite1.getPosition().y);
                //sprite2.setPosition(sprite2.getPosition().x + m_SpeedMoving * TIME_PER_FRAME.asSeconds(), sprite2.getPosition().y);
                //sprite3.setPosition(sprite3.getPosition().x + m_SpeedMoving * TIME_PER_FRAME.asSeconds(), sprite3.getPosition().y);
                //sprite4.setPosition(sprite4.getPosition().x + m_SpeedMoving * TIME_PER_FRAME.asSeconds(), sprite4.getPosition().y);
                //sprite5.setPosition(sprite5.getPosition().x + m_SpeedMoving * TIME_PER_FRAME.asSeconds(), sprite5.getPosition().y);

                //RectFloatSprite1.left = RectFloatSprite1.left + m_SpeedMoving * TIME_PER_FRAME.asSeconds();
                //RectFloatSprite2.left = RectFloatSprite2.left + m_SpeedMoving * TIME_PER_FRAME.asSeconds();
                //RectFloatSprite3.left = RectFloatSprite3.left + m_SpeedMoving * TIME_PER_FRAME.asSeconds();
                //RectFloatSprite4.left = RectFloatSprite4.left + m_SpeedMoving * TIME_PER_FRAME.asSeconds();
                //RectFloatSprite5.left = RectFloatSprite5.left + m_SpeedMoving * TIME_PER_FRAME.asSeconds();
                ////RectFloatSprite.left = RectFloatSprite.left + m_SpeedMoving * TIME_PER_FRAME.asSeconds();

                //sprite1.setPosition(RectFloatSprite1.left, RectFloatSprite1.top);
                //sprite2.setPosition(RectFloatSprite2.left, RectFloatSprite2.top);
                //sprite3.setPosition(RectFloatSprite3.left, RectFloatSprite3.top);
                //sprite4.setPosition(RectFloatSprite4.left, RectFloatSprite4.top);
                //sprite5.setPosition(RectFloatSprite5.left, RectFloatSprite5.top);
                //sprite.setPosition(RectFloatSprite.left, RectFloatSprite.top);
            }
        }

        //**********************************************************
        //*******************       DRAW         *******************
        //**********************************************************
        window.clear();

        window.draw(sprite1);
        //window.draw(sprite2);
        //window.draw(sprite3);
        //window.draw(sprite4);
        //window.draw(sprite5);
        //window.draw(sprite);

        window.display();
    }

    return 0;
}


5
Graphics / Re: Jittery 98 sprites
« on: August 17, 2022, 11:24:56 am »
I now tried to implement fixed time steps as suggested in the book SFML Game Development on p23, but it actually seems to be worst now & I cannot get even 2 sprites to scroll without jitter.

I must be doing something wrong, or it is the vector<Sprite> that is the problem. I rewrote the code outside of any classes in order to show it. Picture is 200x300 & array in code is set to 2x1 = (2 images to display).

Code: [Select]
#include <iostream>
#include<vector>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>

using namespace sf;
using namespace std;

vector<Sprite> spriteArray;
float m_SpeedMoving = 600.0f;

const int numVertical = 2;      //Number of vertical sprites to create
const int numHorizontal = 1;    //Number of horizontal sprites to create

const int OffsetBottom = 20;
const int OffsetBottomOfScreen = 100;
const int OffsetLeft = 40;

void MakeSpriteArray(Texture& texture)
{
    unsigned short colCounter = 0;
    unsigned short numVert = 0;

    for (int i = 0; i < (numVertical * numHorizontal); ++i)
    {
        spriteArray.push_back(Sprite());
        spriteArray[i].setTexture(texture);            
        spriteArray[i].setScale(0.5, 0.5);

        if (colCounter == 0) //First column of sprite
        {
            if (numVert == 0) //Bottom row of sprites just above the bottom of the screen
            {
                spriteArray[i].setPosition(0, (1080 - OffsetBottomOfScreen) - spriteArray[i].getGlobalBounds().height);
            }
            else
            {
                spriteArray[i].setPosition(0, spriteArray[i - 1].getGlobalBounds().top - (spriteArray[i].getGlobalBounds().height - OffsetBottom));
            }
        }
        else
        {
            if (numVert == 0) //Bottom row of sprites just above the bottom of the screen
            {
                spriteArray[i].setPosition((spriteArray[i - numVertical].getGlobalBounds().left + spriteArray[i - numVertical].getGlobalBounds().width - OffsetLeft),
                    (1080 - OffsetBottomOfScreen) - spriteArray[i].getGlobalBounds().height);
            }
            else
            {
                spriteArray[i].setPosition((spriteArray[i - numVertical].getGlobalBounds().left + (spriteArray[i - numVertical].getGlobalBounds().width - OffsetLeft)),
                    (spriteArray[i - 1].getGlobalBounds().top - spriteArray[i].getGlobalBounds().height) + OffsetBottom);
            }
        }

        ++numVert;
        if (numVert == numVertical)
        {
            ++colCounter;
            numVert = 0;
        }
    }
}

void MoveLeft(Time& TIME_PER_FRAME)
{
    for (int i = 0; i < spriteArray.size(); ++i)
    {
        //spriteArray[i].setPosition(spriteArray[i].getGlobalBounds().left - m_SpeedMoving * dt.asSeconds(),
        //    spriteArray[i].getGlobalBounds().top);
        spriteArray[i].setPosition(spriteArray[i].getGlobalBounds().left - m_SpeedMoving * TIME_PER_FRAME.asSeconds(),
            spriteArray[i].getGlobalBounds().top);

        //if (!Keyboard::isKeyPressed(Keyboard::Left))
        //    break;
    }
}

void MoveRight(Time& TIME_PER_FRAME)
{
    for (int i = 0; i < spriteArray.size(); ++i)
    {
        //spriteArray[i].setPosition(spriteArray[i].getGlobalBounds().left + m_SpeedMoving * dt.asSeconds(),
        //    spriteArray[i].getGlobalBounds().top);

        spriteArray[i].setPosition(spriteArray[i].getGlobalBounds().left + m_SpeedMoving * TIME_PER_FRAME.asSeconds(),
            spriteArray[i].getGlobalBounds().top);

        //if (!Keyboard::isKeyPressed(Keyboard::Right))
        //    break;
    }
}


int main()
{
    //******************  WINDOW ******************
    Vector2f resolution;
    resolution.x = VideoMode::getDesktopMode().width;
    resolution.y = VideoMode::getDesktopMode().height;

    VideoMode vm(resolution.x, resolution.y);

    RenderWindow window(vm, "TEST", Style::Default);
    window.setFramerateLimit(60);

    Texture texture;
    texture.loadFromFile("graphics/Image1.png");



    //******************  TEXT  ******************



    //****************** CONFIG  ******************
    Clock clock;

    Time timeSinceLastUpdate = Time::Zero;
    Time TIME_PER_FRAME = seconds(1.0f / 60.0f);
   
    MakeSpriteArray(texture);

    bool isMovingLeft = false;
    bool isMovingRight = false;

    while (window.isOpen())
    {
        //**********************************************************
        //*******************   KEYBOARD/MOUSE   *******************
        //**********************************************************
        Event event;                       

        //NEEDED, to prevent intial screen blue circle
        while (window.pollEvent(event))
        {

        }

        //ESC to exit game
        if (Keyboard::isKeyPressed(Keyboard::Escape))
            window.close();


        ////*******************   KEYS   *******************

        if (Keyboard::isKeyPressed(Keyboard::Left))
        {
            isMovingLeft = true;
        }
        else
        {
            isMovingLeft = false;
        }

        if (Keyboard::isKeyPressed(Keyboard::Right))
        {
            isMovingRight = true;
        }
        else
        {
            isMovingRight = false;
        }


        //**********************************************************
        //*******************       UPDATE       *******************
        //**********************************************************
       
        timeSinceLastUpdate += clock.restart();
        //Time dt = clock.restart();

        cout << TIME_PER_FRAME.asSeconds() << endl;

        while (timeSinceLastUpdate > TIME_PER_FRAME)
        {
            timeSinceLastUpdate -= TIME_PER_FRAME;

            if (isMovingLeft)
            {
                MoveLeft(TIME_PER_FRAME);

            }

            if (isMovingRight)
            {
                MoveRight(TIME_PER_FRAME);
            }
        }

        //**********************************************************
        //*******************       DRAW         *******************
        //**********************************************************
        window.clear();

        //DRAW ALL
        for (int i = spriteArray.size() - 1; i >= 0; --i)       
        {
            window.draw(spriteArray[i]);
        }
        window.display();
    }

    return 0;
}


6
Graphics / Re: Jittery 98 sprites
« on: August 16, 2022, 11:42:21 pm »
I have tried so many things, including:

1) Implementing keyboard input from the Event event.key.code instead.
2) Inserting a break in the for loops when button isKeyReleased.
3) Moving the vector to main().
4) Trying various other frame rates: 30,60,120,240
5) Removing all other items except the vector & sprites in question.

Today I learned since dt is not consistently the same that it might be wise to check & force dt to consistency, so I am going to give this a try:

const float dt60 = 1.0f / 60.0f;
if (dt > dt60)
     dt -= dt60;

7
Graphics / Re: Jittery 98 sprites
« on: August 16, 2022, 07:41:09 am »
I only use:
window.setFramerateLimit(60);

The sprites move & then there is a quick micro second pause & then move again, & it is not consistent. Sometimes it can even pause/jitter twice, but more rarely. Sometimes it can move for longer periods and not jitter/pause.

When I try 50 sprite elements it runs smoother & jitters less frequently, 30 elements runs even smoother & barely jitters. BUT even with 30 if I hit L/R/L/R/L/R quickly & then hold R it is guaranteed to jitter. Stop holding the keys for a second & start again & it runs smooth again, as if the system is trying to catch up. Is there a container that is quicker than a vector<Sprite>, although a vector should be good enough since all my Sprites are loaded on startup & I never add/remove any throughout the game. Maybe that is the issue or is it the window.draw() for too many elements?

My key presses & releases are controlled with a bool in the class.
Code: [Select]
        if (Keyboard::isKeyPressed(Keyboard::Left))
        {
            classSprite.moveLeft();
        }
        else
        {
             classSprite.stopLeft();
        }

        if (Keyboard::isKeyPressed(Keyboard::Right))
        {
            classSprite.moveRight();
        }
        else
        {
            classSprite.stopRight();
        }

8
Graphics / Jittery 98 sprites
« on: August 15, 2022, 02:10:30 pm »
I have a vector<Sprites> with 98 elements (300x200 at scale (.5,.5)) and I am trying to move them all in the x-axis. I also have in the update section:
Time dt = clock.restart();

The sprites move very nicely with uncapped framerate, but they become jittery when I set:
window.setFramerateLimit(60);

Even though the FPS remains at constant above 60 (61-62). Any solutions or help would be appreciated.


Code: [Select]
if (m_MovingLeft)
{
for (int i = 0; i < m_Array.size(); ++i)
{
m_Array[i].setPosition(m_Array[i].getGlobalBounds().left - m_SpeedMoving * dt.asSeconds(), m_Array[i].getGlobalBounds().top);
}
}

if (m_MovingRight)
{
for (int i = 0; i < m_Array.size(); ++i)
{
m_Array[i].setPosition(m_Array[i].getGlobalBounds().left + m_SpeedMoving * dt.asSeconds(), m_Array[i].getGlobalBounds().top);
}
}

9
General discussions / Re: SFML on phone/tablets???
« on: August 03, 2022, 11:22:14 pm »
Thanks.

10
General discussions / Re: SFML on phone/tablets???
« on: August 03, 2022, 02:46:24 am »
Any good links or reading material on using SFML on phone/tablest? Any books on using SFML on them?

11
General discussions / SFML on phone/tablets???
« on: July 31, 2022, 08:01:30 pm »
I would like to use SFML with C++ on phone/tablets to build apps, is that possible?

12
Graphics / 2D animation
« on: July 24, 2022, 11:48:44 am »
Is it possible to shift & bend images in real-time with SFML, in order to create fluid animation? Something like this Photoshop tutorial, where triangles are placed on top of images & then you manipulate the image.

At time 3:00
https://youtu.be/kH2LP3Md6uE?t=180

Can you bend & shift a collection of sprite images that will make up a larger unit/character? Can you do it with triangles in SFML?

13
Graphics / sprite from square to rhombus
« on: June 16, 2022, 05:16:21 am »
I would like to take my sprite and skew it from a square to a rhombus. To slowly transition from square into various degrees of the rhombus and then back. How can I accomplish this?

Thanks in advance.

14
Graphics / Re: VertexArray accepts coordinates one beyond?
« on: June 11, 2022, 07:22:14 pm »
Thanks.

15
Graphics / Re: VertexArray accepts coordinates one beyond?
« on: June 07, 2022, 06:48:10 pm »
So it is like a mesh on top of the original image that is then used for scaling. Thanks, it makes sense now.

My 2nd question restated below.
In this line:
messageText.setOrigin(textRect.left + textRect.width / 2.0f, textRect.top + textRect.height / 2.0f);

Why do we need to add the textRect.top of the FloatRect (textRect) to the textRect.height in order to get the center of the messageText box? What does the .top value really mean (in this case it is = 12). What is within that 12 pixels at the top, is it empty space or does it hold part of the pixels of the font? If it is empty pixels then we should be subtracting from the height, not adding to it? Usually in other program a .top represents where the top starts, but here it obviously does not.

Code: [Select]
// Position the text
FloatRect textRect = messageText.getLocalBounds();

messageText.setOrigin(textRect.left + textRect.width / 2.0f, textRect.top + textRect.height / 2.0f);

messageText.setPosition(1920 / 2.0f, 1080 / 2.0f);

scoreText.setPosition(20, 20);

OUTPUT FROM CODE when you print to screen below (just to show coordinates):
Code: [Select]
Window x = 1920
Window y = 1080

BEFORE FloatRect formed:
messageText.getLocalBounds().left = 0
messageText.getLocalBounds().top = 12
messageText.getLocalBounds().height = 64
messageText.getLocalBounds().width = 935

AFTER FloatRect formed:
textRect.left = 0
textRect.top = 12
textRect.height = 64
textRect.width = 935

messageText.getLocalBounds().left = 0
messageText.getLocalBounds().top = 12
messageText.getLocalBounds().height = 64
messageText.getLocalBounds().width = 935

messageText.getGlobalBounds().left = 0
messageText.getGlobalBounds().top = 12
messageText.getGlobalBounds().height = 64
messageText.getGlobalBounds().width = 935

Pages: [1] 2
anything