esitccachan
Messages postés4Date d'inscriptionmercredi 4 mai 2011StatutMembreDernière intervention 9 mai 2011
-
4 mai 2011 à 09:38
esitccachan
Messages postés4Date d'inscriptionmercredi 4 mai 2011StatutMembreDernière intervention 9 mai 2011
-
9 mai 2011 à 10:46
Bonjours à tous,
J'ai un projet à faire sur excel avec Visual Basic. J'ai décidé de faire un jeu de dame mais je me retrouve dès le début bloqué. J'ai crée un objet que je n'arrive pas à déplacer où je le souhaite avec la souris, en fait il fuit la souris. Pouvez-vous m'aider svp?
Merci d'avance
Private Sub noir1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
noir1.Top = (X / 2 - centrex)
noir1.Left = (Y / 2 - centrey)
End Sub
jordane45
Messages postés38091Date d'inscriptionmercredi 22 octobre 2003StatutModérateurDernière intervention23 mars 2024344 4 mai 2011 à 18:33
Bonjour,
J'ai commencé un petit projet qui utilise le drag&Drop.
( déplacer des objets à la souris, gérer les collisions avec d'autres, ne pas sortir des limites du "terrain"..)
esitccachan
Messages postés4Date d'inscriptionmercredi 4 mai 2011StatutMembreDernière intervention 9 mai 2011 9 mai 2011 à 10:44
J'ai maintenant un autre problème, je n'arrive pas à transformer un pion en dame et je n'arrive pas non plus à manger un pion. J'ai néanmoins réussi à faire bouger les pions et à délimiter mon damier.
esitccachan
Messages postés4Date d'inscriptionmercredi 4 mai 2011StatutMembreDernière intervention 9 mai 2011 9 mai 2011 à 10:46
Je vous mets aussi mon codage pour que vous pouviez voir ce que j'ai fait.
François
Private Sub blanc1_Click()
Set pieceselectionnee = blanc1
Set celluleobject = pieceselectionnee.TopLeftCell
End Sub
Private Sub noir1_Click()
Set pieceselectionnee = noir1
Set celluleobject = pieceselectionnee.TopLeftCell
End Sub
Private Sub noir2_Click()
Set pieceselectionnee = noir2
Set celluleobject = pieceselectionnee.TopLeftCell
End Sub
Private Sub noir3_Click()
Set pieceselectionnee = noir3
Set celluleobject = pieceselectionnee.TopLeftCell
End Sub
Private Sub noir4_Click()
Set pieceselectionnee = noir4
Set celluleobject = pieceselectionnee.TopLeftCell
End Sub
Private Sub noir5_Click()
Set pieceselectionnee = noir5
Set celluleobject = pieceselectionnee.TopLeftCell
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim deplacement As Integer
If pieceselectionnee Is Nothing Then Exit Sub
If Not dansdamier() Then
MsgBox "sorti du damier"
Exit Sub
End If
If Left(pieceselectionnee.Name, 4) = "noir" Then
deplacement = 1
Else
deplacement = -1
End If
If Target.Address celluleobject.Offset(deplacement, -1).Address Or Target.Address celluleobject.Offset(deplacement, 1).Address Then
pieceselectionnee.Top = Target.Top
pieceselectionnee.Left = Target.Left
pieceselectionnee.Height = Target.Height
pieceselectionnee.Width = Target.Width
Else
MsgBox " ce n'est pas la bonne case"
End If
End Sub