- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
gp_terrains.at(0)->draw();
//it took me only 50 lines of spaghetti code to implement the spiral layout
//direction 1 for +x, 2 for +y, 3: -x, 0: -y
int repetition_count = 1;
int i = 1;
int direction = 0;
while(i < (int)gp_terrains.size()) {
for (int k = 0; k < 2; k++) {
direction = (++direction) % 4;
for (int j = 0; j < repetition_count; j++) {
switch(direction) {
case 1: {
glTranslated(512, 0, 0);
gp_terrains.at(i)->draw();
break;
}
case 2: {
glTranslated(0, 512, 0);
gp_terrains.at(i)->draw();
break;
}
case 3: {
glTranslated(-512, 0, 0);
gp_terrains.at(i)->draw();
break;
}
case 0: {
glTranslated(0, -512, 0);
gp_terrains.at(i)->draw();
break;
}
}
if (++i >= (int)gp_terrains.size())
break;
}
if (i >= (int)gp_terrains.size())
break;
}
if (i >= (int)gp_terrains.size())
break;
repetition_count++;
Комментарии (0) RSS
Добавить комментарий