Miren,
De momento he echo esto, el pacman se para cuando llega a una parte negra, el problema esta en k si la parte negra esta por arriba el pacman se para, pero si kuando esta parado kiero tirar hacia la izquierda o derecha el pacman se me va parando, otra cosa es k si tngo una parte negra por debajo,el pacman no se para hasta k no llega a la parte superior de la imagen. Weno pos estos son mis problems, si puede ser les agradeceria mucho su ayuda.
Cita: Dim k As Variant
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
Public Sub picture1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDown Then
tmrtimer.Enabled = False
Call moure
k = 0
End If
If KeyCode = vbKeyRight Then
tmrtimer.Enabled = False
Call moure
k = 1
End If
If KeyCode = vbKeyUp Then
tmrtimer.Enabled = False
Call moure
k = 2
End If
If KeyCode = vbKeyLeft Then
tmrtimer.Enabled = False
Call moure
k = 3
End If
End Sub
Private Sub tmrtimer_Timer()
Select Case k
Case 0:
picpac.Top = (picpac.Top + 1)
Call black
If tmrtimer.Enabled = False Then
tmrtimer.Enabled = True
End If
Call black
Case 1:
picpac.Left = (picpac.Left + 1)
Call black
If tmrtimer.Enabled = False Then
tmrtimer.Enabled = True
End If
Call black
Case 2:
picpac.Top = (picpac.Top - 1)
Call black
Case 3:
picpac.Left = (picpac.Left - 1)
Call black
End Select
End Sub
Function moure()
tmrtimer.Enabled = True
End Function
Function black()
Dim XX As Long, YY As Long, A As Long
XX = picpac.Left - 1
YY = picpac.Top - 1
If vbBlack = GetPixel(Picture1.hdc, XX, YY) Then
tmrtimer.Enabled = False
End If
End Function
Copien este codigo y creen una picturebox que se llame "picture1".En picture cargan una imagen con una parte negra i otra de otro color.
Creen una Image dentro del picture que se llame "picpac", procurenle ponerla en la parte que no esta negra del picture1.
Creen un timer i nombrenlo "tmrtimer" ponganle en las opciones enabled FALSE y interval 1.
Asi podran ver lo k tngo exo. Por favor ayudenme k estoy estancado.
Gracias a todos.;)