Post by PeterMaria on Jul 21, 2015 8:27:38 GMT -5
Hi,
Declare Sub Init2D(width,height)
Declare Sub SetPixel(x#,y#,size#)
Declare Function Rand(min,max)
dim anzahl=3000, aSpeed#, i, c
dim xscreen=640, yscreen=480
dim xmitte=xscreen/2, ymitte=yscreen/2
dim x#(3000)
dim y#(3000)
dim angle#(3000)
dim speed#(3000)
dim sinus#(360)
dim cosin#(360)
For i=1 to anzahl
x#(i) = xmitte
y#(i) = ymitte
angle#(i)= Rand(1,360)
speed#(i)= Rand(1,3)
Next
For i=0 to 360
sinus#(i) = sin(i)
cosin#(i) = cos(i)
Next
Function xMove(x#,w,speed#)
Return x# + cosin#(w)*speed#
End Function
Function yMove(y#,w,speed#)
Return y# + sinus#(w)*speed#
End Function
Function Distance(x1,y1,x2,y2)
dim dx, dy
dx = x1-x2: dy = y1-y2
Return abs(sqr(dx*dx+dy*dy))
End Function
Init2D(640,480)
glEnable(GL_POINT_SMOOTH)
while Keydown(27)=0
glClearColor(0,0,.5,1)
glClear(GL_COLOR_BUFFER_BIT)
For i=0 to anzahl
aSpeed# = Distance(xmitte, ymitte, x#(i),y#(i))/200 * speed#(i)+6
x#(i) = xMove(x#(i), angle#(i), aSpeed#)
y#(i) = yMove(y#(i), angle#(i), aSpeed#)
iF x#(i) <0 or x#(i) > xscreen or y#(i) <0 Or y#(i) > yscreen then
x#(i) = xmitte
y#(i) = ymitte
angle#(i) = Rand(1,360)
speed#(i) = Rand(1,3)
End iF
c = speed#(i)*100-55
glColor3ub(c,c,c)
setpixel(x#(i),y#(i),10)
Next
xmitte = Mouse_x()*640
ymitte = Mouse_y()*480
swapbuffers()
waittimer(10)
wend
Function Rand(min,max)
Return rnd()% (max - min + 1) + min
End Function
Sub Init2D(width,height)
glMatrixMode (GL_PROJECTION)
glLoadIdentity()
glOrtho(0,width,height,0,-1,1)
glMatrixMode (GL_MODELVIEW)
glDisable(GL_DEPTH_TEST)
End Sub
Sub SetPixel(x#,y#,size#)
glPointSize(size#)
glBegin(GL_POINTS)
glVertex2f(x#,y#)
glEnd()
End Sub