mettre 4 label (caption = 0) 4 timer ( timer1 et 2 = 1 timer4=100 timer3=2700) et mettre 2 image (une picture et l'autre pict2)
timer1.enabled = false
Source / Exemple :
Private i
Option Explicit
Const cSoundBuffers = 10
'Le code qui suit est de Nix
Dim X(50), Y(50), Velocity(50), Size(50) As Integer
Private Sub Form_Activate()
Randomize
For i = 1 To 50
X(i) = Int(Me.Width * Rnd)
Y(i) = Int(Me.Height * Rnd)
Velocity(i) = Int(500 - (Int(Rnd * 499)))
Size(i) = 16 * Rnd
Next
End Sub
Private Sub Timer4_Timer()
For i = 1 To 50
Circle (X(i), Y(i)), Size(i), BackColor
Y(i) = Y(i) + Velocity(i)
If Y(i) >= SOUND.Height Then
Y(i) = 0
X(i) = Int(SOUND.Width * Rnd)
End If
Circle (X(i), Y(i)), Size(i), vbWhite
Next
End Sub
Private Sub Form_Keydown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyLeft Then pict2.Left = pict2.Left - 40
If KeyCode = vbKeyRight Then pict2.Left = pict2.Left + 40
If KeyCode = vbKeySpace Then espace
If (pict2.Top >= Image1.Top) And (pict2.Top <= (Image1.Top + Image1.Height)) Then
If (pict2.Left >= Image1.Left) And (pict2.Left <= (Image1.Left + Image1.Width)) Then
End If
End If
End Sub
Private Sub Form_Load()
Me.BackColor = 0
End Sub
Private Sub espace()
Label1.Caption = pict2.Top
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Dim dedans As Boolean
dedans = True
Label1.Caption = Label1.Caption - 90
pict2.Top = Label1.Caption
If (pointDedans(pict2.Top, pict2.Top + pict2.Height, pict2.Left, pict2.Left + pict2.Width, Image1.Left, Image1.Top)) = False Then
If (pointDedans(pict2.Top, pict2.Top + pict2.Height, pict2.Left, pict2.Left + pict2.Width, Image1.Left + Image1.Width, Image1.Top)) = False Then
If (pointDedans(pict2.Top, pict2.Top + pict2.Height, pict2.Left, pict2.Left + pict2.Width, Image1.Left, Image1.Top + Image1.Height)) = False Then
If (pointDedans(pict2.Top, pict2.Top + pict2.Height, pict2.Left, pict2.Left + pict2.Width, Image1.Left + Image1.Width, Image1.Top + Image1.Height)) = False Then
dedans = False
End If
End If
End If
End If
If dedans = True Then
Label4.Caption = Label4.Caption + 10
Image1.Left = Rnd * 3000
End If
If pict2.Top <= 0 Then
pict2.Top = 5520
Timer1.Enabled = False
End If
'bonus
If Label4.Caption = 100 Then
MsgBox "Bonus de 50 points", vbExclamation, "bonus"
Label4.Caption = Label4.Caption + 50
End If
If Label4.Caption = 200 Then
MsgBox "Bonus de 50 points", vbExclamation, "bonus"
Label4.Caption = Label4.Caption + 50
End If
If Label4.Caption = 300 Then
MsgBox "Bonus de 50 points", vbExclamation, "bonus"
Label4.Caption = Label4.Caption + 50
End If
If Label4.Caption = 400 Then
MsgBox "Bonus de 50 points", vbExclamation, "bonus"
Label4.Caption = Label4.Caption + 50
End If
If Label4.Caption >= 500 Then
MsgBox "Vous avez gagné", vbExclamation, "Gagné"
End If
End Sub
Private Sub Timer2_Timer()
Label1.Caption = pict2.Top
Label2.Caption = pict2.Left
Label3.Caption = Image1.Left
End Sub
Private Function pointDedans(Base, Hauteur, Gauche, Droite, X, Y) As Boolean
pointDedans = False
If (X >= Gauche) And (X <= Droite) Then
If (Y >= Base) And (Y <= Hauteur) Then
pointDedans = True
End If
End If
End Function
Private Sub Timer3_Timer()
Image1.Left = Rnd * 3000
End Sub
Conclusion :
plus simple
http://perso.wanadoo.fr/steyer.ad/download/setup.exe
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.