hi
i wrote a progrm for maze but my problem is that the keys dont work and i want to make my maze confusing. when i try for the keys it says variable has no valu so plzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz help me thanks ......and i made my program faster just for now ..and plzz crrect the mistake i did
my program is
Turing: |
% to set screen
setscreen ("graphics:600,500, position:center;center,nobuttonbar,offscreenonly")
%constants
const rows := 42
const columns := 42
const size := 15
% declare the variables
var bold, italic, underline : boolean
var maze, x, y, c : int
var font1, font2, font3, font4 : int
var text1, text2, text3 : string
var keys : array char of boolean
var counter : int := 0
var startime : int
var timeremaining : int
var timeLowRange : int := 5
var timeHighRange : int := 10
var travelled : array 0 .. columns + 1, 0 .. rows + 1 of boolean
var routes : int := 0
var direction : array 1 .. 4, 1 .. 2 of int % there are 4 possibilities and 2 different directions
var way : array 1 .. rows* columns, 1 .. columns* rows of boolean
var lines : int
var x1, y1, x2, y2 : int
% to initilize the random values
randint (x, 0, maxx)
randint (y, 0, maxy)
randint (c, 0, 255)
% sets the background colour as black
drawfillbox (0, 0, maxx, maxy, 7)
%assign the font type and the size, for "The Maze"
font1 := Font.New ("monotype corsiva:80")
assert font1 > 0
text1 := "The Maze"
Draw.Text (text1, 100, 250, font1, c )
% for text 2, " Please press enter to continue"
font2 := Font.New ("times new roman:15:Italic")
assert font2 > 0
text2 := "please press enter to continue "
Draw.Text (text2, 160, 190, font2, 40)
% animation for " The Maze"
for i : 1 .. 65
randint (c, 35, 51)
Draw.Text (text1, 100, 250, font1, c )
View.Update
delay (15)
end for
% for text 3, " Instructions"
font3 := Font.New ("monotype corsiva:55:Italic")
assert font3 > 0
text3 := " Instructions "
% lets the user use the keys
loop
counter := counter + 1
Input.KeyDown (keys )
if keys (KEY_ENTER ) then
cls
drawfillbox (0, 0, maxx, maxy, 7)
Draw.Text (text3, 150, 330, font3, 64)
end if
exit when (counter = 2)
View.Update
Input.Pause
end loop
% font and size for the instructions
font4 := Font.New ("times new roman:19")
assert font4 > 0
% draw text for the instructions
Draw.Text (" * This is a one player game ", 65, 250, font4, 40)
Draw.Text (" * You have to use the arrow keys to move", 65, 210, font4, 40)
Draw.Text (" * start where you see red circle and end at the blue ", 65, 180, font4, 40)
Draw.Text (" * You have to complete this game in 2 minutes ", 65, 140, font4, 40)
Draw.Text (" * Enjoy ", 65, 100, font4, 40)
% lets the user use the enter key
loop
Input.KeyDown (keys )
View.Update
if keys (KEY_ENTER ) then
cls
for k: 1.. 3
put " loading.. "..
delay(100)
end for
end if
cls
%draws outer walls
Draw.Box (15, 15, 45 * 13, 34 * 13, 7)
% draws the oval at the start
Draw.FillOval (575, 23, 5, 5, red)
% for the other end
Draw.FillOval (44 * 13, 33 * 13, 5, 5, blue)
startime := Time.Elapsed % for time
loop
%time at the top of the game
timeremaining := Time.Elapsed - startime
if timeremaining = 60 then
put " you have 1 minutes remaining "
end if
if timeremaining = 120 then
put " your time is up !!! "
end if
exit when timeremaining = 120
View.Update
locate (1, 1)
put "Time: ", startime / 1000 : 1 : 1, " seconds "
View.Set ("offscreenonly")
%exit when Time.Elapsed =300
% for the lines in the maze
Draw.Line (550, 420, 585, 420, black)
Draw.Line (550, 420, 585, 420, black)
Draw.Line (550, 420, 550, 300, black)
Draw.Line (440, 300, 550, 300, black)
Draw.Line (550, 220, 500, 220, black)
Draw.Line (100, 110, 374, 110, black)
Draw.Line (550, 100, 550, 300, black)
Draw.Line (450, 350, 450, 440, black)
Draw.Line (560, 320, 440, 320, black)
Draw.Line (440, 320, 440, 220, black)
Draw.Line (400, 360, 400, 260, black)
Draw.Line (500, 340, 500, 440, black)
Draw.Line (400, 260, 360, 260, black)
Draw.Line (350, 160, 440, 220, black)
Draw.Line (300, 360, 360, 260, black)
Draw.Line (300, 220, 360, 220, black)
Draw.Line (250, 160, 350, 160, black)
Draw.Line (250, 160, 250, 270, black)
Draw.Line (250, 270, 300, 270, black)
Draw.Line (450, 360, 360, 360, black)
Draw.Line (250, 350, 300, 270, black)
Draw.Line (300, 320, 340, 320, black)
Draw.Line (360, 360, 300, 360, black)
Draw.Line (40, 310, 210, 310, black)
Draw.Line (210, 310, 210, 270, black)
Draw.Line (210, 130, 210, 270, black)
Draw.Line (210, 130, 370, 130, black)
Draw.Line (480, 200, 370, 130, black)
Draw.Line (480, 280, 480, 200, black)
Draw.Line (480, 280, 510, 280, black)
Draw.Line (510, 210, 510, 280, black)
Draw.Line (510, 210, 640, 210, black)
Draw.Line (40, 310, 40, 230, black)
Draw.Line (15, 180, 80, 180, black)
Draw.Line (80, 180, 170, 180, black)
Draw.Line (80, 180, 80, 260, black)
Draw.Line (210, 260, 170, 260, black)
Draw.Line (170, 210, 170, 260, black)
Draw.Line (34, 130, 300, 130, black)
Draw.Line (300, 200, 300, 150, black)
Draw.Line (215, 359, 215, 440, black)
Draw.Line (120, 100, 120, 130, black)
Draw.Line (160, 15, 160, 90, black)
Draw.Line (200, 40, 200, 130, black)
Draw.Line (240, 15, 240, 90, black)
Draw.Line (280, 40, 280, 130, black)
Draw.Line (320, 15, 320, 90, black)
Draw.Line (360, 40, 360, 130, black)
Draw.Line (360, 40, 580, 40, black)
Draw.Line (580, 40, 580, 160, black)
Draw.Line (500, 160, 580, 160, black)
Draw.Line (500, 160, 420, 60, black)
Draw.Line (420, 100, 530, 80, black)
Draw.Line (510, 120, 540, 120, black)
Draw.Line (45, 345, 255, 345, black)
Draw.Line (100, 15, 100, 100, black)
Draw.Line (50, 35, 100, 35, black)
Draw.Line (150, 35, 100, 35, black)
Draw.Line (50, 100, 50, 15, black)
x:= 57
y:= 23
x2:= 5
y2:= 5
% to move the circle
Input.KeyDown (keys )
if keys (KEY_UP_ARROW) then
y1 := y1 + 1
y2 := y2 + 1
drawfilloval (x1, y1, x2, y2, 1)
elsif keys (KEY_DOWN_ARROW) then
y1 := y1 - 1
y2 := y2 - 1
drawfilloval (x1, y1, x2, y2, 1)
elsif keys (KEY_LEFT_ARROW) then
x1 := x1 - 1
x2 := x2 - 1
drawfilloval (x1, y1, x2, y2, 1)
elsif keys (KEY_RIGHT_ARROW) then
x1 := x1 + 1
x2 := x2 + 1
drawfilloval (x1, y1, x2, y2, 1)
end if
View.Update
Input.Pause
cls
end loop
end loop
|
Mod EDIT: Remember the syntax tags!! |