I'm using point sprites in PyOpenGL with numpy and glDrawArrays. So I have two arrays, one for the points and one for the vectors.
r = lambda: random.random()
self.pts = numpy.zeros((2000,2), dtype=numpy.uint16)
for pt in self.pts:
pt[0] = 300*r()
pt[1] = 200*r()
self.vectors = numpy.zeros((2000,2), dtype=numpy.uint16)
for vec in self.vectors:
vec[0] = 3*r()
vec[1] = 3*r()
Now I need to update the position and vector arrays based on collision with the screen borders. So for example
if pt[0][0]-width < 0: pt[0][0] = width; vec[0][0] *= -1
In the end I must have a 2000x2 arrays of pts on the screen to feed to opengl.
EDIT - Current solution to keeping points inside a bounding box (0,0,width,height)
points [:,0][points[:,0] > width] = width
vectors[:,0][points[:,0] > width] *= -1
points [:,0][points[:,0] < 0] = 0
vectors[:,0][points[:,0] < 0] *= -1
points [:,1][points[:,1] > height] = height
vectors[:,1][points[:,1] > height] *= -1
points [:,1][points[:,1] < 0] = 0
vectors[:,1][points[:,1] < 0] *= -1