%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% TO DO:
% Import Game over sound
% Insert Timer
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
setscreen ("graphics:800;600")
setscreen ("offscreenonly")
setscreen ("nocursor")
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Declaration %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
type Box :
record
x1, x2, y1, y2 : int
end record
var box : array 1 .. 14 of Box
var px1, py1, px2, py2 : int
var fontmain, font2 : int
var chars : array char of boolean
var time1, time2 : int
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Setting of the variables for the map layout %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
box (1).x1 := 30
box (1).y1 := 0
box (1).x2 := 30
box (1).y2 := 250
box (2).x1 := 0
box (2).y1 := 0
box (2).x2 := 0
box (2).y2 := 280
box (3).x1 := 0
box (3).y1 := 280
box (3).x2 := 60
box (3).y2 := 280
box (4).x1 := 60
box (4).y1 := 280
box (4).x2 := 60
box (4).y2 := 150
box (5).x1 := 30
box (5).y1 := 120
box (5).x2 := 90
box (5).y2 := 120
box (6).x1 := 90
box (6).y1 := 120
box (6).x2 := 90
box (6).y2 := 250
box (7).x1 := 60
box (7).y1 := 280
box (7).x2 := 500
box (7).y2 := 280
box (8).x1 := 90
box (8).y1 := 250
box (8).x2 := 530
box (8).y2 := 250
box (9).x1 := 530
box (9).y1 := 250
box (9).x2 := 530
box (9).y2 := 500
box (10).x1 := 500
box (10).y1 := 280
box (10).x2 := 500
box (10).y2 := 470
box (11).x1 := 530
box (11).y1 := 500
box (11).x2 := 480
box (11).y2 := 500
box (12).x1 := 500
box (12).y1 := 470
box (12).x2 := 450
box (12).y2 := 470
box (13).x1 := 450
box (13).y1 := 470
box (13).x2 := 450
box (13).y2 := 600
box (14).x1 := 480
box (14).y1 := 500
box (14).x2 := 480
box (14).y2 := 600
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Main Menu %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
colorback (255)
fontmain := Font.New ("Comic Sans MS :22")
font2 := Font.New ("Comic Sans MS :13")
Font.Draw ("Welcome to Paul's Maze Game", 150, 400, fontmain, 14)
Font.Draw ("Use your arrow keys to move the box through the maze in the shortest time possible.", 0, 350, font2, 2)
Font.Draw ("Press any key twice to continue.", 300, 100, font2, 255)
Input.Pause
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Procedure %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure getKey
var ch : string (1)
getch (ch)
end getKey
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Starting Position of square %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
py1 := 4
px1 := 4
py2 := 24
px2 := 24
drawfillbox (px1, py1, px2, py2, 255)
getKey
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Background Music
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
process playstuff
loop
Music.PlayFile ("sounds/backgroundmusic.mp3")
end loop
end playstuff
fork playstuff
loop
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Timer
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
time1 := Time.Elapsed
time2 := Time.Elapsed - time1
color (14)
put time2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Level 1 Maze Layout %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
cls
drawfillbox (box (1).x1, box (1).y1, box (1).x2, box (1).y2, 1)
drawfillbox (box (2).x1, box (2).y1, box (2).x2, box (2).y2, 1)
drawfillbox (box (3).x1, box (3).y1, box (3).x2, box (3).y2, 1)
drawfillbox (box (4).x1, box (4).y1, box (4).x2, box (4).y2, 1)
drawfillbox (box (5).x1, box (5).y1, box (5).x2, box (5).y2, 1)
drawfillbox (box (6).x1, box (6).y1, box (6).x2, box (6).y2, 1)
drawfillbox (box (7).x1, box (7).y1, box (7).x2, box (7).y2, 1)
drawfillbox (box (8).x1, box (8).y1, box (8).x2, box (8).y2, 1)
drawfillbox (box (9).x1, box (9).y1, box (9).x2, box (9).y2, 1)
drawfillbox (box (10).x1, box (10).y1, box (10).x2, box (10).y2, 1)
drawfillbox (box (11).x1, box (11).y1, box (11).x2, box (11).y2, 1)
drawfillbox (box (12).x1, box (12).y1, box (12).x2, box (12).y2, 1)
drawfillbox (box (13).x1, box (13).y1, box (13).x2, box (13).y2, 1)
drawfillbox (box (14).x1, box (14).y1, box (14).x2, box (14).y2, 1)
Input.KeyDown (chars)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Level 1 Background %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
drawdot (400, 200, 3)
drawdot (401, 199, 3)
drawdot (402, 198, 3)
drawdot (403, 197, 3)
drawdot (404, 196, 3)
drawdot (405, 195, 3)
drawdot (406, 194, 3)
drawdot (406, 195, 3)
drawfilloval (250, 200, 5, 5, 2)
drawfilloval (270, 200, 5, 5, 2)
drawarc (260, 180, 20, 20, 180, 0, 4)
drawfillmapleleaf (80, 400, 130, 450, 4)
drawfillmapleleaf (300, 400, 350, 450, 4)
drawfillstar (300, 100, 350, 150, 14)
drawfillstar (400, 100, 480, 180, 14)
drawstar (200, 0, 300, 100, 14)
drawstar (600, 350, 700, 450, 8)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Game over check %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i : 1 .. upper (box)
if px2 >= box (i).x1 and px1 <= box (i).x2 and py2 >= box (i).y1 and py1 <= box (i).y2 then
put "GAME OVER"
var clown : int
clown := Pic.FileNew ("pics/clown.jpg")
Pic.Draw (clown, 0, -100, picCopy)
Pic.Free (clown)
delay (500)
Music.PlayFile ("sounds/scream1.mp3")
clown := Pic.FileNew ("pics/clown.jpg")
Pic.Draw (clown, 0, -100, picCopy)
Pic.Free (clown)
end if
end for
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Movement of the player's square %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if chars (KEY_UP_ARROW) then
py1 := py1 + 1
py2 := py2 + 1
drawfillbox (px1, py1, px2, py2, 1)
elsif chars (KEY_DOWN_ARROW) then
py1 := py1 - 1
py2 := py2 - 1
drawfillbox (px1, py1, px2, py2, 1)
elsif chars (KEY_LEFT_ARROW) then
px1 := px1 - 1
px2 := px2 - 1
drawfillbox (px1, py1, px2, py2, 1)
elsif chars (KEY_RIGHT_ARROW) then
px1 := px1 + 1
px2 := px2 + 1
drawfillbox (px1, py1, px2, py2, 1)
end if
View.Update
getKey
cls
end loop
|