Eiyeron Fulmincendii преди 11 години
родител
ревизия
0917f980a5
променени са 7 файла, в които са добавени 65 реда и са изтрити 64 реда
  1. 13 12
      draw_states.c
  2. 8 8
      hexagon.c
  3. 3 3
      init_states.c
  4. 20 20
      struct.h
  5. 7 7
      update_states.c
  6. 7 7
      wall.c
  7. 7 7
      wall.h

+ 13 - 12
draw_states.c

@@ -36,11 +36,11 @@ static const unsigned char hex_border_bottom_right_rev[8] ={0xFC, 0xFC, 0xF8, 0x
 void draw_game(Game_Data *data)
 {
 	fillBackground(data);
-	//draw the player and the lines
+	// draw the player and the lines
 	drawPlayer(data, data->player_angle);
 	drawPolygon(data, data->nb_lines, data->line_transition);
 	drawDiagonals(data, data->nb_lines, data->line_transition);
-    	//showing the walls
+    	// showing the walls
 	if(data->list != NULL)
 		drawWalls(data->list, data, data->nb_lines, data->line_transition);
 	drawHud(data);
@@ -89,12 +89,13 @@ static void fillBackground(Game_Data *data) {
 }
 
 static void drawChrono(Game_Data *data) {
-	unsigned char time_text[8] = "";
+	unsigned char time_text[32] = "";
 
 	sprintf(time_text, "%.2f", data->chrono_time);
 
-
 	if(data->chrono_time < 60) {
+		// Drawing the text with the little progress bar. As I offset the text,
+		// I need to remake the whole routine.
 		ML_Color drawing_color = data->are_colors_reversed ? WHITE : BLACK;
 		unsigned int text_color = data->are_colors_reversed ? MINI_OVER : MINI_REV;
 		unsigned short length_of_time, length_of_time_line;
@@ -196,17 +197,17 @@ static void drawPolygon(Game_Data *data, int nb_lines, Line_Transition line_tran
 		}
 	}while(i <= nb_lines);
 
-	//draw the aforementionned circle, depending on the camera's center
-	//ML_filled_circle(cam.cX, cam.cY, 6, BLACK);
+	// draw the aforementionned circle, depending on the camera's center
+	// ML_filled_circle(cam.cX, cam.cY, 6, BLACK);
 	ML_polygone(x, y, nb_lines, drawing_color);
-	//draw the player. At such a low scale, it was impossible to draw a rotating triangle, so its a radius 1 circle instead.
+	// draw the player. At such a low scale, it was impossible to draw a rotating triangle, so its a radius 1 circle instead.
 	// TODO : Replace it for a quick sprite blit, or unwrapped ML_pixel procedure.
 }
 
-//draws the player
-//at first, was supposed to draw an hexagon in the center, plus a triangle to show the player,
-//but the hexagon was not visible, and it was a pixel mess, so we're showing a circle instead.
-//there is still for code to calculate the vertices of the hexagon, in case we want to change that again
+// draws the player
+// at first, was supposed to draw an hexagon in the center, plus a triangle to show the player,
+// but the hexagon was not visible, and it was a pixel mess, so we're showing a circle instead.
+// there is still for code to calculate the vertices of the hexagon, in case we want to change that again
 static void drawPlayer(Game_Data *data, int player_angle)
 {
 	ML_Color drawing_color = data->are_colors_reversed ? WHITE : BLACK;
@@ -215,7 +216,7 @@ static void drawPlayer(Game_Data *data, int player_angle)
 
 }
 
-//draws one of the three rotating lines
+// draws one of the three rotating lines
 static void drawDiagonals(Game_Data *data, int nb_lines, Line_Transition line_transition)
 {
 	fix tmp_angle = FIX(data->cam.angle);

+ 8 - 8
hexagon.c

@@ -10,11 +10,11 @@
 int AddIn_main(int isAppli, unsigned short OptionNum)
 {
     Game_Data data;
-	//variables for fps calculation
+	// variables for fps calculation
     unsigned int fps = 0, frame = 0, tempsOrigine = RTC_GetTicks();
-	//char string to display the fps
+	// char string to display the fps
     unsigned char fps_text[8] = {0};
-	//rand initialisation
+	// rand initialisation
     srand(RTC_GetTicks());
 
     // Key init
@@ -25,9 +25,9 @@ int AddIn_main(int isAppli, unsigned short OptionNum)
     switch_to_state(TITLE, &data);
 
 
-    while(KeyUp(K_EXIT)){ //main loop
-        //fps
-        if(RTC_GetTicks() - tempsOrigine >= 32 )//if 1/4 seconds elapsed
+    while(KeyUp(K_EXIT)){ // main loop
+        // fps
+        if(RTC_GetTicks() - tempsOrigine >= 32 )// if 1/4 seconds elapsed
         {
             fps = frame*4;
             frame = 0;
@@ -39,9 +39,9 @@ int AddIn_main(int isAppli, unsigned short OptionNum)
         update(&data);
         draw(&data);
 
-	//printing debug information
+	// printing debug information
 
-	//updating the screen
+	// updating the screen
         ML_display_vram();
         ML_clear_vram();
 

+ 3 - 3
init_states.c

@@ -161,7 +161,7 @@ void init_game(Game_Data *data)
 
 
 	data->list = NULL;
-	data->start_time = RTC_GetTicks(); //1 tick == 1/128 second
+	data->start_time = RTC_GetTicks(); // 1 tick == 1/128 second
 	data->last_time = 0;
 	data->current_time = RTC_GetTicks();
 	data->chrono_time = 0;
@@ -183,7 +183,7 @@ void init_game(Game_Data *data)
 }
 void init_title(Game_Data *data)
 {
-	data->start_time = RTC_GetTicks(); //1 tick == 1/128 second
+	data->start_time = RTC_GetTicks(); // 1 tick == 1/128 second
 	data->last_time = 0;
 	data->current_time = RTC_GetTicks();
 	data->chrono_time = 0;
@@ -205,7 +205,7 @@ void init_title(Game_Data *data)
 }
 void init_menu(Game_Data *data)
 {
-	data->start_time = RTC_GetTicks(); //1 tick == 1/128 second
+	data->start_time = RTC_GetTicks(); // 1 tick == 1/128 second
 	data->last_time = 0;
 	data->current_time = RTC_GetTicks();
 	data->chrono_time = 0;

+ 20 - 20
struct.h

@@ -3,7 +3,7 @@
 
 #include "stdlib.h"
 
-//constants
+// constants
 #define FPS 20
 #define FRAME_TIME 1/FPS
 #define PI 3.14159265
@@ -13,7 +13,7 @@
 #define false 0
 #define bool unsigned char
 
-//macros
+// macros
 #define abs(x) x>0 ? x : -x
 
 typedef struct Camera Camera;
@@ -27,9 +27,9 @@ typedef enum {GAME, MENU, TITLE, GAME_OVER} State;
 
 struct Level{
 
-	int id; //1 to 6
+	int id; // 1 to 6
 
-	//for the level generation
+	// for the level generation
 	Pattern* patterns;
 	int nb_patterns;
 
@@ -37,25 +37,25 @@ struct Level{
 	// Just compare Hexagon and Hexagonest in the original game
 	float player_rotation_speed;
 
-	//for the camera rotation
-	int cam_change_interval; //5 seconds most of the time, but who knows...
-	int cam_change_precision; //to add a bit of randomness to the intervals
-	float cam_change_probability; //sometimes, there can be no change at all
-	//camera speed
+	// for the camera rotation
+	int cam_change_interval; // 5 seconds most of the time, but who knows...
+	int cam_change_precision; // to add a bit of randomness to the intervals
+	float cam_change_probability; // sometimes, there can be no change at all
+	// camera speed
 	float cam_max_speed;
 	float cam_min_speed;
 
-	float fast_spin_probability; //very low, there sometimes is a slightly faster spin for one second, then a normal spin. This is the number that allow us to generate it
+	float fast_spin_probability; // very low, there sometimes is a slightly faster spin for one second, then a normal spin. This is the number that allow us to generate it
 	
-	//for the line number changes (lc prefix):
-	int lc_min_score; //minimum score in seconds to reach before any line number change occurs
+	// for the line number changes (lc prefix):
+	int lc_min_score; // minimum score in seconds to reach before any line number change occurs
 	float lc_probability;
 	int lc_duration;
 };
 
-//the camera is defined by its center
+// the camera is defined by its center
 // ! and not by its upper left corner !
-//and an angle
+// and an angle
 struct Camera{
     int cX;
     int cY;
@@ -65,12 +65,12 @@ struct Camera{
     float speed;
 };
 
-//a simple obstacle structure
-//d is the distance from the lowest face of the trapeze to the center of the screen
-//h is the thickness of the wall
-//line indicates the line that contains this obstacle
-//id is self explanatory
-//nxt is used by the linked list
+// a simple obstacle structure
+// d is the distance from the lowest face of the trapeze to the center of the screen
+// h is the thickness of the wall
+// line indicates the line that contains this obstacle
+// id is self explanatory
+// nxt is used by the linked list
 struct Wall{
     float d;
     unsigned int h;

+ 7 - 7
update_states.c

@@ -28,18 +28,18 @@ void update_game(Game_Data *data)
 	}
 
 	if(data->list != NULL) {
-	//if the linked list is not empty
+	// if the linked list is not empty
 		updateWalls(data->list, min(data->current_time - data->last_time, 2));
-		//update the linked list
+		// update the linked list
 
-		//if the player and a wall collide
+		// if the player and a wall collide
 		if(isColliding(data->list, data->player_angle, data->nb_lines) == true) {
-			//death handling
+			// death handling
 		}
-	//remove every wall whose distance to the center equals zero
+	// remove every wall whose distance to the center equals zero
 		data->list = removeWall(data->list, 8);
 	}
-	//level generation
+	// level generation
 	if(!data->cooldown_timer--) {
 		Pattern pattern = data->level->patterns[rand()% data->level->nb_patterns];
 		addPattern(data, &pattern, rand()%data->nb_lines, rand()&1);
@@ -102,7 +102,7 @@ void update_menu(Game_Data *data)
 }
 void update_game_over(Game_Data *data)
 {
-//TODO
+// TODO
 }
 
 void updateCamera(Camera *cam, unsigned int delta_time){

+ 7 - 7
wall.c

@@ -67,7 +67,7 @@ Wall *removeWall(Wall *list, int d)
 
 void updateWalls(Wall *list, unsigned int delta_time)
 {
-	//we want to move the obstacle by 1 every two ticks (1/64 seconds ~= 1/60)
+	// we want to move the obstacle by 1 every two ticks (1/64 seconds ~= 1/60)
 	//
 	Wall *tmp;
 	tmp = list;
@@ -75,7 +75,7 @@ void updateWalls(Wall *list, unsigned int delta_time)
 	do{
 		if(tmp != NULL)
 		{
-			//just reducing the distance from the center
+			// just reducing the distance from the center
 			tmp->d -= 0.5 * delta_time;
 		}
 		tmp = tmp->nxt;
@@ -83,7 +83,7 @@ void updateWalls(Wall *list, unsigned int delta_time)
 }
 
 void drawWalls(Wall *list, Game_Data *data, int nb_lines, Line_Transition line_transition)
-{//NEEDS A COMPLETE REWRITE TO SUPPORT THE LINE TRANSITIONS !
+{// NEEDS A COMPLETE REWRITE TO SUPPORT THE LINE TRANSITIONS !
 	Wall *tmp;
 	ML_Color drawing_color = data->are_colors_reversed ? WHITE : BLACK;
 	Camera *cam = &data->cam;
@@ -128,7 +128,7 @@ void drawWalls(Wall *list, Game_Data *data, int nb_lines, Line_Transition line_t
 
 }
 
-//tests every Wall in the list
+// tests every Wall in the list
 bool isColliding(Wall *list, int player_angle, int nb_lines)
 {
 	Wall *tmp;
@@ -137,10 +137,10 @@ bool isColliding(Wall *list, int player_angle, int nb_lines)
 	do{
 		if(tmp != NULL)
 		{
-			if(tmp-> d <= 8+tmp->h + 2)//if the wall is close enough from the center of the screen
-			{	//and is on the same line than the player
+			if(tmp-> d <= 8+tmp->h + 2)// if the wall is close enough from the center of the screen
+			{	// and is on the same line than the player
 				if(tmp->line == (int)(player_angle/ (360 / nb_lines)) && tmp->line < nb_lines)
-				{	//BOOM
+				{	// BOOM
 					return true;
 				}
 			}

+ 7 - 7
wall.h

@@ -4,15 +4,15 @@
 #include "struct.h"
 #include "MonochromeLib.h"
 #include "math.h"
-//adds a wall to the linked list specified in the parameter "list"
-Wall *addWall(Wall *list, int d, int h, int id, int line);//returns a new pointer to the first element
-//removes every wall from "list" whose d member is smaller than the "d" passed as argument
-Wall *removeWall(Wall *list, int d); //returns a new pointer to the first element
+// adds a wall to the linked list specified in the parameter "list"
+Wall *addWall(Wall *list, int d, int h, int id, int line);// returns a new pointer to the first element
+// removes every wall from "list" whose d member is smaller than the "d" passed as argument
+Wall *removeWall(Wall *list, int d); // returns a new pointer to the first element
 
-//show the ll "list"
+// show the ll "list"
 void drawWalls(Wall *list, Game_Data *data, int nb_lines, Line_Transition line_transition);
-//updates the ll "list"
+// updates the ll "list"
 void updateWalls(Wall *list, unsigned int delta_time);
-//simple collision test. Returns true if a Wall from the list collides with the player
+// simple collision test. Returns true if a Wall from the list collides with the player
 bool isColliding(Wall *list, int player_angle, int nb_lines);
 #endif