steinc
Legacy Member
hallo,
ik probeer mijn eigen shooter te maken maar ik zit vast aan de baan die mijn kogel moet maken om het doelwit te raken.
Dit is wat ik al heb:
Dim shoot As Boolean = False
Dim value As Single
Dim x1, x2, y1, y2 As Single
Private Sub Form1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
BackgroundPicture.Size = New Size(Me.Width, Me.Height)
BackgroundPicture.Location = New Point(0, 0)
PictureBoxGun.Location = New Point(Me.Width / 2, Me.Height * (25 / 29))
End Sub
Private Sub BackgroundPicture_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BackgroundPicture.Click
shoot = True
x1 = Control.MousePosition.X
y1 = Control.MousePosition.Y
x2 = PictureBoxGun.Location.X
y2 = PictureBoxGun.Location.Y
End Sub
Private Sub BulletTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BulletTimer.Tick
If shoot = True Then
For Me.value = 1 To 10 Step 1
PictureBoxbullet.Location = New Point(10, ((y2 - y1 / x2 - x1) * (value - x1)) + y1)
If value = 10 Then
shoot = False
End If
Next
End If
End Sub
nu als ik dit run kom ik totaal niet uit wat ik wil namelijk dat de kogel dat aan de muis vliegt (of toch al in de richting). Wat is er fout?
ik probeer mijn eigen shooter te maken maar ik zit vast aan de baan die mijn kogel moet maken om het doelwit te raken.
Dit is wat ik al heb:
Dim shoot As Boolean = False
Dim value As Single
Dim x1, x2, y1, y2 As Single
Private Sub Form1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
BackgroundPicture.Size = New Size(Me.Width, Me.Height)
BackgroundPicture.Location = New Point(0, 0)
PictureBoxGun.Location = New Point(Me.Width / 2, Me.Height * (25 / 29))
End Sub
Private Sub BackgroundPicture_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BackgroundPicture.Click
shoot = True
x1 = Control.MousePosition.X
y1 = Control.MousePosition.Y
x2 = PictureBoxGun.Location.X
y2 = PictureBoxGun.Location.Y
End Sub
Private Sub BulletTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BulletTimer.Tick
If shoot = True Then
For Me.value = 1 To 10 Step 1
PictureBoxbullet.Location = New Point(10, ((y2 - y1 / x2 - x1) * (value - x1)) + y1)
If value = 10 Then
shoot = False
End If
Next
End If
End Sub
nu als ik dit run kom ik totaal niet uit wat ik wil namelijk dat de kogel dat aan de muis vliegt (of toch al in de richting). Wat is er fout?