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