Hi all,
I want to move a ball(ovalshape) at various angles.
I made a simple program to test the movement and angle, but I can not get it right.
If the number of possible angles(N) is low then the ball is moving fine.
if the number of possible angles(N) high then the ball is moving too coarse.
I know it is because of the way i calculate, but I dont know enough about maths. I dont want to use vectors, trigonometry is ok.
On a windowsform I have a trackbar (0 - 360), a lineshape (barrel rotating 360 degrees shooting the ball)
I use the folowing code for the barrel:
This is the code for the movement (in a timer):
I know the x an y values of a point should be integers, but that is part of the broblem.
I hope someone can help
thanks,
Groover
I want to move a ball(ovalshape) at various angles.
I made a simple program to test the movement and angle, but I can not get it right.
If the number of possible angles(N) is low then the ball is moving fine.
if the number of possible angles(N) high then the ball is moving too coarse.
I know it is because of the way i calculate, but I dont know enough about maths. I dont want to use vectors, trigonometry is ok.
On a windowsform I have a trackbar (0 - 360), a lineshape (barrel rotating 360 degrees shooting the ball)
I use the folowing code for the barrel:
VB.NET:
Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
trackbarangle = TrackBar1.Value
TextBox1.Text = trackbarangle.ToString
barrel.X1 = barrel.X2 - Math.Cos(trackbarangle * (pi / 180)) * 100
barrel.Y1 = barrel.Y2 - Math.Sin(trackbarangle * (pi / 180)) * 100
End Sub
This is the code for the movement (in a timer):
VB.NET:
Public Sub initiate()
Dim n as integer
If start = False Then ball.Location = New Point(barrel.X1 - ball.Width / 2, barrel.Y1 - ball.Width / 2)
ball.Location = New Point(ball.Location.X - (n * (Math.Cos(trackbarangle * (pi / 180)))), _
(ball.Location.Y - (n * (Math.Sin(trackbarangle * (pi / 180))))))
start = True
End Sub
I know the x an y values of a point should be integers, but that is part of the broblem.
I hope someone can help
thanks,
Groover