Commits

Trammell Hudson committed d9bf4ef

Use age of stars instead of distance to age them

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);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.