Other need some math specialists...

ilan

Expert
Licensed User
i would like to make jump in a radial path...

i need to calculate the path for example my circle radius is 15% of the screenhight let say (80dip)

and i would like to move the ball from pos x to pos y (50% of the screen widht = 160dip)
and in 24 steps that means 180/24 = 7.5° and i need to get the left and top of the ball view

and add this to a list and then say in a timer ball.left = list1.get(i) and ball.top = list1.get(i2)

how do i calculate the path??

(i need the x/y of the yellow points)

balljump.png
 
Last edited:

derez

Expert
Licensed User
B4X:
dim a as float
For i = 0 To 24
    a = i * 7.5
    x = cx - R * CosD(a) - ball.width/2
    y = cy - R * SinD(a) - ball.height/2
    list1.add(x)
    list2.add(y)
Next
cx , cy - the center of circle, R - the radius.
 

ilan

Expert
Licensed User
thanx i solved it like this



B4X:
filljumplist(25%x, 24, "left") 'fill jumping lists jump to left
filljumplist(25%x, 24, "right") 'fill jumping lists jump to right

Sub filljumplist(radius As Int, steps As Double, direction As String)
jumprcalc.Clear

Dim jx As Float
Dim jy As Float
Dim angle As Float = 180/steps
jumpingdir = direction
jumpint = 0

For i = 0 To 24
    If direction = "right" Then
        jx = radius - (radius * CosD(angle*i))
    Else If direction = "left" Then
        jx = radius + (radius * CosD(angle*i))
    End If
jy = radius * SinD(angle*i)
jumprcalc.Add(jx & "|" & jy)
'Log(jx & "|" & jy)
Next

End Sub
 
Last edited:
Top