@@ -32,18 +32,18 @@ int main(void)
3232 const int screenHeight = 450 ;
3333
3434 InitWindow (screenWidth , screenHeight , "raylib [shapes] example - starfield effect" );
35-
35+
3636 Color bgColor = ColorLerp (DARKBLUE , BLACK , 0.69f );
37-
37+
3838 // Speed at which we fly forward
3939 float speed = 10.0f /9.0f ;
40-
40+
4141 // We're either drawing lines or circles
4242 bool drawLines = true;
43-
43+
4444 Vector3 stars [STAR_COUNT ] = { 0 };
4545 Vector2 starsScreenPos [STAR_COUNT ] = { 0 };
46-
46+
4747 // Setup the stars with a random position
4848 for (int i = 0 ; i < STAR_COUNT ; i ++ )
4949 {
@@ -65,22 +65,22 @@ int main(void)
6565 if ((int )mouseMove != 0 ) speed += 2.0f * mouseMove /9.0f ;
6666 if (speed < 0.0f ) speed = 0.1f ;
6767 else if (speed > 2.0f ) speed = 2.0f ;
68-
68+
6969 // Toggle lines / points with space bar
7070 if (IsKeyPressed (KEY_SPACE )) drawLines = !drawLines ;
71-
71+
7272 float dt = GetFrameTime ();
73- for (int i = 0 ; i < STAR_COUNT ; i ++ )
73+ for (int i = 0 ; i < STAR_COUNT ; i ++ )
7474 {
7575 // Update star's timer
7676 stars [i ].z -= dt * speed ;
77-
77+
7878 // Calculate the screen position
7979 starsScreenPos [i ] = (Vector2 ){
8080 screenWidth * 0.5f + stars [i ].x /stars [i ].z ,
8181 screenHeight * 0.5f + stars [i ].y /stars [i ].z ,
8282 };
83-
83+
8484 // If the star is too old, or offscreen, it dies and we make a new random one
8585 if ((stars [i ].z < 0.0f ) || (starsScreenPos [i ].x < 0 ) || (starsScreenPos [i ].y < 0.0f ) ||
8686 (starsScreenPos [i ].x > screenWidth ) || (starsScreenPos [i ].y > screenHeight ))
@@ -97,14 +97,14 @@ int main(void)
9797 BeginDrawing ();
9898
9999 ClearBackground (bgColor );
100-
100+
101101 for (int i = 0 ; i < STAR_COUNT ; i ++ )
102102 {
103103 if (drawLines )
104104 {
105105 // Get the time a little while ago for this star, but clamp it
106106 float t = Clamp (stars [i ].z + 1.0f /32.0f , 0.0f , 1.0f );
107-
107+
108108 // If it's different enough from the current time, we proceed
109109 if ((t - stars [i ].z ) > 1e-3 )
110110 {
@@ -113,26 +113,26 @@ int main(void)
113113 screenWidth * 0.5f + stars [i ].x /t ,
114114 screenHeight * 0.5f + stars [i ].y /t ,
115115 };
116-
116+
117117 // Draw a line connecting the old point to the current point
118118 DrawLineV (startPos , starsScreenPos [i ], RAYWHITE );
119119 }
120120 }
121- else
121+ else
122122 {
123123 // Make the radius grow as the star ages
124124 float radius = Lerp (stars [i ].z , 1.0f , 5.0f );
125-
125+
126126 // Draw the circle
127127 DrawCircleV (starsScreenPos [i ], radius , RAYWHITE );
128128 }
129129 }
130-
130+
131131 DrawText (TextFormat ("[MOUSE WHEEL] Current Speed: %.0f" , 9.0f * speed /2.0f ), 10 , 40 , 20 , RAYWHITE );
132132 DrawText (TextFormat ("[SPACE] Current draw mode: %s" , drawLines ? "Lines" : "Circles" ), 10 , 70 , 20 , RAYWHITE );
133-
133+
134134 DrawFPS (10 , 10 );
135-
135+
136136 EndDrawing ();
137137 //----------------------------------------------------------------------------------
138138 }
0 commit comments