VB가 구현한 QQ미녀 트집잡기 게임 커닝기 실례

2597 단어 VBQQ게임커닝기
본고는 VB가 실현한'QQ미녀 트집잡기 게임'커닝기를 실례로 다루고 있다.여러분에게 참고할 수 있도록 나누어 드리겠습니다.구체적으로 다음과 같습니다.
심심하군요. 원리는 간단하고 VB로 속도가 느리지만 실현하기는 쉬워요.

Option Explicit
Private Type sPOINT
  x As Long
  y As Long
End Type
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const HWND_TOPMOST& = -1
'  , 
Private Const SWP_NOSIZE& = &H1
'  
Private Const SWP_NOMOVE& = &H2
'  
Private Sub Form_Load()
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
'  
End Sub
' long RGB 3 
Sub ColorRGB(Color As Long, C() As Integer)
  Const ByN As Integer = 256
  Const ByN2 As Long = 65536
  C(1) = (Color Mod ByN)
  C(2) = ((Color Mod ByN2) \ ByN)
  C(3) = (Color \ ByN2)
End Sub
Private Sub GetPoint()
  Dim p1(497, 447) As Long, p2(497, 447) As Long, C1(3) As Integer, C2(3) As Integer
  ' 
  Dim pic1 As sPOINT, pic2 As sPOINT
  ' 
  pic1.x = 8
  pic1.y = 192
  pic2.x = 517
  pic2.y = 192
  Dim h As Long, hD As Long, r As Long, i As Integer, j As Integer
  hD = GetDC(0)
  ' 
  For i = 0 To 497
    For j = 0 To 447
      p1(i, j) = GetPixel(hD, i + pic1.x, j + pic1.y)
      p2(i, j) = GetPixel(hD, i + pic2.x, j + pic2.y)
    Next
  Next
  ' , 
  Dim t As Boolean
  t = True
  For i = 0 To 497
    For j = 0 To 447
      Call ColorRGB(p1(i, j), C1())
      Call ColorRGB(p2(i, j), C2())
      If (Abs(C1(1) - C2(1)) > 30 Or Abs(C1(2) - C2(2)) > 30 Or Abs(C1(3) - C2(3)) > 30) Then
        t = Not t
        If t Then
          Picture1.ForeColor = &H0&
        Else
          Picture1.ForeColor = &HFF00&
        End If
      Else
        Picture1.ForeColor = p1(i, j)
      End If
      Picture1.PSet (i, j)
    Next
  Next
End Sub
Private Sub Picture1_Click()
Me.Visible = False
DoEvents
GetPoint
Me.Visible = True
End Sub

본 문서가 여러분의 VB 프로그래밍에 도움이 되기를 바랍니다.

좋은 웹페이지 즐겨찾기