@@ -143,6 +143,8 @@ void DrawingGameVisitor::visit(GameBoard& model) {
143143
144144}
145145
146+
147+
146148/* *
147149 * Draw a road.
148150 * @param road The road to draw.
@@ -241,18 +243,103 @@ void drawTexturedCircle(std::pair<float, float> texCenter, float texRadius, std:
241243 double angle = ((double ) i) * (2 . * M_PI) / (double )articulation;
242244 double tangle = ((double ) -i) * (2 . * M_PI) / (double )articulation;
243245 texCoordPair ({texCenter.first + texRadius * std::cos (tangle), texCenter.second + texRadius * std::sin (tangle)});
246+ // std::cout << texCenter.first + texRadius << "\n";
244247 glVertex2d (screenCenter.first + (screenRadius * std::cos (angle)), screenCenter.second + (screenRadius * std::sin (angle)));
248+ // std::cout << screenCenter.first + (screenRadius * std::cos(angle));
249+
245250 }
246251 glEnd ();
247252}
248253
254+ void drawTexturedRectangle (std::pair<float , float > texTopLeft, float sideLength, std::pair<float , float > screenTopLeft, float screenSideLength) {
255+
256+ static const GLuint diceTextures = loadImageAsTexture (" resources/catan_dice_new.bmp" );
257+ glBindTexture (GL_TEXTURE_2D, diceTextures);
258+
259+ glBegin (GL_QUADS);
260+
261+
262+
263+ texCoordPair ({texTopLeft.first + 0 .0f , texTopLeft.second + 0 .0f });
264+ glVertex2d (screenTopLeft.first + 0 .0f , screenTopLeft.second + 0 .0f );
265+
266+ texCoordPair ({texTopLeft.first + sideLength, texTopLeft.second + 0 .0f });
267+ glVertex2d (screenTopLeft.first + screenSideLength, screenTopLeft.second + 0 .0f );
268+
269+
270+ texCoordPair ({texTopLeft.first + 0 .0f , texTopLeft.second + sideLength});
271+ glVertex2d (screenTopLeft.first + 0 .0f , screenTopLeft.second + screenSideLength);
272+
273+ texCoordPair ({texTopLeft.first + sideLength, texTopLeft.second + sideLength});
274+ glVertex2d (screenTopLeft.first + screenSideLength, screenTopLeft.second + screenSideLength);
275+
276+
277+ // redraw the image for reasons
278+ texCoordPair ({texTopLeft.first + sideLength, texTopLeft.second + sideLength});
279+ glVertex2d (screenTopLeft.first + screenSideLength, screenTopLeft.second + screenSideLength);
280+
281+ texCoordPair ({texTopLeft.first + 0 .0f , texTopLeft.second + sideLength});
282+ glVertex2d (screenTopLeft.first + 0 .0f , screenTopLeft.second + screenSideLength);
283+
284+ texCoordPair ({texTopLeft.first + sideLength, texTopLeft.second + 0 .0f });
285+ glVertex2d (screenTopLeft.first + screenSideLength, screenTopLeft.second + 0 .0f );
286+
287+ texCoordPair ({texTopLeft.first + 0 .0f , texTopLeft.second + 0 .0f });
288+ glVertex2d (screenTopLeft.first + 0 .0f , screenTopLeft.second + 0 .0f );
289+
290+
291+
292+
293+ glEnd ();
294+
295+
296+ glBindTexture (GL_TEXTURE_2D, 0 );
297+
298+
299+
300+ }
301+
302+ void DrawingGameVisitor::visit (GameDice& dice) {
303+
304+
305+
306+
307+ /* static const std::map<int, std::pair<float, float>> topLeftOffset = {
308+ make_pair(1, make_pair(4.f, 8.f)),
309+ make_pair(2, make_pair(134.f, 8.f)),
310+ make_pair(3, make_pair(264.f, 8.f)),
311+ make_pair(4, make_pair(4.f, 142.f)),
312+ make_pair(5, make_pair(134.f, 142.f)),
313+ make_pair(6, make_pair(264.f, 142.f))
314+ };*/
315+ /*
316+ drawTexturedRectangle(topLeftOffset.find(dice.getFirst())->second, 96.f,
317+ make_pair(.8f, .9f), 0.03);
318+ */
319+
320+ // drawTexturedRectangle(make_pair(134.f, 8.f), 96.f, make_pair(.8f, .9f), 0.03);
321+
322+ // drawTexturedRectangle(topLeftOffset.find(dice.getSecond())->second, 96.f,
323+ // make_pair(.84f, .9f), 0.03);
324+
325+ drawTexturedRectangle (make_pair (4 .f , 8 .f ), 1000 .f , make_pair (.7f , .9f ), 0.03 );
326+
327+
328+
329+
330+
331+ // std::cout << dice.getFirst() << "\n";
332+
333+ }
334+
249335/* *
250336 * Draw a resource tile.
251337 * @param tile The tile to draw.
252338 */
253339void DrawingGameVisitor::visit (ResourceTile& tile) {
254340 Coordinate coord = tile.getLocation ();
255341 static const GLuint tileTextures = loadImageAsTexture (" resources/catan_sprite_sheet.bmp" );
342+
256343 glBindTexture (GL_TEXTURE_2D, tileTextures);
257344 static const std::map<resourceType, pair<float , float >> topRightPoints = {
258345 make_pair (WOOD, make_pair (260 .f , 17 .f )),
@@ -307,6 +394,8 @@ void DrawingGameVisitor::visit(ResourceTile& tile) {
307394 drawTexturedCircle (numberTexPoints.find (tile.getDiceValue ())->second , radius, coordToScreen (coord), 0.04 );
308395 }
309396 glBindTexture (GL_TEXTURE_2D, 0 );
397+
398+
310399}
311400
312401/* *
0 commit comments