gpu_particle_burst_04.py Diff#
--- /home/docs/checkouts/readthedocs.org/user_builds/arcade-library/checkouts/latest/doc/tutorials/gpu_particle_burst/gpu_particle_burst_03.py
+++ /home/docs/checkouts/readthedocs.org/user_builds/arcade-library/checkouts/latest/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
import arcade
@@ -31,7 +32,7 @@
# Program to visualize the points
self.program = self.ctx.load_program(
- vertex_shader="vertex_shader_v1.glsl",
+ vertex_shader="vertex_shader_v2.glsl",
fragment_shader="fragment_shader.glsl",
)
@@ -63,8 +64,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