PDA

Click to See Complete Forum and Search --> : SetPixel() : An Interesting Example


plenderj
Jun 10th, 2002, 04:39 AM
Enclosed is an example of using SetPixel().
This example, which I like to call 'flies', creates a black picturebox.
Then once you click inside the PictureBox, it will create what looks like lots of flies.
When you move the mouse cursor around they try to get away from the cursor.
I think it looks quite nice :)

If you have any queries or comments, just let me know.

plenderj
Oct 21st, 2004, 09:49 AM
* 21-October-2004 - Moved to CodeBank *

wossname
Oct 22nd, 2004, 04:31 PM
Just spent 10 minutes messing with it. :D

(the program that is)

plenderj
Oct 22nd, 2004, 04:40 PM
Actually I forgot what that app did. God that is so much fun :D

kill_bill_gates
Nov 15th, 2004, 06:55 AM
:thumb:

great app. really funny :D

Ishaan
Nov 15th, 2004, 11:12 PM
hi

great prog
i tried to change the area around the cursor to a box but it still behaves like as if it was a circle???

onil

also at

onil67@hotmail.com

plenderj
Nov 16th, 2004, 04:38 AM
The flies' positions are goverened by this:


For i = 0 To UBound(pixels) - 1
With pixels(i)
''
'' some code
''
If distanceBetweenTwoPoints(pos, .pos) < 25 Then
Do Until (distanceBetweenTwoPoints(pos, .pos) > 35)
With .pos
.x = .x + (2 * Rnd)
.Y = .Y + (2 * Rnd)
End With
Loop
End If
''
'' some code
''
Next

''
'' elsewhere
''
Private Function distanceBetweenTwoPoints(ByRef point1 As pointapi, ByRef point2 As pointapi) As Single
distanceBetweenTwoPoints = (((point2.x - point1.x) ^ 2) + ((point2.Y - point1.Y) ^ 2)) ^ 0.5
End Function