var keys : array char of boolean %my variables and constants
var x, y, y2 := 25
var x2 := 125
var X, Y := 100
var y_velocity := 0
const gravity := 2
var bounce := 0
var try : string
setscreen ("graphics, offscreenonly")
procedure game
loop
Input.KeyDown (keys) %Line movements
if keys (KEY_RIGHT_ARROW) then
x2 += 15
x += 15
end if
if keys (KEY_LEFT_ARROW) then
x2 -= 15
x -= 15
end if
y_velocity -= gravity %Ball gravity effect
Y += y_velocity
if Y = 0 then % ball hitting 0
put "You got ", bounce, " bounces before you let the ball drop!" %Broken restart
put "Try again? (y, n)"
get try
if try = "y" then
game
else
exit
end if
end if
if Math.DistancePointLine (X,Y,x,y,x2,y2) < 15 then %Ball bounce
y_velocity := 35
x := x + 10
X := Rand.Int(1, 500)
bounce := bounce + 1
end if
drawline (x,y,x2,y2, black) %Objects and end loop
Draw.FillOval(X, Y, 15,15, brightgreen )
View.Update
delay (1)
cls
end loop
end game
game
|