var x, y, x2, y2, a, b, rx, ry, bcheck, score, xmouse, ymouse, button, count : int := 10
var timer, hper : real := 0.005
var shots : int := 0
setscreen ("graphics,offscreenonly")
count := 0
score := 0
procedure initialize
if count = 100 then
count := 0
end if
drawbox (9, 9, 631, 391, black)
mousewhere (xmouse, ymouse, button)
drawoval (xmouse, ymouse, 30, 30, black)
drawline (xmouse - 30, ymouse, xmouse + 30, ymouse, black)
drawline (xmouse, ymouse - 30, xmouse, ymouse + 30, black)
end initialize
procedure ifs
if button = 1 and bcheck = 1 then
shots := shots + 1
end if
if button = 0 then
bcheck := 1
elsif button = 1 then
bcheck := 0
end if
if ymouse >= y - 30 and xmouse >= x - 30 and ymouse <= y2 + 30 and xmouse <= x2 + 30 and count = 0 then
a := a * -1
b := b * -1
end if
if ymouse >= y - 30 and xmouse >= x - 30 and ymouse <= y2 + 30 and xmouse <= x2 + 30 then
count := count + 1
elsif ymouse <= y - 30 or xmouse <= x - 30 or ymouse >= y2 + 30 or xmouse >= x2 + 30 then
count := 0
end if
if button = 1 and ymouse <= y2 and ymouse >= y and xmouse <= x2 and xmouse >= x then
randint (x, 9, 606)
randint (y, 9, 366)
score := score + 1
end if
end ifs
procedure drawstuff
x2 := x + 25
y2 := y + 25
drawbox (x, y, x2, y2, black)
if x = 10 then
a := 1
elsif x2 = 630 then
a := -1
end if
if y = 10 then
b := 1
elsif y2 = 390 then
b := -1
end if
timer := timer + .005
locate (3, 3)
put "Time: ", timer : 0 : 2 ..
locate (2, 3)
put "Score: ", score ..
locate (4, 3)
put "Shots Taken: ", shots ..
if shots >= 1 then
hper := score / shots * 100
locate (5, 3)
put "Hit Percentage: ", hper : 0 : 2, "%" ..
else
locate (5, 3)
put "Hit Percentage: 0.00%" ..
end if
end drawstuff
procedure newpoints
x := x + a
y := y + b
randint (rx, 1, 200)
if rx = 5 then
a := a * -1
randint (ry, 1, 200)
end if
if ry = 5 then
b := b * -1
end if
end newpoints
for i : 1 .. 10
loop
cls
delay (5)
locate (2, 20)
put "Level ", i
locate (3, 20)
put "Get a score of ", i * 5, " in ", i * 20, " seconds or less"
initialize
ifs
drawstuff
newpoints
View.Update
exit when score = i * 5 or timer > i * 20
end loop
if timer >= i * 20 then
locate (15, 15)
put "GAME OVER"
exit
end if
score := 0
timer := 0
end for
|