Don't calculate every single frame
This commit is contained in:
		
							parent
							
								
									34027d5239
								
							
						
					
					
						commit
						3c4f882d18
					
				
							
								
								
									
										9
									
								
								main.c
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								main.c
									
									
									
									
									
								
							| @ -70,6 +70,7 @@ int main(int argc, char** argv) { | |||||||
| 
 | 
 | ||||||
|     float delta; |     float delta; | ||||||
|     Vector2 mouse_position; |     Vector2 mouse_position; | ||||||
|  |     char *calculation = ""; | ||||||
| 
 | 
 | ||||||
|     while (!WindowShouldClose()) { |     while (!WindowShouldClose()) { | ||||||
|       delta = GetFrameTime(); |       delta = GetFrameTime(); | ||||||
| @ -79,6 +80,7 @@ int main(int argc, char** argv) { | |||||||
| 	for (int i = 0; i < 48; i++) { | 	for (int i = 0; i < 48; i++) { | ||||||
| 	  if (point_within_card(&cards[i], mouse_pos)) { | 	  if (point_within_card(&cards[i], mouse_pos)) { | ||||||
| 	    cards[i].selected = !cards[i].selected; | 	    cards[i].selected = !cards[i].selected; | ||||||
|  | 	    calculation = ""; | ||||||
| 	    break; | 	    break; | ||||||
| 	  } | 	  } | ||||||
| 	} | 	} | ||||||
| @ -92,16 +94,17 @@ int main(int argc, char** argv) { | |||||||
| 	draw_card(&cards[i]); | 	draw_card(&cards[i]); | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|       if (num_selected == 7) { |       if (strlen(calculation) == 0 && num_selected == 7) { | ||||||
| 	Hand h; | 	Hand h; | ||||||
| 	h.count = 0; | 	h.count = 0; | ||||||
| 	for (int i = 0; i < 48; i++) { | 	for (int i = 0; i < 48; i++) { | ||||||
| 	  if (cards[i].selected) memcpy(&h.cards[h.count++], &cards[i], sizeof(Card)); | 	  if (cards[i].selected) memcpy(&h.cards[h.count++], &cards[i], sizeof(Card)); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	char *s = TextFormat("Set: %s(%d) / Chaff: %s(%d) / Total: %d", set_teyaku_english(h), set_teyaku_points(h), chaff_teyaku_english(h), chaff_teyaku_points(h), calculate_teyaku(h)); | 	calculation = TextFormat("Set: %s(%d) / Chaff: %s(%d) / Total: %d", set_teyaku_english(h), set_teyaku_points(h), chaff_teyaku_english(h), chaff_teyaku_points(h), calculate_teyaku(h)); | ||||||
| 	DrawText(s, 10, 500, 25, BLACK); |  | ||||||
|       } |       } | ||||||
|  | 
 | ||||||
|  |       DrawText(calculation, 10, 500, 25, BLACK); | ||||||
|       EndDrawing(); |       EndDrawing(); | ||||||
|     } |     } | ||||||
|        |        | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user