|
|
|
|
|
|
PROBLEM 1: |
PROBLEM 2: |
PROBLEM 3: |
Shouldn't that be an if/else instead of 2 if's? |
Shouldn't that be an if/else instead of 2 if's? |
I would have expected that the direction is used instead. |
|
|
Shouldn't that be an if/else instead of 2 if's? If you press both left and right at the same time then the effect of both if statements will cancel each other out and the paddle will not move. If you change it to use "else if" it would instead move left when both keys are pressed. |
protoseepp wrote: |
---|
I don't know any VB Studio debugging yet |
Is this because Keyboard::isKeyPressed goes low for both left & right keys because they are both being pressed at the same time? I have not checked & will have to go back to place some values to the screen to satisfy myself. I would have suspected both of them to go high and for both if's to go through...scratching my head? |
|
|
FloatRect sf::Text::getGlobalBounds ( ) const Get the global bounding rectangle of the entity. The returned rectangle is in global coordinates, which means that it takes into account the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the text in the global 2D world's coordinate system. Returns Global bounding rectangle of the entity |
These are needed to run the game in it's current form. I've shared them publicly in my Dropbox: http://bit.ly/1myJJk0 Copy everything from there to the /resources directory. |
No flickering on the screen either for the paddle because the increment/decrement is so small, which is an added bonus. |
But then if that was the case he should be subtracting that number & not adding it in... |
textRect.width |----------------| _ _ | | | | | |_ _____ _| |_ | __/ _ \ \/ / __| | || __/> <| |_ \__\___/_/\_\\__| ^ ^ | | | textRect.left + textRect.width / 2.0f | textRect.left |
_ _ __ __ _ _ __ ___ | | | '_ \ / _` | '_ \ / _ \ | | ____ _ _ __ ___ >| | | | (_| | | | | (_) | >| |/ / _` | '_ \ / _ \ |_| |_|\__,_|_| |_|\___/ | < (_| | | | | (_) | |_|\_\__,_|_| |_|\___/ |
FloatRect sf::Text::getLocalBounds ( ) const Get the local bounding rectangle of the entity. The returned rectangle is in local coordinates, which means that it ignores the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the entity in the entity's coordinate system. Returns Local bounding rectangle of the entity |
|
|
Window x = 1920 Window y = 1080 0messageText.getLocalBounds().left = 0 0messageText.getLocalBounds().top = 12 textRect.left = 0 textRect.top = 12 textRect.height = 64 messageText.getLocalBounds().left = 0 messageText.getLocalBounds().top = 12 messageText.getLocalBounds().height = 64 messageText.getGlobalBounds().left = 0 messageText.getGlobalBounds().top = 12 messageText.getGlobalBounds().height = 64 |
messageText.setOrigin(textRect.left + textRect.width / 2.0f, textRect.top + textRect.height / 2.0f); messageText.setOrigin(0 + 935 / 2.0f, 12 + 64 / 2.0f); messageText.setOrigin(467.5f, 38.0f); |
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 AFTER messageText.setOrigin(textRect.left + textRect.width / 2.0f, textRect.top + textRect.height / 2.0f); : 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 = 492.5 messageText.getGlobalBounds().top = 508 messageText.getGlobalBounds().height = 64 messageText.getGlobalBounds().width = 935 |
So, we are saying the height of this text box is 64 pixels, but the first pixel drawn is 12 pixels down from the top (textRect.top = 12). |
Top left corner _|_ ___ | | | 12 pixels ____ _|_ | ## | | |# #| | |####| | 64 pixels |#__#| _|_ |
does that mean really there is 12 pixels of empty space between the very top of the text box & where it hits the first visible pixel from the top of the font? |
so that now really the math should be subtraction (instead of addition like he has it), because we have 12 dead empty pixel rows at the top? |
Do you know SFML, how did you know this? |
Did you see that Mario game and how smooth and great of a job he did? |
Have you created any games? |
Any really good in-depth Mario bros how to video/coding tutorials? |