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.


Topics - MichelangeloSFML/

Pages: [1]
1
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);
}
}

2
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?

3
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?

4
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.

5
Graphics / VertexArray accepts coordinates one beyond?
« on: June 07, 2022, 01:13:35 pm »
Thanks in advance.

1) I am going through this book that uses a sprite sheet that is 50x200, with 4 sprites each 50x50.
Book says each of the corner Quads coordinates are as follows:

IMAGE 1:
0,0      49,0

0,49      49,49

IMAGE 2:
0,50       49,50

0,99       49,99

IMAGE 3:
0,100   49,100

0,149   49,149

IMAGE 4:
0,150   49,150

0,199   49,199 




So for a 50x50 image coordinates go from 0-49 on width & 0-49 on height, BUT THEN the program uses a VertexArray to accept .positon for coordinates between 0-50 for both width & height. I assumed that such a request would go 1 pixel beyond the width & height and give an error, but instead the code runs perfectly and displays the tiles on the screen. So I am just wondering does the VertexArray class accept one beyond for mathematical convenience, or is there something else that I am missing? 

Here is a partial cout of the coord from the for loop:

.position:
  • = (0, 0)
  • [1] = (50, 0)
    [2] = (50, 50)
    [3] = (0, 50)

    [4] = (0, 50)
    [5] = (50, 50)
    [6] = (50, 100)
    [7] = (0, 100)

    [8] = (0, 100)
    [9] = (50, 100)
    [10] = (50, 150)
    [11] = (0, 150)

    [12] = (0, 150)
    [13] = (50, 150)
    [14] = (50, 200)
    [15] = (0, 200)

    [16] = (0, 200)
    [17] = (50, 200)
    [18] = (50, 250)
    [19] = (0, 250)

    [20] = (0, 250)
    [21] = (50, 250)
    [22] = (50, 300)
    [23] = (0, 300)

    [24] = (0, 300)
    [25] = (50, 300)
    [26] = (50, 350)
    [27] = (0, 350)
    _____________________________

.textCoords:
  • = (0, 150)
  • [1] = (50, 150)
    [2] = (50, 200)
    [3] = (0, 200)

    [4] = (0, 150)
    [5] = (50, 150)
    [6] = (50, 200)
    [7] = (0, 200)

    [8] = (0, 150)
    [9] = (50, 150)
    [10] = (50, 200)
    [11] = (0, 200)

    [12] = (0, 150)
    [13] = (50, 150)
    [14] = (50, 200)
    [15] = (0, 200)

    [16] = (0, 150)
    [17] = (50, 150)
    [18] = (50, 200)
    [19] = (0, 200)

    [20] = (0, 150)
    [21] = (50, 150)
    [22] = (50, 200)
    [23] = (0, 200)

    [24] = (0, 150)
    [25] = (50, 150)
    [26] = (50, 200)
    [27] = (0, 200)


    2) I am also curious why do I have to add the "textRect.top" to the height "textRect.top + textRect.height / 2.0f" to get the origin? What does the .top for the textRect FloatRect represent? Is it the empty space between the top to the point where it hits the first pixel of the font? So in my example below...

    textRect.top = 12

    ...means that there are 12 empty rows of pixels from the top until it reaches a font pixel. If that is the case, why am I adding the "textRect.top + textRect.height / 2.0f", shouldn't I be subtracting those 12 empty pixels instead so I can get the TRUE mid point/origin?

    ________________
    // 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);

    ________________
    COUT FROM CODE:

    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]
anything