setscreen ("graphics:800;600,offscreenonly")
%const detail := 10
var speed : int := 0
const startx := 0
const starty := 0
var shotx, shoty : real
var mx, my, mb : int
var deltax, deltay : real
var b : real
var ang : real
loop %main loop
shotx := startx
shoty := starty
loop %gives player initial angle
mousewhere (mx, my, mb)
b := Math.Distance (startx, starty, mx, my)
deltay := my - starty
deltax := mx - startx
ang := arcsind (deltay / b)
if mx < startx then
ang := 180 - ang
end if
locate (1, 1)
put "Angle is: ", ang
View.Update
exit when mb = 1
end loop
deltay := my - starty
deltax := mx - startx
b := Math.Distance (startx, starty, mx, my) %trig
ang := arcsind (deltay / b)
if mx < startx then
ang := 180 - ang
end if
loop
mousewhere (mx, my, mb) %detects when shot is initialed
exit when mb = 1
end loop
speed := 15
loop %tracks shots
shotx := shotx + (deltax / ((Math.Distance (startx, starty, mx, my)) / speed))
shoty := shoty + (deltay / ((Math.Distance (startx, starty, mx, my)) / speed))
drawfilloval (round (shotx), round (shoty), 10, 10, red)
View.Update
cls
put "Angle is: ", ang
locate (2, 1)
exit when shotx > 800 or shoty > 600
end loop
end loop
|