Bladeren bron

Started make the hud prettier

Florian DORMONT 11 jaren geleden
bovenliggende
commit
b25b53a7f7
2 gewijzigde bestanden met toevoegingen van 55 en 2 verwijderingen
  1. 1 1
      MonochromeLib.h
  2. 54 1
      draw_states.c

+ 1 - 1
MonochromeLib.h

@@ -58,7 +58,7 @@
 //#define ML_BMP_AND_CL
 //#define ML_BMP_XOR_CL
 
-//#define ML_BMP_8_OR
+#define ML_BMP_8_OR
 //#define ML_BMP_8_AND
 //#define ML_BMP_8_XOR
 #define ML_BMP_8_OR_CL

+ 54 - 1
draw_states.c

@@ -32,8 +32,61 @@ void draw_game_over(Game_Data *data)
 
 static void drawHud(Game_Data *data) {
 	unsigned char time_text[8] = "";
+	unsigned char *step_text[6] = {
+		"Point",
+		"Line",
+		"Triangle",
+		"Square",
+		"Pentagon",
+		"Hexagon"
+	};
+	unsigned short step_time[5] = {
+		10,
+		20,
+		30,
+		45,
+		60
+	};
+
+	unsigned char time_hud_border[8] = {0xF0, 0xF0, 0xE0, 0xE0, 0xC0, 0xC0, 0x80, 0x80};
+	unsigned char step_hud_border[8] ={0x1F, 0x1F, 0x0F, 0x0F, 0x07, 0x07, 0x01, 0x01};
+	unsigned short length_of_time, length_of_time_line;
+	unsigned short length_of_step, current_step, i;
+	current_step = 5;
+	for(i = 0; i < 5; i++) {
+		if(data->chrono_time < step_time[i]) {
+			current_step = i;
+			break;
+		}
+	}
+
 	sprintf(time_text, "%.2f", data->chrono_time);
-	PrintMini(0, 0, time_text, MINI_REV);
+
+	length_of_time = strlen(time_text);
+	length_of_time_line = 4 * length_of_time;
+	length_of_step = 4 * strlen(step_text[current_step]) + 1;
+
+	// Little patch because the font is not fixed width and 'n' chars are annoying me.
+	ML_vertical_line(125,0,5, BLACK);
+	ML_vertical_line(126,0,5, BLACK);
+	ML_vertical_line(127,0,5, BLACK);
+
+	PrintMini(127 - length_of_step, 1, step_text[current_step], MINI_REV);
+	ML_bmp_8_or(step_hud_border, 127 - length_of_step - 8, 0);
+	ML_horizontal_line(6, 127 - length_of_step - 2, 127, BLACK);
+	ML_horizontal_line(7, 127 - length_of_step - 2, 127, BLACK);
+
+	if(data->chrono_time < 60) {
+		PrintMini(0, 0, time_text, MINI_REV);
+		ML_horizontal_line(6, 0, (data->chrono_time/60.) * (length_of_time_line - 2), BLACK);
+		ML_horizontal_line(7, 0, length_of_time_line - 1, BLACK);
+	}
+	else {
+		PrintMini(0, 1, time_text, MINI_REV);
+		ML_horizontal_line(6, 0, length_of_time_line - 1, BLACK);
+		ML_horizontal_line(7, 0, length_of_time_line - 1, BLACK);
+	}
+	ML_bmp_8_or(time_hud_border, length_of_time_line, 0);
 }
 
 //draws the player