|
@@ -4,7 +4,7 @@ Wall *addWall(Wall *list, int d, int h, int id, int line)
|
|
|
{
|
|
{
|
|
|
Wall *tmp;
|
|
Wall *tmp;
|
|
|
Wall *new;
|
|
Wall *new;
|
|
|
- tmp = list;
|
|
|
|
|
|
|
+ tmp = list;
|
|
|
|
|
|
|
|
new = malloc(sizeof(Wall));
|
|
new = malloc(sizeof(Wall));
|
|
|
new->d = d;
|
|
new->d = d;
|
|
@@ -13,7 +13,7 @@ Wall *addWall(Wall *list, int d, int h, int id, int line)
|
|
|
new->line = line;
|
|
new->line = line;
|
|
|
new->nxt = NULL;
|
|
new->nxt = NULL;
|
|
|
|
|
|
|
|
- if(list == NULL)
|
|
|
|
|
|
|
+ if(list == NULL)
|
|
|
return new;
|
|
return new;
|
|
|
else if(list != NULL)
|
|
else if(list != NULL)
|
|
|
{
|
|
{
|
|
@@ -89,16 +89,6 @@ int getSlopeIndex(int dot1, int dot2)
|
|
|
}
|
|
}
|
|
|
void show(Wall *list, Camera *cam)
|
|
void show(Wall *list, Camera *cam)
|
|
|
{
|
|
{
|
|
|
- /*
|
|
|
|
|
-
|
|
|
|
|
- 0________________1
|
|
|
|
|
- / 0 \
|
|
|
|
|
- 3/ \1
|
|
|
|
|
- / \
|
|
|
|
|
-3/______________________\2
|
|
|
|
|
- 2
|
|
|
|
|
-
|
|
|
|
|
- */
|
|
|
|
|
Wall *tmp;
|
|
Wall *tmp;
|
|
|
tmp = list;
|
|
tmp = list;
|
|
|
do{
|
|
do{
|
|
@@ -106,85 +96,19 @@ void show(Wall *list, Camera *cam)
|
|
|
{
|
|
{
|
|
|
if(tmp->d + tmp->h< 64)
|
|
if(tmp->d + tmp->h< 64)
|
|
|
{
|
|
{
|
|
|
|
|
+
|
|
|
const float angle = PI * ((tmp->line)*60 +cam->angle) / 180;
|
|
const float angle = PI * ((tmp->line)*60 +cam->angle) / 180;
|
|
|
const float cos1 = cos(angle);
|
|
const float cos1 = cos(angle);
|
|
|
const float cos2 = cos(angle + PI/3);
|
|
const float cos2 = cos(angle + PI/3);
|
|
|
const float sin1 = sin(angle);
|
|
const float sin1 = sin(angle);
|
|
|
const float sin2 = sin(angle + PI/3);
|
|
const float sin2 = sin(angle + PI/3);
|
|
|
- int x[4];
|
|
|
|
|
- int y[4];
|
|
|
|
|
- float slopes[4];
|
|
|
|
|
- int i = 0;
|
|
|
|
|
- int j = 0;
|
|
|
|
|
-
|
|
|
|
|
- int tmpInt = 0;
|
|
|
|
|
- int x1=0, x2 = 0;
|
|
|
|
|
- //finding the two active edges
|
|
|
|
|
- int leftDotIndex = 0, rightDotIndex = 0, leftSlope=0, rightSlope=0;
|
|
|
|
|
-
|
|
|
|
|
- x[0]=tmp->d * cos1 + 64;
|
|
|
|
|
- x[1]=tmp->d * cos2 + 64;
|
|
|
|
|
- x[2]= (tmp->h + tmp->d) * cos2 + 64;
|
|
|
|
|
- x[3]=(tmp->h + tmp->d) * cos1 + 64;
|
|
|
|
|
-
|
|
|
|
|
- y[0]=tmp->d * sin1 + 32;
|
|
|
|
|
- y[1]=tmp->d * sin2 + 32;
|
|
|
|
|
- y[2]= (tmp->h + tmp->d) * sin2 + 32;
|
|
|
|
|
- y[3]=(tmp->h + tmp->d) * sin1 + 32;
|
|
|
|
|
-
|
|
|
|
|
- /*slopes[0] = (y[1] - y[0])/(x[1]-x[0]);
|
|
|
|
|
- slopes[1] = (y[2] - y[1])/(x[2]-x[1]);
|
|
|
|
|
- slopes[2] = (y[3] - y[2])/(x[3]-x[2]);
|
|
|
|
|
- slopes[3] = (y[0] - y[3])/(x[0]-x[3]);*/
|
|
|
|
|
- /*for(i = 0; i < tmp->h; i+=0.5)
|
|
|
|
|
- {
|
|
|
|
|
- ML_line((tmp->d + i) * cos2 + 64, (tmp->d + i) * sin2 + 32, (tmp->d + i) * cos1 + 64, (tmp->d + i) * sin1 + 32, BLACK);
|
|
|
|
|
- }*/
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-/* i = y[0];
|
|
|
|
|
- j = y[0];
|
|
|
|
|
-
|
|
|
|
|
- for(i = 0; i < 4; i++)
|
|
|
|
|
- if(y[tmpInt] > y[i])
|
|
|
|
|
- tmpInt = i;
|
|
|
|
|
- i = tmpInt;
|
|
|
|
|
- tmpInt = 0;
|
|
|
|
|
- for(j = 0; j < 4; j++)
|
|
|
|
|
- if(y[tmpInt] < y[j])
|
|
|
|
|
- tmpInt = j;
|
|
|
|
|
- j = tmpInt;
|
|
|
|
|
- x1 = x[i];
|
|
|
|
|
- x2 = x[i];
|
|
|
|
|
-
|
|
|
|
|
- //i contains an index to the highest vertex and j the lowest
|
|
|
|
|
- tmpInt = 0;
|
|
|
|
|
- for(leftDotIndex = 0; leftDotIndex < 4; leftDotIndex ++)
|
|
|
|
|
- {
|
|
|
|
|
- if(leftDotIndex != i && leftDotIndex != j && (tmpInt == 0 || tmpInt > x[leftDotIndex]))
|
|
|
|
|
- tmpInt = x[leftDotIndex];
|
|
|
|
|
- }
|
|
|
|
|
- for(rightDotIndex = 0; rightDotIndex == i || rightDotIndex == j || rightDotIndex == leftDotIndex; rightDotIndex ++)
|
|
|
|
|
- {}
|
|
|
|
|
-
|
|
|
|
|
- tmpInt = i;
|
|
|
|
|
- while(i <= j)
|
|
|
|
|
- {
|
|
|
|
|
- //getting the active slopes' indexes
|
|
|
|
|
- if(y[i] < y[leftDotIndex])
|
|
|
|
|
- leftSlope = getSlopeIndex(i, leftDotIndex);
|
|
|
|
|
- else leftSlope = getSlopeIndex(leftDotIndex, j);
|
|
|
|
|
- if(y[i] < y[rightDotIndex])
|
|
|
|
|
- rightSlope = getSlopeIndex(i, rightDotIndex);
|
|
|
|
|
- else rightSlope = getSlopeIndex(rightDotIndex, j);
|
|
|
|
|
-
|
|
|
|
|
- ML_horizontal_line(y[tmpInt] + i, x1, x2, BLACK);
|
|
|
|
|
- ML_horizontal_line(y[tmpInt] + i, x2, x1, BLACK);
|
|
|
|
|
- x1 = x1 - (1/slopes[leftSlope]);
|
|
|
|
|
- x2 = x2 - (1/slopes[rightSlope]);
|
|
|
|
|
- i++;
|
|
|
|
|
- }*/
|
|
|
|
|
- ML_filled_polygone(x, y, 4, BLACK);
|
|
|
|
|
|
|
+ int i,j, x, y;
|
|
|
|
|
+ float dist = tmp->d - tmp->h;
|
|
|
|
|
+ for(i = 0; i < tmp->h; ++i) {
|
|
|
|
|
+ if(dist <= 8) break;
|
|
|
|
|
+ ML_line(64 + dist*cos1, 32 + dist*sin1, 64 + dist*cos2, 32 + dist*sin2, BLACK);
|
|
|
|
|
+ --dist;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
tmp = tmp->nxt;
|
|
tmp = tmp->nxt;
|