All pastes #2069669 Raw Edit

Untitled

public text v1 · immutable
#2069669 ·published 2011-05-26 21:53 UTC
rendered paste body
program asciicraft;
uses crt;
var i : integer;
var material :array[1..80,1..18] of integer;
var xglobal, yglobal :integer;
var ch1 : char;

Procedure terrain(x:integer);
var y, num, count : integer;
begin
y:=5;
count:=1;
repeat
	gotoxy(x,y);
	num:=random(100)+1;
	y:=y+1;
	if num>75 then begin
	writeln(' ');
	material[x,y]:=0;
	end
	else begin 
		textbackground(BROWN); 
		writeln(' '); 
		textbackground(BLACK); 
	material[x,y]:=1;
	end;
	count:=count+1;
	delay(2);
until count=15
end;


procedure drawchar;
begin
	writeln('A');
end;


procedure movement(key:char);
begin
if key = 'd' then begin
	if material[xglobal+1,yglobal]=0 then begin
	gotoxy(xglobal,yglobal);
	writeln(' ');
	xglobal:=xglobal+1;
	gotoxy(xglobal,yglobal);
	drawchar;
	end;
	end;
if key = 's' then begin
	if material[xglobal,yglobal+1]=0 then begin
	gotoxy(xglobal,yglobal);
	writeln(' ');
	yglobal:=yglobal+1;
	gotoxy(xglobal,yglobal);
	drawchar;
	end;
	end;
if key = 'a' then begin
	if material[xglobal-1,yglobal]=0 then begin
	gotoxy(xglobal,yglobal);
	writeln(' ');
	xglobal:=xglobal-1;
	gotoxy(xglobal,yglobal);
	drawchar;
	end;
	end;
if key = 'w' then begin
	if material[xglobal,yglobal-1]=0 then begin
	gotoxy(xglobal,yglobal);
	writeln(' ');
	yglobal:=yglobal-1;
	gotoxy(xglobal,yglobal);
	drawchar;
	end;
	end
else begin
gotoxy(xglobal,yglobal);
drawchar;
end;
end;

begin
ch1:=' ';
xglobal:=1;
yglobal:=4;
randomize;
clrscr;
i:=1;
repeat
terrain(i);
i:=i+1;
until i=80;
movement(ch1);
repeat
ch1:=readkey;
movement(ch1);
until ch1='q';
clrscr;
readln;
clrscr;
end.