All pastes #2069681 Raw Edit

Anonymous

public text v1 · immutable
#2069681 ·published 2011-05-26 22:24 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 drawTerrain;
    var
    	x,y:integer;
    begin
    	x:=1;
    	y:=5;
    	repeat
    		repeat
    		if material[x,y]=0 then
    			begin
    				gotoxy(x,y);
    				textbackground(black);
    				write(' ');
    			end
    		else if material[x,y]=1 then 
    			begin
    				gotoxy(x,y);
    				textbackground(Brown);
    				write(' ');
    				textbackground(black);
    			end;
    			x:=x+1
    		until(x=81);
    		x:=1;
    		y:=y+1;
    	until(y=19);
    end;
     
    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 material[x,y]:=0
            else material[x,y]:=1;
            count:=count+1;
    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;
    drawTerrain;
    movement(ch1);
    repeat
    ch1:=readkey;
    movement(ch1);
    until ch1='q';
    clrscr;
    readln;
    clrscr;
    end.