Commits

Trammell Hudson committed d9bf4ef

Use age of stars instead of distance to age them

  • Participants
  • Parent commits 83b2f98

Comments (0)

Files changed (1)

 	int8_t dx;
 	int8_t dy;
 	uint8_t brightness;
+	uint16_t age;
 } __attribute__((packed));
 
 
 
 	star->x = 0;
 	star->y = 0;
+	star->age = 0;
 
 	// Brighter stars are faster
 	star->brightness = vel * 2;
 	int32_t y = (APP->rotate_cos * star->y + APP->rotate_sin * star->x) / 120 + dy;
 
 	if (x <= -SCREEN_WIDTH * 8 || x >= SCREEN_WIDTH * 8
-	||  y <= -SCREEN_HEIGHT * 8 || y >= SCREEN_HEIGHT * 8)
+	||  y <= -SCREEN_HEIGHT * 8 || y >= SCREEN_HEIGHT * 8
+	||  star->age++ > 2000)
 	{
 		star_create(star);
 		return;
 	};
 
 	// Earlier stars are darker
-	if (star->x > -200 && star->x < 200
-	&&  star->y > -200 && star->y < 200)
+	if (star->age < 100)
 		color.red = color.blue = color.green = star->brightness / 4;
 	else
-	if (star->x > -400 && star->x < 400
-	&&  star->y > -400 && star->y < 400)
+	if (star->age < 200)
 		color.red = color.blue = color.green = star->brightness / 2;
 
 	star_draw_point(star, color);