123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
--------------------------------------------------------------------------------

Excellent Rat in a Maze Program.

--------------------------------------------------------------------------------



Program Mazefinal;
uses crt;

type str= string[1];
mazear= array[1..20, 1..60] of char;

var x, y, col, row, count: integer;
maze: mazear;
pick, again, choice, movement: char;



Procedure opening; {opening screen and title}

begin
textcolor(10);
writeln;
writeln(' 浜様様様様様様様様様様様様様様様様様様様様様様様様様様様 ');
writeln(' ');
writeln(' 栩 栩 栩栩栩栩栩 栩栩栩栩栩 栩栩栩栩栩 ');
writeln(' 栩 栩 栩 栩 栩 栩 ');
writeln(' 栩栩 栩栩 栩 栩 栩 栩 ');
writeln(' 栩 栩 栩 栩 栩 栩 栩 栩 ');
writeln(' 栩 栩栩 栩 栩栩栩栩栩 栩 栩栩栩栩 ');
writeln(' 栩 栩 栩 栩 栩 栩 栩 ');
writeln(' 栩 栩 栩 栩 栩 栩 ');
writeln(' 栩 栩 栩 栩 栩栩栩栩栩 栩栩栩栩栩 ');
writeln(' ');
writeln(' 栩 栩 栩栩栩栩栩 栩 栩 ');
writeln(' 栩 栩 栩 栩 栩 栩 ');
writeln(' 栩栩 栩栩 栩 栩 栩栩 栩 ');
writeln(' 栩 栩 栩 栩 栩 栩 栩 栩 栩 ');
writeln(' 栩 栩栩 栩 栩栩栩栩栩 栩 栩 栩 ');
writeln(' 栩 栩 栩 栩 栩 栩 栩栩 ');
writeln(' 栩 栩 栩 栩 栩 栩 ');
writeln(' 栩 栩 栩 栩 栩 栩 ');
writeln(' ');
writeln(' 藩様様様様様様様様様様様様様様様様様様様様様様様様様様様 ');
writeln;
textbackground(black);
gotoxy(10,23);
textcolor(15);
writeln(' Program FREE for Distribution');
gotoxy(10,24);
writeln(' For Educational Purposes ');

gotoxy(40,24);
textcolor(10+blink);
write(' Press enter to begin. ');
readln;
textcolor(white);

end;


Procedure Opening2(var choice: char);

Procedure Right(var choice:char);

Function Valid(var choice: char): boolean;
begin
valid:=false;
case choice of
'1': valid:=true;
'2': valid:=true;
'3': valid:=true;
'4': valid:=true;
'5': valid:=true;
'6': valid:=true;
end;{case}
end;

begin
while not valid(choice) do
begin
gotoxy(8,19);
write(' ');
gotoxy(8,19);
write('Please enter a valid menu option: ');
readln(choice);
end;
end;

begin
clrscr;
gotoxy(8,2);
writeln('Directions: Move the man in the maze using the keypad.');
gotoxy(8,3);
writeln(' 2:down, 8:up, 4:left, 6:right');
gotoxy(8,8);
textcolor(lightmagenta);
writeln('Mazes,(1-5): ');
writeln;
gotoxy(8,10);
textcolor(lightgreen);
writeln('1) Easiest ');
gotoxy(8,11);
writeln('2) Easy ');
gotoxy(8,12);
writeln('3) Medium ');
gotoxy(8,13);
writeln('4) Hard ');
gotoxy(8,14);
writeln('5) Hardest ');
gotoxy(8,15);
writeln('6) Impossible ');
gotoxy(8,18);
textcolor(white);
write('Enter the number of the maze you would like to play: ');
readln(choice);
Right(choice);
end;


Procedure sixlaby(var maze: mazear; var col, row: integer);
var dfile: text;

begin

row := 0;

