Skip to content

Commit c626833

Browse files
committed
Added settlement drawing
1 parent 7f0cca0 commit c626833

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/GameBoard.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,10 +422,12 @@ void GameBoard::PlaceCity(Coordinate location, Player& Owner){
422422

423423
void GameBoard::accept(GameVisitor& visitor) {
424424
visitor.visit(*this);
425-
for(auto& it : corners) {
425+
// Drawing needs this to happen in this order. Visitors technically should be order-independent, but this was an easy fix at the moment.
426+
// Keep that in mind when modifying this.
427+
for(auto& it : resources) {
426428
it.second->accept(visitor);
427429
}
428-
for(auto& it : resources) {
430+
for(auto& it : corners) {
429431
it.second->accept(visitor);
430432
}
431433
for(auto& roadCoordVec : roads) {

src/GameView.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,18 @@ void DrawingGameVisitor::visit(Road& road) {
8383
}
8484

8585
void DrawingGameVisitor::visit(Settlement& settlement) {
86+
static const auto settlementRadius = 0.03;
8687

88+
auto centerScreenPos = coordToScreen(settlement.getLocation());
89+
90+
glBindTexture(GL_TEXTURE_2D, 0);
91+
glColor3d(0., 0., 0.);
92+
glBegin(GL_QUADS);
93+
glVertex2d(centerScreenPos.first, centerScreenPos.second + settlementRadius);
94+
glVertex2d(centerScreenPos.first + settlementRadius, centerScreenPos.second);
95+
glVertex2d(centerScreenPos.first, centerScreenPos.second - settlementRadius);
96+
glVertex2d(centerScreenPos.first - settlementRadius, centerScreenPos.second);
97+
glEnd();
8798
}
8899

89100
void DrawingGameVisitor::visit(City& city) {

0 commit comments

Comments
 (0)