i created this game wheni was bored:
Turing: |
var x, y, rad : int
var user_x, user_y, user_rad, user_col : int
var comp_x, comp_y, comp_rad, comp_col, comp_speed : int
var mouse_x, mouse_y, button : int
var level : int
var TIME : int
var done : boolean
var speed : int
var small_font : int := Font.New ("Serif:8")
var font_name : string := "Times New Roman:15"
var font : int := Font.New (font_name )
var font_size : int := strint (font_name (length (font_name ) - 1 .. length (font_name )))
procedure ResetGrid
x := 10
y := 10
end ResetGrid
procedure ResetGame
x := 10
y := 10
rad := 30
user_x := 30
user_y := 40
user_rad := 30
user_col := brightred
comp_x := 300
comp_y := 310
comp_rad := 30
comp_col := brightblue
comp_speed := 10
level := 1
TIME := 0
done := false
speed := 100
end ResetGame
procedure Refresh
Font.Draw ("SCORE: " + intstr (TIME ), 60, maxy - font_size, font, blue)
Font.Draw ("LEVEL: " + intstr (level ), 200, maxy - font_size, font, blue)
Font.Draw ("THE OBJECT IS TO AVOID", 370, 300, font, blue)
Font.Draw ("THE SQUARE", 370, 300 - font_size, font, blue)
Font.Draw ("BLUE", 410, 300 - font_size, font, brightblue)
Font.Draw ("USE THE ARROW KEYS TO", 370, 300 - font_size * 2, font, blue)
Font.Draw ("MOVE YOUR SQUARE", 370, 300 - font_size * 3, font, blue)
Font.Draw ("RED", 490, 300 - font_size * 3, font, brightred)
Font.Draw ("Increase", 385, 140, small_font, black)
Draw.Box (390, 100, 420, 130, black)
Draw.ThickLine (405, 100, 405, 130, 2, green)
Draw.ThickLine (390, 115, 420, 115, 2, green)
Font.Draw ("Decrease", 435, 140, small_font, black)
Draw.Box (440, 100, 470, 130, black)
Draw.ThickLine (440, 115, 470, 115, 2, brightblue)
Font.Draw ("Close", 491, 140, small_font, black)
Draw.Box (490, 100, 520, 130, black)
Draw.ThickLine (490, 100, 520, 130, 2, brightred)
Draw.ThickLine (520, 100, 490, 130, 2, brightred)
Font.Draw ("Reset", 542, 140, small_font, black)
Draw.Box (540, 100, 570, 130, black)
Draw.Oval (555, 115, 15, 15, black)
end Refresh
procedure End
Refresh
Input.Flush
Font.Draw (Sys.GetUserName + "'s Final Score is " + intstr (TIME ), 45, maxy - font_size * 2 - 10, font, brightred)
Font.Draw ("Press any key to continue...", 65, maxy - font_size * 3 - 10, font, black)
View.Update
delay (1000)
if not done then
ResetGame
end if
end End
ResetGame
var keys : array char of boolean
var window := Window.Open ("graphics;offscreenonly,nocursor")
loop
Input.KeyDown (keys )
Mouse.Where (mouse_x, mouse_y, button )
if keys (KEY_LEFT_ARROW) then
user_x - = user_rad
%comp_x += comp_rad
elsif keys (KEY_RIGHT_ARROW) then
user_x + = user_rad
%comp_x -= comp_rad
end if
if keys (KEY_UP_ARROW) then
user_y + = user_rad
%comp_y -= comp_rad
elsif keys (KEY_DOWN_ARROW) then
user_y - = user_rad
%comp_y += comp_rad
end if
if keys (KEY_ESC) then
exit
end if
if user_x < user_rad then
user_x + = user_rad
elsif user_x > user_rad * 10 then
user_x - = user_rad
end if
if user_y < user_rad then
user_y + = user_rad
elsif user_y > user_rad * 11 then
user_y - = user_rad
end if
if comp_x < comp_rad then
comp_x + = comp_rad
elsif comp_x > comp_rad * 10 then
comp_x - = comp_rad
end if
if comp_y < comp_rad then
comp_y + = comp_rad
elsif comp_y > comp_rad * 11 then
comp_y - = comp_rad
end if
delay (speed )
for i : 1 .. 100
x + = rad
if i mod 10 = 1 then
y + = rad
x := rad
end if
Draw.FillBox (user_x, user_y, user_x + user_rad, user_y + user_rad, user_col )
Draw.Box (user_x, user_y, user_x + user_rad, user_y + user_rad, black)
Draw.FillBox (comp_x, comp_y, comp_x + comp_rad, comp_y + comp_rad, comp_col )
Draw.Box (comp_x, comp_y, comp_x + comp_rad, comp_y + comp_rad, black)
Draw.Box (x, y, x + rad, y + rad, black)
end for
if Rand.Int (0, comp_speed ) = Rand.Int (0, comp_speed ) and comp_x > user_x then
comp_x - = comp_rad
elsif Rand.Int (0, comp_speed ) = Rand.Int (0, comp_speed ) and comp_x < user_x then
comp_x + = comp_rad
end if
if Rand.Int (0, comp_speed ) = Rand.Int (0, comp_speed ) and comp_y > user_y then
comp_y - = comp_rad
elsif Rand.Int (0, comp_speed ) = Rand.Int (0, comp_speed ) and comp_y < user_y then
comp_y + = comp_rad
end if
if whatdotcolour (comp_x + user_rad div 2, comp_y + user_rad div 2) = user_col
or whatdotcolour (user_x + comp_rad div 2, user_y + comp_rad div 2) = comp_col
then
End
end if
%%% Mouse buttons
if mouse_y > 100 and mouse_y < 130 and button = 1 then
if mouse_x > 390 and mouse_x < 420 then
TIME + = 30
level + = 1
elsif mouse_x > 440 and mouse_x < 470 then
elsif mouse_x > 490 and mouse_x < 520 then
done := true
elsif mouse_x > 540 and mouse_x < 570 then
ResetGame
end if
end if
TIME + = 1
Refresh
if TIME mod 30 = 0 then
if level < 10 then
comp_speed - = 1
end if
level + = 1
end if
if level = 10 then
comp_rad * = 2
comp_speed + = 5
level + = 1
end if
if level = 15 then
comp_speed - = 5
level + = 1
end if
if level = 20 then
comp_speed - = 5
level + = 1
end if
View.Update
cls
ResetGrid
exit when done
end loop
End
if done then
View.Update
Input.Pause
Window.Close (window )
end if
|
i attached mine sweeper which will be my final projet, I am still working on it |