assign(dfile, 'f:projectsmazemaze6.txt');
reset(dfile);
while not eof(dfile) do
begin
row := row + 1;
col := 0;
while not eoln(dfile) do
begin
col := col + 1;
read(dfile, maze[row, col]);
end;{x}
readln(dfile);
end;
close(dfile);
end;{procedure}


Procedure fivelaby(var maze: mazear; var col, row: integer);
var dfile: text;

begin

row := 0;

assign(dfile, 'f:projectsmazemaze5.txt');
reset(dfile);
while not eof(dfile) do
begin
row := row + 1;
col := 0;
while not eoln(dfile) do
begin
col := col + 1;
read(dfile, maze[row, col]);
end;{x}
readln(dfile);
end;
close(dfile);
end;{procedure}



Procedure fourlaby(var maze: mazear; var col, row: integer);

var dfile: text;

begin
row:=0;
assign(dfile, 'f:projectsmazemaze4.txt');
reset(dfile);
while not eof(dfile) do
begin
row:=row+1;
col:=0;
while not eoln(dfile) do
begin
col:=col+1;
read(dfile, maze[row, col]);
end;{y}
readln(dfile);
end;{x}
close(dfile);
end;{procedure}


Procedure threelaby(var maze: mazear; var col, row: integer);

var dfile: text;

begin
row:=0;
assign(dfile, 'f:projectsmazemaze3.txt');
reset(dfile);
while not eof(dfile) do
begin
row:=row+1;
col:=0;
while not eoln(dfile) do
begin
col:=col+1;
read(dfile, maze[row, col]);
end;{y}
readln(dfile);
write(row,col);
end;{x}
close(dfile);
end;{procedure}

Procedure twolaby(var maze: mazear; var col, row: integer);

var dfile: text;

begin
row:=0;
assign(dfile, 'f:projectsmazemaze2.txt');
reset(dfile);
while not eof(dfile) do
begin
row:=row+1;
col:=0;
while not eoln(dfile) do
begin
col:=col+1;
read(dfile, maze[row, col]);
end;{y}
readln(dfile);
end;{x}
close(dfile);
end;{procedure}


Procedure onelaby(var maze: mazear; var col, row: integer);
var dfile: text;

begin

row := 0;

assign(dfile, 'f:projectsmazemaze1.txt');
reset(dfile);
while not eof(dfile) do
begin
row := row + 1;
col := 0;
while not eoln(dfile) do
begin
col := col + 1;
read(dfile, maze[row, col]);
end;{x}
readln(dfile);
end;
close(dfile);
end;{procedure}

Procedure display(var maze:mazear; col, row: integer);
var x,y: integer;

begin
writeln;
textcolor(yellow);
for x:=1 to row do
begin
write(' ');
for y:=1 to col do
begin
write(maze[x,y]);
end;{y}
writeln;
end;{x}
end;{procedure}

Procedure start(var maze: mazear; col, row: integer);

begin
gotoxy(col+5,row);
textcolor(11);
write(' ');
textcolor(white);
end;{procedure}

Procedure Moveman2(var maze: mazear; var row, col, x, y: integer;
var movement: char);

Function checkmove(var movement: char): boolean;
begin
checkmove:=false;
case movement of
'2': checkmove:= true;
'4': checkmove:= true;
'6': checkmove:= true;
'8': checkmove:= true;
's': checkmove:= true;
end;{case}
end;

Procedure GetMove(var movement: char);

begin
gotoxy(1,22);
write(' ');
gotoxy(1,22);
write('Use the key pad to move! (Press "s" to stop at anytime.)');
movement:=readkey;
while not checkmove(movement) do
begin
gotoxy(1,22);
write(' ');
gotoxy(1,22);
write('Invalid Move! Please try again.');
movement:=readkey;
end;
end;

begin
getmove(movement);
end;


Function hit(var maze: mazear; var x,y: integer; var movement: char): boolean;
var x1, y1: integer;
begin
x1:=x;
y1:=y;

case movement of
'2': y1:=y1+1;
'4': x1:=x1-1;
'6': x1:=x1+1;
'8': y1:=y1-1;
end;{case}

