procedure ovalgame
View.Set ("offscreenonly")
%All of the variables and such
var reply : string
var x, y, b : int := -1
var c : int := 0
var dx : int
var dy:int
var minimisscount : int := 0
var minimiss : string
var miniscorecount : int := 0
var miniscore : string
var miniwaveharder : int := 1
var miniwavenumber : int := 1
var fontmini : int
var whatway : int
fontmini := Font.New ("Times New Roman:10:Bold")
loop
%Resets the variables for the game
minimisscount := 0
miniscorecount := 0
miniwaveharder := 1
miniwavenumber := 1
fontmini := Font.New ("Times New Roman:10:Bold")
%the mian loop of the game
loop
%randomly choses the direction of which the oval falls
randint (whatway, 1, 4)
%down
if whatway = 1 then
randint (dx, 1, 600)
dy := 380
%right
elsif whatway = 2 then
randint (dy, 1, 380)
dx := 10
%left
elsif whatway = 3 then
randint (dy, 1, 380)
dx := 600
%up
elsif whatway = 4 then
randint (dx, 1, 600)
dy := 10
end if
%Inner loop
loop
delay (50)
%draws the score and misses and the oval
miniscore := intstr (miniscorecount)
minimiss := intstr (minimisscount)
drawfillbox (0, 0, maxx, maxy, white)
Font.Draw ("Hits", 8, 380, fontmini, brightred)
Font.Draw (miniscore, 50, 380, fontmini, brightred)
Font.Draw ("Misses", 8, 370, fontmini, brightred)
Font.Draw (minimiss, 50, 370, fontmini, brightred)
drawfilloval (dx, dy, 10, 10, blue)
View.Update
%moves the oval about
if whatway = 1 then
dy := dy - (2 + miniwaveharder)
elsif whatway = 2 then
dx := dx + (2 + miniwaveharder)
elsif whatway = 3 then
dx := dx - (2 + miniwaveharder)
elsif whatway = 4 then
dy := dy + (2 + miniwaveharder)
end if
%tells if the mouse is on one of the blue ovals
%with the almighty whatdotcolour
mousewhere (x, y, b)
if whatdotcolor (x, y) = blue then
sound (500, 10)
Font.Draw ("Hit", dx + 10, dy + 20, fontmini, brightred)
View.Update
miniscorecount := miniscorecount + 1
miniwaveharder := miniwaveharder + 1
%-----------------------------------------%
%the oval leaves the screen
elsif dy < 0 or dx < 0 or dy > 380 or dx > 600 then
Font.Draw ("Miss", dx + 10, dy + 20, fontmini, brightred)
View.Update
minimisscount := minimisscount + 1
miniwaveharder := miniwaveharder + 1
end if
exit when dy < 0 or dx < 0 or dy > 380 or dx > 600 or whatdotcolor (x, y) = blue
end loop
exit when minimisscount = 10
end loop
%a synopsis of the gameplay
fontmini := Font.New ("Times New Roman:30:Bold")
drawfillbox (0, 0, maxx, maxy, white)
Font.Draw ("You scored", 100, 200, fontmini, brightred)
Font.Draw (miniscore, 300, 200, fontmini, brightred)
Font.Draw ("hits", 375, 200, fontmini, brightred)
Font.Draw ("Replay?", 300, 100, fontmini, brightred)
View.Update
get reply
exit when reply not= "y"
end loop
cls
Font.Draw ("Thanks for playing! :)", 100, 200, fontmini, brightred)
View.Update
end ovalgame
ovalgame |