
-----------------------------------
asd
Thu Aug 30, 2007 11:42 pm

launching: determining angles
-----------------------------------
i'm making a game to kill time cause i'm grounded. I want to launch a ball using the mouse, but i dont know how to determine the angle in which the ball will be thrown. 
any help is appreciated.

here's what i got so far:

%Launching Program

View.Set ("offscreenonly")
setscreen ("nobuttonbar")

var x, y, button, x2, y2, power : int := 0
var dist, speed : real := 0
var lineX, lineY, lineX2, lineY2 : int

loop
    View.Update
    delay (50)
    cls
    drawline (0, 50, 650, 50, black)

    mousewhere (x, y, button)

    locate (1, 1)
    if button = 0 then
        power := 0
        put x : 4, "  ", y : 4, "  ", "Power: ", power : 4, "  button up"
        drawfilloval (x, y, 5, 5, blue)
        x2 := x
        y2 := y
    else

        drawoval (x2, y2, 50, 50, black)
        lineX := x2 - 50
        lineY := y2
        lineX2 := x2 + 50
        lineY2 := y2
        drawline (lineX, lineY, lineX2, lineY2, black)

        dist := sqrt ((x2 - x) ** 2 + (y2 - y) ** 2)

        if dist >= 50 - 5 then
            drawfilloval (x, y, 5, 5, blue)
            power := 50
        elsif dist 