Commits

Trammell Hudson committed 8c580c6

Fix rotation problem

Comments (0)

Files changed (1)

 )
 {
 	uint8_t theta = rand() & 0xFF;
-	int32_t vel = (rand() & 0xFF) + 1;
-	star->dx = (sin_lookup(theta) * vel) / 512;
-	star->dy = (cos_lookup(theta) * vel) / 512;
+	int32_t vel = (rand() & 0x7F) + 1;
+	star->dx = (sin_lookup(theta) * vel) / 1024;
+	star->dy = (cos_lookup(theta) * vel) / 1024;
 
 	star->x = 0;
 	star->y = 0;
 
 	// Brighter stars are faster
-	star->brightness = vel;
+	star->brightness = vel * 2;
 }
 
 
 	// Turn off its current location
 	star_draw_point(star, COLOR_BLACK24);
 
-	// Check for age
-	int32_t x = (APP->rotate_cos * star->x - APP->rotate_sin * star->y) / 128 + star->dx;
-	int32_t y = (APP->rotate_cos * star->y + APP->rotate_sin * star->x) / 128 + star->dy;
+	// Rotate the dx and allow it to speed up a bit
+	int32_t dx = (APP->rotate_cos * star->dx - APP->rotate_sin * star->dy) / 120;
+	int32_t dy = (APP->rotate_cos * star->dy + APP->rotate_sin * star->dx) / 120;
+
+	// Rotate the position, also allowing for some speed up
+	int32_t x = (APP->rotate_cos * star->x - APP->rotate_sin * star->y + dx / 2) / 120 + dx;
+	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)
 
 	star->x = x;
 	star->y = y;
+	star->dx = dx;
+	star->dy = dy;
 
 	color24_t color = {
 		.red	= star->brightness,
 	};
 
 	// Earlier stars are darker
-	if (star->x > -100 && star->x < 100
-	&&  star->y > -100 && star->y < 100)
+	if (star->x > -200 && star->x < 200
+	&&  star->y > -200 && star->y < 200)
 		color.red = color.blue = color.green = star->brightness / 4;
 	else
-	if (star->x > -200 && star->x < 200
-	&&  star->y > -200 && star->y < 200)
+	if (star->x > -400 && star->x < 400
+	&&  star->y > -400 && star->y < 400)
 		color.red = color.blue = color.green = star->brightness / 2;
 
 	star_draw_point(star, color);