Browse Source

Merge branch 'wallDraw'

Adrien Boucaud 12 years ago
parent
commit
6502d128d3
3 changed files with 22 additions and 91 deletions
  1. 7 0
      hexagon.dlr
  2. 5 5
      hexagon.dlw
  3. 10 86
      wall.c

+ 7 - 0
hexagon.dlr

@@ -96,6 +96,7 @@ Flags=00001012
 File=C:\Users\Florian\GIT\Super-Hexagon-Casio\wall.c
 Line=112
 Flags=00001012
+Sublevel=1
 
 [Breakpoint]
 File=C:\Users\Florian\GIT\Super-Hexagon-Casio\hexagon.c
@@ -157,3 +158,9 @@ Flags=00001012
 File=C:\Users\Florian\GIT\Super-Hexagon-Casio\hexagon.c
 Line=161
 Flags=00001012
+
+[Breakpoint]
+File=C:\Users\Florian\GIT\Super-Hexagon-Casio\wall.c
+Line=112
+Flags=00001012
+Sublevel=2

+ 5 - 5
hexagon.dlw

@@ -9,7 +9,7 @@ Height=4740
 Width=5565
 State=0
 Flags=00000020
-Setting=157:1:hexagon.c
+Setting=124:1:MonochromeLib.c
 OptionA=0
 
 [_2]
@@ -48,7 +48,7 @@ OptionA=0
 
 [_5]
 Type=8
-Order=4
+Order=5
 Top=450
 Left=14730
 Height=3225
@@ -125,7 +125,7 @@ OptionA=0
 
 [_32]
 Type=16
-Order=5
+Order=6
 Top=2940
 Left=2370
 Height=4590
@@ -149,12 +149,12 @@ OptionA=0
 
 [_34]
 Type=16
-Order=6
+Order=4
 Top=3600
 Left=5985
 Height=6885
 Width=17190
 State=0
 Flags=00000020
-Setting=156:5:wall.c
+Setting=116:1:wall.c
 OptionA=0

+ 10 - 86
wall.c

@@ -4,7 +4,7 @@ Wall *addWall(Wall *list, int d, int h, int id, int line)
 {
 	Wall *tmp;
 	Wall *new;
-	tmp = list;		 
+	tmp = list;
 
 	new = malloc(sizeof(Wall));
 	new->d = d;
@@ -13,7 +13,7 @@ Wall *addWall(Wall *list, int d, int h, int id, int line)
 	new->line = line;
 	new->nxt = NULL;
 
-	if(list == NULL)		
+	if(list == NULL)
 		return new;
 	else if(list != NULL)
 	{
@@ -89,16 +89,6 @@ int getSlopeIndex(int dot1, int dot2)
 }
 void show(Wall *list, Camera *cam)
 {
-	/*
-
-	0________________1
-	/        0       \
-  3/                  \1
-  /                    \
-3/______________________\2
- 			2
-
- 	*/
 	Wall *tmp;
 	tmp = list;
 	do{
@@ -106,85 +96,19 @@ void show(Wall *list, Camera *cam)
 		{
 			if(tmp->d + tmp->h< 64)
 			{
+
 				const float angle = PI * ((tmp->line)*60 +cam->angle) / 180;
 				const float cos1 = cos(angle);
 				const float cos2 = cos(angle + PI/3);
 				const float sin1 = sin(angle);
 				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;