Skip to content

Commit ec2ae81

Browse files
committed
fixed some magic numbers and extracted repeated code into macros
1 parent 113b4a2 commit ec2ae81

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/GameView.cpp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ using std::string;
1818

1919
float DiceXCoords[3] = {9.f, 134.f, 259.f};
2020
float DiceYCoords[2] = {3.f, 142.f};
21+
std::pair<float, float> lDieScreenLoc= make_pair(0.7f, 0.8f);
22+
std::pair<float, float> rDieScreenLoc= make_pair(0.78f, 0.8f);
23+
24+
#define DIE_SIDE_LENGTH 0.06f
2125

2226
#define EMPLACE_SQUARE_VERTEX(imXOff, imYOff, scXOff, scYOff) \
2327
texCoordPair({texTopLeft.first + imXOff, texTopLeft.second + imYOff}); \
@@ -296,18 +300,6 @@ void drawTexturedRectangle(std::pair<float, float> texTopLeft, float sideLength,
296300
EMPLACE_SQUARE_VERTEX(sideLength, sideLength, screenSideLength, screenSideLength)
297301
EMPLACE_SQUARE_VERTEX(0.0f, sideLength, 0.0f, screenSideLength)
298302

299-
300-
301-
/*texCoordPair({texTopLeft.first + sideLength, texTopLeft.second + 0.0f});
302-
glVertex2d(screenTopLeft.first + screenSideLength, screenTopLeft.second + 0.0f);
303-
304-
305-
texCoordPair({texTopLeft.first + sideLength, texTopLeft.second + sideLength});
306-
glVertex2d(screenTopLeft.first + screenSideLength, screenTopLeft.second + screenSideLength);
307-
308-
texCoordPair({texTopLeft.first + 0.0f, texTopLeft.second + sideLength});
309-
glVertex2d(screenTopLeft.first + 0.0f, screenTopLeft.second + screenSideLength);*/
310-
311303
glEnd();
312304

313305
}
@@ -330,11 +322,11 @@ void DrawingGameVisitor::visit(GameDice& dice) {
330322

331323

332324
drawTexturedRectangle(topLeftOffset.find(dice.getFirst())->second, 95.f,
333-
make_pair(.7f, .8f), 0.06);
325+
lDieScreenLoc, DIE_SIDE_LENGTH);
334326

335327

336328
drawTexturedRectangle(topLeftOffset.find(dice.getSecond())->second, 95.f,
337-
make_pair(.78f, .8f), 0.06);
329+
rDieScreenLoc, DIE_SIDE_LENGTH);
338330

339331

340332
glBindTexture(GL_TEXTURE_2D, 0);

0 commit comments

Comments
 (0)