% Sets the Screen
View.Set ("graphics:640;480,nobuttonbar,offscreenonly")
% Declaration of Variables,
var x, y, xRadius, yRadius, initialAngle, finalAngle : int := 0 % Values for Trajectory
var xAngle, yAngle : int := 0 % Line values
var windspeed, Power : int := 0 % Windspeed and power Values
var MoveArrow : array char of boolean % Value for when a key has been pressed
var Adjust : int
% Declaration of Procedures,
forward procedure Main
forward procedure Trajectory
forward procedure MoveTurret
% Variable Values,
xAngle := maxx - 20
yAngle := 20
% This is the arc distance that needs to be maintain while the
% Line moves up and down,
var Distance : int := Math.Distance (maxx, 0, yAngle,xAngle)
% This is the main procedure which controls the whole program,
% Main Program,
body procedure Main
% Main loop
loop
% Slows the program down so you have more control over were you palce the turret
delay (50)
% Gets Movemnet from turret
MoveTurret
View.Update
cls
end loop
end Main
body procedure Trajectory
% Draws the trajectory line
drawarc (x, y, xRadius, yRadius, initialAngle, finalAngle, black)
end Trajectory
body procedure MoveTurret
% Draws the Turret
drawfilloval (maxx, 0, 20, 20, 7)
drawline (maxx, 0, xAngle, yAngle, black)
% Checks if Up,Down or Enter was pressed
Input.KeyDown (MoveArrow)
% What happens when Up key is pressed
if MoveArrow (KEY_UP_ARROW) then
% If the line is at a 90 then stop it
if xAngle >= 0 and yAngle >= 40 then
xAngle := xAngle
yAngle := yAngle
% Otherwise continue
else
xAngle := xAngle + +1
yAngle := yAngle - -1
% This is for making the line move along a arc pattern
if Math.Distance (maxx, 0, xAngle, yAngle) >= Distance then
Adjust := Math.Distance (maxx, 0, xAngle, yAngle) - Distance
yAngle := yAngle - Adjust
else
end if
end if
% What happens when Down key is pressed
elsif MoveArrow (KEY_DOWN_ARROW) then
% If line is at 180 then stop it
if xAngle <= maxx and yAngle <= 0 then
xAngle := xAngle
yAngle := yAngle
% Otherwise continue
else
xAngle := xAngle + -1
yAngle := yAngle - +1
% This is for making the line move along a arc pattern
if Math.Distance (maxx, 0, xAngle, yAngle) >= Distance then
else
end if
end if
% What happens if Enter key is pressed
elsif MoveArrow (KEY_ENTER) then
Trajectory
end if
end MoveTurret
Main
|