gpu_particle_burst_04.py Diff#

gpu_particle_burst_04.py#
--- /home/docs/checkouts/readthedocs.org/user_builds/arcade-library/checkouts/development/doc/tutorials/gpu_particle_burst/gpu_particle_burst_03.py
+++ /home/docs/checkouts/readthedocs.org/user_builds/arcade-library/checkouts/development/doc/tutorials/gpu_particle_burst/gpu_particle_burst_04.py
@@ -3,6 +3,7 @@
 """
 import random
 import time
+import math
 from array import array
 from dataclasses import dataclass
 
@@ -64,8 +65,10 @@
         def _gen_initial_data(initial_x, initial_y):
             """ Generate data for each particle """
             for i in range(PARTICLE_COUNT):
-                dx = random.uniform(-.2, .2)
-                dy = random.uniform(-.2, .2)
+                angle = random.uniform(0, 2 * math.pi)
+                speed = random.uniform(0.0, 0.3)
+                dx = math.sin(angle) * speed
+                dy = math.cos(angle) * speed
                 yield initial_x
                 yield initial_y
                 yield dx