-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathumap.pas
More file actions
50 lines (38 loc) · 756 Bytes
/
umap.pas
File metadata and controls
50 lines (38 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
unit umap;
{$mode objfpc}{$H+} {$MODESWITCH ADVANCEDRECORDS}
interface
uses
Classes, SysUtils;
type
IntGrid = array of array of integer;
TMap = record
private
const MapFileName = 'map.txt';
public
Map: IntGrid;
function ReadFromFile: IntGrid;
end;
var
GameMap: TMap;
implementation
function TMap.ReadFromFile: IntGrid;
var
fin: text;
j: integer;
s: string;
begin
assign(fin,MapFileName);
reset(fin);
while (not eof(fin)) do
begin
setlength(Result,length(Result)+1);
readln(fin,s);
setlength(Result[high(Result)],length(s));
for j := low(s) to high(s) do
Result[high(Result),j-1] := StrToIntDef(s[j],0);
end;
close(fin);
end;
initialization
GameMap.Map := GameMap.ReadFromFile;
end.