type projectile :
record
x, y : real
vx, vy : real
angle : real
end record
var ball : projectile
var goal : int
proc INIT (var p : projectile)
p.x := 10
p.y := 10
p.vx := 0
p.vy := 0
goal := Rand.Int (maxx div 3, maxx - 40)
end INIT
loop
INIT (ball)
Draw.Line (goal - 50, 5, goal + 50, 5, brightred)
put "Enter power, then angle\n(ex.5 45)"
get ball.vx, ball.angle
cls
ball.vy += sind (ball.angle) * ball.vx
loop
exit when ball.y < 0
ball.y += ball.vy
ball.vy -= .1
ball.x += ball.vx
Draw.Oval (round (ball.x), round (ball.y), 2, 2, black)
Draw.Line (goal - 50, 5, goal + 50, 5, brightred)
end loop
if ball.x > goal - 50 and ball.x < goal + 50 then
put "Well Done"
else
put "Sorry Missed"
end if
Input.Pause
end loop
|