hit:= false;

{case maze[y1-1, x1-7] of
'*': hit:= true;
'|': hit:= true;
'_': hit:= true;
'-': hit:= true;
'': hit:= true;
'': hit:= true;
'': hit:= true;
'': hit:= true;
'': hit:= true;
'': hit:= true;
end; {case}
if maze[y1-1, x1-7] <> ' ' then
if maze[y1-1, x1-7]<> 'F' then
if maze[y1-1, x1-7]<> 'S' then
hit:=true;

end;


Procedure Move(var movement:char; var x, y: integer);
begin

gotoxy(x,y);
write(' ');

case movement of
'2': y:=y+1;
'4': x:=x-1;
'6': x:=x+1;
'8': y:=y-1;
end;{case}

gotoxy(x,y);
textcolor(11);
write(' ');
textcolor(white);
end;


Function KickOut(var maze: mazear; var x,y: integer; var movement: char): boolean;
begin
kickout:=false;
if maze[y-1,x-7]= 'F' then kickout:= true;
if movement= 's' then kickout:= true;
end;


Procedure credit(var again: char);

Function valid_ans(var again: char): boolean;
begin
valid_ans:=false;
case again of
'y': valid_ans:=true;
'n': valid_ans:=true;
end;{case}
end;


begin
clrscr;
writeln;
textcolor(10);
writeln('This program was written and designed by: ');
textcolor(15);
writeln(' Faraz Younus Bandukda');
writeln(' Farazoftine SOftware Products');
writeln;
textcolor(11);
writeln('A Quality Game By Farazoftine Software Products');
writeln;
textcolor(15);
writeln('Year: 2001 ');
writeln;
writeln('Designed using Turbo Pascal 7.0');
writeln;
textcolor(12);
writeln('Solve the mazes............. if you can !');
writeln;
writeln;
writeln;
writeln;
writeln;
writeln;
writeln('Peace to all and for all.');
textcolor(13);
writeln;
writeln(' THANX FOR PLAYING MAZE MAN! ');
writeln(' Press "y" followed by ENTER to go back to ');
write (' the starting screen, "n" to exit. ');
textcolor(15);
gotoxy(60,23);
write('Choice: ');
readln(again);
while not valid_ans(again) do
begin
repeat
gotoxy(10,24);
write(' ');
gotoxy(10,24);
write('Please type a valid choice. ');
readln(again);
until valid_ans(again);
end;
end;


Procedure Win(var count: integer);


begin
clrscr;
textcolor(12+blink);
gotoxy(1,5);
writeln(' 栩 栩 栩栩栩 栩 栩 栩 栩 栩栩栩栩 栩栩栩栩');
writeln(' 栩 栩 栩 栩 栩 栩 栩 栩 栩 栩');
writeln(' 栩 栩 栩 栩栩 栩 栩栩 栩 栩 栩 栩');
writeln(' 栩 栩 栩 栩 栩 栩 栩 栩 栩 栩 栩 栩');
writeln(' 栩 栩 栩 栩 栩 栩 栩 栩 栩 栩 栩 栩');
writeln(' 栩 栩 栩 栩 栩 栩 栩 栩 栩 栩 栩栩栩栩');
writeln(' 栩 栩 栩 栩 栩 栩 栩 栩 栩 栩栩栩 栩栩 ');
writeln(' 栩 栩 栩 栩 栩 栩 栩 栩 栩 栩 栩 栩 栩 ');
writeln(' 栩 栩 栩 栩 栩 栩 栩 栩 栩 栩 栩 栩 栩 ');
writeln(' 栩 栩 栩 栩 栩 栩 栩 栩 栩 栩 栩 栩 栩');
writeln(' 栩 栩 栩 栩 栩栩 栩 栩栩 栩 栩 栩');
writeln(' 栩 栩 栩 栩 栩 栩 栩 栩 栩 栩');
writeln(' 栩 栩 栩栩栩 栩 栩 栩 栩 栩栩栩栩 栩 栩');
gotoxy(2,22);
textcolor(white);
writeln(' You succesfully completed the maze in ', count, ' moves!');
gotoxy(2,23);
write (' Please press enter to view the credits.');
readln;

end;




begin {main}
clrscr;
opening;
again:='y';
while again='y' do
begin
clrscr;
opening2(choice); {pick choice screen}
case choice of {case statement}
'1': onelaby(maze, col, row); {read 1st maze from text}
'2': twolaby(maze, col, row); {read 2nd maze from text}
'3': threelaby(maze, col, row); {read 3rd maze from text}
'4': fourlaby(maze, col, row); {read 4th maze from text}
'5': fivelaby(maze, col, row); {read 5th maze from text}
'6': sixlaby(maze,col,row);
end;

clrscr;
display(maze, col, row); {displays characters from text}
start(maze,col,row); {where we start the man}
y:=row;
x:=col+5;
count:=0;
repeat {repeat loop when moving}
moveman2(maze,row,col, x, y, movement); {how to move man}
while hit(maze,x,y, movement) do {what happens when you hit a wall}
begin
moveman2(maze,row,col, x, y, movement);
end;
move(movement, x, y);
count:=count+1;
until kickout(maze, x, y, movement); {end maze when ever you want}

if maze[y-1,x-7]= 'F' then
begin
win(count); {when "f" then end and win}
end;

credit(again); {credits page}
end;

end.




--------------------------------------------------------------------------
Sample Maze Pattern - 1
--------------------------------------------------------------------------

浜様冤様冤様様様様様様様様様様様様様様様様様様様様様様様
F 敖陳陳陳陳陳陳陳陳陳陳陳陳陳陳陳陳陳陳

敖陳陳陳陳陳 陳陳陳陳陳朕

敖陳陳陳陳陳陳陳陳陳

敖* VYOMW *朕

青陳陳陳

敖陳陳陳陳陳
青陳陳
敖陳陳陳陳陳
青陳 陳陳陳
敖陳陳陳陳陳陳
青陳陳陳陳陳陳陳
S
藩様様様様様様様様様様様詫様様様詫様様様様様様様様様様様


--------------------------------------------------------------------------
Sample Maze Pattern - 2
--------------------------------------------------------------------------

浜様様様様様用様様様様様様用様様様様様様様様様様様様様様
F
把陳陳陳 敖田陳陳 青陳陳 陳堕陳陳 団 陳超


陳 青陳津陳陳珍陳 青 敖 青陳陳陳
把 陳祖調 陳陳

把賃陳 敖陳祖陳田陳賃珍 * FSP* 堕陳祖陳陳陳陳
団津陳 陳陳

潰 青陳 青 劃調 敖 陳陳陳堕 陳

敖陳陳 敖 団陳
債 陳 陳陳陳珍陳
敖 珍陳 珍 陳調
青陳陳陳調 敖陳陳陳
S
藩様様様様様詫様様様様様様詫様様様様様溶様様様様様様様様


--------------------------------------------------------------------------
Sample Maze Pattern - 3
--------------------------------------------------------------------------

浜様様様冤様様様様様様様冤様様様様様様冤様様様様冤様様様
F
把陳陳 田陳陳 陳 陳 堕津 田陳陳 田陳
田陳
田陳陳田陳 田津津 劃陳陳楚 田賃
田陳陳 津
田津陳陳陳津 田陳
把 田田朕 津陳 超
田 団陳 田陳陳陳陳 田
陳陳 田陳津
VYOMWORLD 田陳津
田陳 田 田津陳田 陳陳 津 田
陳陳 静津 田 陳田
把電 団陳陳津 団
青陳陳田陳陳陳陳 田津
田 田津陳津陳陳 陳 津
田陳陳陳陳陳津 陳陳 陳 田陳
S
藩様様様様様様様詫様溶様様様様様様様溶様様様詫様様様様様


--------------------------------------------------------------------------------

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved copyright 123ENG