Просмотр исходного кода

Fixed collisions (again ?) and started impmementing game over state

Eiyeron Fulmincendii лет назад: 11
Родитель
Сommit
f8fcd97f6e
5 измененных файлов с 43 добавлено и 26 удалено
  1. 3 3
      ECode.c
  2. 16 4
      draw_states.c
  3. 16 6
      init_states.c
  4. 6 11
      update_states.c
  5. 2 2
      wall.c

+ 3 - 3
ECode.c

@@ -1,4 +1,4 @@
-/***********************************/
+ /***********************************/
 /**          Easy Coding          **/
 /**Category : Snippets Collection **/
 /**@author Eiyeron                **/
@@ -614,7 +614,7 @@ int downBit_int(int num, char index)
 }
 #endif
 
-
+// TODO : Foudn the new function to detect architecture instead of using versions.
 
 static void delay( void ) // Cette fonction n'est utilisée que pour KeyDown/Up, et elle n'est absolument pas utile ailleurs. D'où le static.
 {
@@ -640,7 +640,7 @@ int OSVersionAsInt(void)
 	return ( ( mainversion << 24 ) & 0xFF000000 ) | ( ( minorversion << 16 ) & 0x00FF0000 ) | ( release & 0x0000FFFF );
 }
 #define isOS2 (OSVersionAsInt() >= 0x02020000)
-#define OS2(x,y) ((OSVersionAsInt() >= 0x02020000)?y:x)
+#define OS2(x,y) ((isOS2)?y:x)
 #endif
 #ifndef OS2Change_Keyboard
 #define OS2Change_Keyboard

+ 16 - 4
draw_states.c

@@ -54,12 +54,10 @@ void draw_title(Game_Data *data)
 	drawPolygon(data, data->nb_lines, data->line_transition);
 	drawDiagonals(data, data->nb_lines, data->line_transition);
 	drawBottomLeftCornerText("Press Shift", data->are_colors_reversed);	
-	drawBottomRightCornerText("By Eiyeron", data->are_colors_reversed);	
+	drawTopRightCornerText("By Eiyeron & Adbook", data->are_colors_reversed);	
 }
 void draw_menu(Game_Data *data)
 {
-	char buffer[20];
-	sprintf(buffer, "%i", data->cam.angle);
 	fillBackground(data);
 	drawPolygon(data, data->nb_lines, data->line_transition);
 	drawDiagonals(data, data->nb_lines, data->line_transition);
@@ -71,7 +69,13 @@ void draw_menu(Game_Data *data)
 }
 void draw_game_over(Game_Data *data)
 {
-
+	unsigned char time_text[32] = "";
+	sprintf(time_text, "%.2f", data->chrono_time);
+	fillBackground(data);
+	drawPolygon(data, data->nb_lines, data->line_transition);
+	drawDiagonals(data, data->nb_lines, data->line_transition);
+	drawTopLeftCornerText(time_text, data->are_colors_reversed);
+	drawBottomLeftCornerText("Press Shift to retry", data->are_colors_reversed);
 }
 
 static void fillBackground(Game_Data *data) {
@@ -311,6 +315,14 @@ static unsigned int length_of_print_string(unsigned char* txt) {
 			current_char_length = 6;
 			break;
 
+			case '&':
+			current_char_length = 5;
+			break;
+
+			case '[':
+			case ']':
+			current_char_length = 3;
+			break;
 			//
 			//
 			default:

+ 16 - 6
init_states.c

@@ -244,15 +244,25 @@ void init_menu(Game_Data *data)
 	data->keypress_delay = 50;
 	data->nb_entries = 6;
 	data->current_entry = 1;
-data->current_entry_high_score = 0; //to load from a save file
-data->entry_difficulties = NULL;
-data->entry_difficulties = malloc(sizeof(char*) * 6);
-if(data->entry_difficulties == NULL)
-	return;
-load_difficulty_names(data->entry_difficulties);
+	data->current_entry_high_score = 0; //to load from a save file
+	data->entry_difficulties = NULL;
+	data->entry_difficulties = malloc(sizeof(char*) * 6);
+	if(data->entry_difficulties == NULL)
+		return;
+	load_difficulty_names(data->entry_difficulties);
 }
 
 void init_game_over(Game_Data *data)
 {
+	data->cam.cX = 96;
+	data->cam.cY = 32;
+	data->cam.angle = 0;
+	data->cam.speed = 1;
+	data->cam.zoom = 12;
+
+	data->nb_lines = 6;
+	data->line_transition.counter = 0;
+	data->line_transition.counter_start = 0;
+	data->line_transition.delta_nb_lines = 0;
 
 }

+ 6 - 11
update_states.c

@@ -50,12 +50,10 @@ void update_game(Game_Data *data)
 	}
 
 	if(KeyDown(K_LEFT)) {
-		float new_player_position = data->player_angle - data->level->player_rotation_speed *  (data->current_time - data->last_time)*FRAME_TIME;
-		data->player_angle = new_player_position;
+		data->player_angle = data->player_angle - data->level->player_rotation_speed *  (data->current_time - data->last_time)*FRAME_TIME;
 	}
 	if(KeyDown(K_RIGHT)) {
-		float new_player_position = data->player_angle + data->level->player_rotation_speed *  (data->current_time - data->last_time)*FRAME_TIME;
-		data->player_angle = new_player_position;
+		data->player_angle = data->player_angle + data->level->player_rotation_speed *  (data->current_time - data->last_time)*FRAME_TIME;
 	}
 
 	if(KeyDown(K_ALPHA) && data->alpha_latch_value == 0) {
@@ -91,15 +89,12 @@ void update_game(Game_Data *data)
 
 void update_game_over(Game_Data *data)
 {
-	data->last_time = data->current_time;
-	data->current_time = RTC_GetTicks();
-	data->chrono_time += (data->current_time - data->last_time)/ 128.;
-
 	if(KeyDown(K_SHIFT) && data->shift_latch_value == 0) {
 		switch_to_state(GAME, data);
 	}
-	if(KeyDown(K_ALPHA) && data->alpha_latch_value == 0) {
-		switch_to_state(TITLE, data);
+
+	if((KeyDown(K_ALPHA) && data->alpha_latch_value == 0)) {
+		switch_to_state(MENU, data);
 	}
 
 
@@ -172,5 +167,5 @@ static void game_over(Game_Data *data) {
 	}
 	free(data->level);
 
-	switch_to_state(MENU, data);
+	switch_to_state(GAME_OVER, data);
 }

+ 2 - 2
wall.c

@@ -160,8 +160,8 @@ 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
-			if(tmp-> d <= 8 + 2)// if the wall is close enough from the center of the screen
+			if(tmp-> d <= 8+tmp->h + 2)// if the wall is close enough from the center of the screen
+			//if(tmp-> d <= 8 + 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