Results 1 to 22 of 22

Thread: Worms!

  1. #1

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111

    Worms!

    worms
    Attached Files Attached Files

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    virus?

  3. #3

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Originally posted by si_the_geek
    virus?
    Definately not a virus.

    It doesn't self-replicate.


  4. #4
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    What does it do then? I would like to know that before I run it.

  5. #5

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    It's a visualisation.

    Two roundrects with AlphaBlending to black.

    Trippy effect to say the least.

  6. #6
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431
    That is trippy. I'd love to see that source code
    Last edited by jemidiah; Oct 27th, 2003 at 10:37 PM.
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  7. #7
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    Wow, Thats nice. It almost looks as if I'm doing something scientific when I run that. Though when they start taking up a lot of screen space, it gets a bit.... whats the word..
    boring i think will have to do.

  8. #8
    pathfinder NotLKH's Avatar
    Join Date
    Apr 2001
    Posts
    2,397
    Very Funny.
    I tried running it from the zip, and the first time all I saw was a blank window, the size of my screen.

    The second time I tried running it from the zip, it told me that c:\windows\temp\worm2.exe was in use, in essence couldn't be overwritten.

    So..., going there, I can't delete it.



    Whats next? My hard drive wiped?
    Whatcha do?
    How do I cleanse my system?

    -Lou
    Attached Images Attached Images  

  9. #9
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    Strange, I did the same thing and it worked. I'll try again...


    ... Yep, still works straight from the .zip

  10. #10
    pathfinder NotLKH's Avatar
    Join Date
    Apr 2001
    Posts
    2,397
    There we go. Got it deleted.
    Still, running it gives me a temporary, fleeting glimpse of a screen shot with two ovals placed, then it instantly becomes a black window.

  11. #11

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Originally posted by NotLKH
    There we go. Got it deleted.
    Still, running it gives me a temporary, fleeting glimpse of a screen shot with two ovals placed, then it instantly becomes a black window.
    Try making the window smaller.

    The AlphaBlend can be slow on some systems.

  12. #12

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    VB Code:
    1. Option Explicit
    2.  
    3. Private Type tLoc
    4.     x As Double
    5.     y As Double
    6.     Vx As Double
    7.     Vy As Double
    8. End Type
    9.  
    10. Private p(5) As tLoc
    11.  
    12. Private Cnt As Long
    13. Private Declare Function RoundRect Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long
    14. Private Declare Function AlphaBlend Lib "msimg32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal widthSrc As Long, ByVal heightSrc As Long, ByVal blendFunct As Long) As Boolean
    15. Private Declare Function GetTickCount Lib "kernel32" () As Long
    16.  
    17. Private Sub Form_Activate()
    18. Dim t As Long, x As Integer, pCnt As Integer
    19. Dim c(2) As Single
    20. Randomize
    21. t = GetTickCount
    22. pCnt = UBound(p)
    23. For x = 0 To pCnt
    24. p(x).x = ScaleWidth * Rnd
    25. p(x).y = ScaleHeight * Rnd
    26. p(x).Vx = 1 * Rnd
    27. p(x).Vy = 1 * Rnd
    28. Next
    29.  
    30. Do
    31. For x = 0 To pCnt
    32. p(x).x = p(x).x + p(x).Vx
    33. p(x).y = p(x).y + p(x).Vy
    34. If p(x).x < 0 Then p(x).x = 0: p(x).Vx = Abs(p(x).Vx)
    35. If p(x).y < 0 Then p(x).y = 0: p(x).Vy = Abs(p(x).Vy)
    36. If p(x).x > ScaleWidth Then p(x).x = ScaleWidth: p(x).Vx = -Abs(p(x).Vx)
    37. If p(x).y > ScaleHeight Then p(x).y = ScaleHeight: p(x).Vy = -Abs(p(x).Vy)
    38. p(x).Vx = p(x).Vx + (Rnd - Rnd) / 100
    39. p(x).Vy = p(x).Vy + (Rnd - Rnd) / 100
    40.  
    41. If p(x).Vx < -1 Then p(x).Vx = 2 * Rnd - 1
    42. If p(x).Vy < -1 Then p(x).Vy = 2 * Rnd - 1
    43. If p(x).Vx > 1 Then p(x).Vx = 2 * Rnd - 1
    44. If p(x).Vy > 1 Then p(x).Vy = 2 * Rnd - 1
    45. Next
    46.  
    47. For x = 0 To 2
    48.  c(x) = c(x) + Rnd * 2 - Rnd * 2
    49.  If c(x) < 0 Then c(x) = 0
    50.  If c(x) > 255 Then c(x) = 255
    51. Next
    52.  
    53. ForeColor = RGB(c(0), c(1), c(2))
    54. RoundRect hdc, p(0).x, p(0).y, p(1).x, p(1).y, p(2).x, p(2).y
    55. ForeColor = RGB(c(2), c(1), c(0))
    56. RoundRect hdc, p(3).x, p(3).y, p(4).x, p(4).y, p(5).x, p(5).y
    57. Cnt = Cnt + 1
    58. If (Cnt Mod 8) = 0 Then
    59. 'Caption = Cnt / ((GetTickCount - t + 1) / 1000)
    60. AlphaBlend hdc, 0, 0, ScaleWidth, ScaleHeight, Picture1.hdc, 0, 0, ScaleWidth, ScaleHeight, &H10000
    61. 'Refresh
    62. DoEvents
    63. End If
    64. Loop
    65. End Sub
    66.  
    67.  
    68. Private Sub Form_Resize()
    69. Picture1.Move 0, 0, ScaleWidth, ScaleHeight
    70. End Sub
    71.  
    72. Private Sub Form_Unload(Cancel As Integer)
    73. End 'Muwhahahahahahahahahahahahahaha!
    74. End Sub

  13. #13
    pathfinder NotLKH's Avatar
    Join Date
    Apr 2001
    Posts
    2,397
    hdc isn't dimmed, nor does it have a value assigned to it? {Amazingly, Option Explicit isn't complaining!}

    Unless RoundRect initializes it.

    Anyways, I compiled it and ran it on my work PC.
    Its a nice, blank form, just sitting on my screen, ohh about 2x3 inches.

    The Picture box is framed by the form window.

    Thats about it.

    Oh. Its a nice shade of default grey.

    Is there anything that needs to be assigned to the form or picture1 props?


  14. #14

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Originally posted by NotLKH
    hdc isn't dimmed, nor does it have a value assigned to it? {Amazingly, Option Explicit isn't complaining!}

    Unless RoundRect initializes it.

    Anyways, I compiled it and ran it on my work PC.
    Its a nice, blank form, just sitting on my screen, ohh about 2x3 inches.

    The Picture box is framed by the form window.

    Thats about it.

    Oh. Its a nice shade of default grey.

    Is there anything that needs to be assigned to the form or picture1 props?

    You don't program eh?

    hdc is a property of the Form.

    Picture1 should have auto redraw set to true.

  15. #15
    pathfinder NotLKH's Avatar
    Join Date
    Apr 2001
    Posts
    2,397
    hdc is also a property of a picturebox, so a hanging hdc, unatached to any parent control or form, is ambiguous, and imho NGCP.

    I always use the Parent Controls name when using properties.
    Outside of a with, I never do it any other way.

    -Lou

  16. #16

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Originally posted by NotLKH
    hdc is also a property of a picturebox, so a hanging hdc, unatached to any parent control or form, is ambiguous, and imho NGCP.

    I always use the Parent Controls name when using properties.
    Outside of a with, I never do it any other way.

    -Lou
    Not attached?

    It's in Private Sub Form_Activate()!

    A with still needs a . before the call.

    For example:

    VB Code:
    1. Private Sub Picture1_Click()
    2. With Picture1
    3. MsgBox hDC & " " & .hDC
    4. End With
    5. End Sub

    I don't see how it's ambiguous, unless you can't read BASIC.

  17. #17
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    I think it's ambiguous too, and I can certianly read basic.

    I also don't like your lack of indentation, and (understandable) lack of comments. I'm not impressed with the use of End either - a simple boolean removes the need for it.

    anyway, the biggest issue is the fact that nothing seems to happen (as with NotLKH)


    after a lot of fiddling (such as setting the scalemode to pixels, and changing the code to draw on the picturebox) I managed to get a few circles.. wow! so pretty

    (I think AlphaBlend doesn't work on Win 2000 )

  18. #18
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    (I think AlphaBlend doesn't work on Win 2000)
    That might very well be the case ( I had heard it only works on XP), but it would seem wierd that it works on me Win98 SE.

  19. #19
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    I see.. it makes sense that Win2000 doesn't have features that Win95/98 and WinXP have - as 2000 is based on NT, and XP combines features of NT and 95/98.

  20. #20
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    oh, ok, thanks for the explanation.

  21. #21
    pathfinder NotLKH's Avatar
    Join Date
    Apr 2001
    Posts
    2,397
    Nope. Alphablend does work on Win2000.

    Just tried this AllApi code.
    Works just fine:

    VB Code:
    1. Const AC_SRC_OVER = &H0
    2. Private Type BLENDFUNCTION
    3.   BlendOp As Byte
    4.   BlendFlags As Byte
    5.   SourceConstantAlpha As Byte
    6.   AlphaFormat As Byte
    7. End Type
    8. Private Declare Function AlphaBlend Lib "msimg32.dll" (ByVal hdc As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal hdc As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal BLENDFUNCT As Long) As Long
    9. Private Declare Sub RtlMoveMemory Lib "kernel32.dll" (Destination As Any, Source As Any, ByVal Length As Long)
    10. Private Sub Form_Load()
    11.     'KPD-Team 2000
    12.     'URL: [url]http://www.allapi.net/[/url]
    13.     'E-Mail: [email][email protected][/email]
    14.     Dim BF As BLENDFUNCTION, lBF As Long
    15.     'Set the graphics mode to persistent
    16.     Picture1.AutoRedraw = True
    17.     Picture2.AutoRedraw = True
    18.     'API uses pixels
    19.     Picture1.ScaleMode = vbPixels
    20.     Picture2.ScaleMode = vbPixels
    21.     'set the parameters
    22.     With BF
    23.         .BlendOp = AC_SRC_OVER
    24.         .BlendFlags = 0
    25.         .SourceConstantAlpha = 128
    26.         .AlphaFormat = 0
    27.     End With
    28.     'copy the BLENDFUNCTION-structure to a Long
    29.     RtlMoveMemory lBF, BF, 4
    30.     'AlphaBlend the picture from Picture1 over the picture of Picture2
    31.     AlphaBlend Picture2.hdc, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, lBF
    32. End Sub

    -Lou

  22. #22

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Originally posted by si_the_geek
    I think it's ambiguous too, and I can certianly read basic.

    I also don't like your lack of indentation, and (understandable) lack of comments. I'm not impressed with the use of End either - a simple boolean removes the need for it.

    anyway, the biggest issue is the fact that nothing seems to happen (as with NotLKH)


    after a lot of fiddling (such as setting the scalemode to pixels, and changing the code to draw on the picturebox) I managed to get a few circles.. wow! so pretty

    (I think AlphaBlend doesn't work on Win 2000 )
    I didn't really care about the code's indention. It's pretty damn simple(I was asked for the source).

    You people are just anal retentive.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width