Tuesday, July 19, 2022
HomeGame Developmentarithmetic - Is placing the parentheses between the display width divided by...

arithmetic – Is placing the parentheses between the display width divided by 2 to set on the display for readability or clarification?


I am utilizing SFML & the guide I am studying has the next snippet of code:

// Create a video mode object
VideoMode vm(1920, 1080);
// Create and open a window for the sport
RenderWindow window(vm, "Timber!!!", Type::Fullscreen);
// Time bar
RectangleShape timeBar;
float timeBarStartWidth = 400;
float timeBarHeight = 80;
timeBar.setSize(Vector2f(timeBarStartWidth, timeBarHeight));
timeBar.setFillColor(Shade::Pink);
timeBar.setPosition((1920 / 2) - timeBarStartWidth / 2, 980);

Is placing the parentheses between the display width, which is 1920, divided by 2 to set on the display for readability or clarification? Does it emphasize to the reader that the time bar is certainly within the middle of the display? The order of division operations occurs from left to proper. I feel that the novice will write that line of code with out the parentheses with that math idea in thoughts as this:

timeBar.setPosition(1920 / 2 - timeBarStartWidth / 2, 980);

I am a newbie in recreation programming with some fundamental programming. And there are lots of issues that inconsistency that isn’t really easy to determine alone why do that approach and never that approach.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments