Skip to content

Commit b57cd46

Browse files
committed
Added city rendering
1 parent 17929af commit b57cd46

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/GameView.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "GameBoard.h"
99
#include "GameController.h"
1010
#include "Renderer.h"
11+
#include "City.h"
1112

1213
using std::make_pair;
1314
using std::pair;
@@ -98,7 +99,18 @@ void DrawingGameVisitor::visit(Settlement& settlement) {
9899
}
99100

100101
void DrawingGameVisitor::visit(City& city) {
102+
static const auto cityRadius = 0.03;
101103

104+
auto centerScreenPos = coordToScreen(city.getLocation());
105+
106+
glBindTexture(GL_TEXTURE_2D, 0);
107+
glColor3d(0., 0., 0.);
108+
glBegin(GL_QUADS);
109+
glVertex2d(centerScreenPos.first + cityRadius, centerScreenPos.second + cityRadius);
110+
glVertex2d(centerScreenPos.first + cityRadius, centerScreenPos.second - cityRadius);
111+
glVertex2d(centerScreenPos.first - cityRadius, centerScreenPos.second - cityRadius);
112+
glVertex2d(centerScreenPos.first - cityRadius, centerScreenPos.second + cityRadius);
113+
glEnd();
102114
}
103115

104116
void DrawingGameVisitor::visit(Player& player) {

src/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ int main(int argc, char *argv[]) {
7575
model.PlaceRoad(Coordinate{0, 0}, Coordinate{1, 0}, firstPlayer);
7676
model.PlaceRoad(Coordinate{1, 0}, Coordinate{1, 1}, firstPlayer);
7777
model.PlaceRoad(Coordinate{1, 1}, Coordinate{0, 2}, firstPlayer);
78+
model.PlaceSettlement(Coordinate{0, 2}, firstPlayer);
79+
model.UpgradeSettlement(Coordinate{0, 2});
7880

7981
bool running = true;
8082
while(running) {

0 commit comments

Comments
 (0)