Нуждающийся
Регистрация: 07.03.2009
Сообщений: 98
Написано 3 полезных сообщений (для 3 пользователей)
|
Не могу понять в чем ошибка
[s]const
MapHeight=15;
MapWidth=15;
var
exit: command;
tile1,man,kust,dom,tile,fon:image;
map:array[0..19,0..19] of string;
x,y,b,sped,sped2,zx,zc,m,a1,a2,a3,a4,a5,a6,a7,a8,key,image_id,ri,ri2,u,g,g1:integer;
ScreenHeight,ScreenWidth:integer;
res : resource;
line:string;
procedure LoadMap;
begin
res := OpenResource('/map.txt');
for y := 0 to MapHeight do begin
line := ReadLine(res);
for x := 0 to MapWidth do
map[x,y] := GetChar(line,x);
end;
CloseResource(res);
end;
procedure RedrawMap;
begin
for y := 0 to MapHeight do
for x := 0 to MapWidth do
begin
if map[x,y] = '5' then begin
zx:=x*15+sped;
zc:=y*15+sped2;
DrawImage(fon,zx,zc);
end;
if map[x,y] = '1' then begin
zx:=x*15+sped;
zc:=y*15+sped2;
DrawImage(dom,zx,zc);
end;
if map[x,y] = '2' then begin
zx:=x*15+sped2;
zc:=y*15+sped;
DrawImage(kust,zx,zc);
end;
if map[x,y] = '3' then begin
zx:=x*15+sped2;
zc:=y*15+sped;
DrawImage(tile,zx,zc);
end;
if map[x,y] = '4' then begin
zx:=x*15+sped2;
zc:=y*15+sped;
DrawImage(tile1,zx,zc);
end;
end;
end;
procedure render;
begin
setcolor(255,255,255);
RedrawMap;
drawImage(loadImage('/play.png'), 50, 50);
repaint;
end;
procedure pere;
begin
m:=0;
for y := 0 to MapHeight do
for x := 0 to MapWidth do
begin
if map[x,y] = '1,2,3,4' then begin
zx:=x*16+sped2;
zc:=y*16+sped;
if (50<(zx+a1)) and ((50+a2)>zx) and (50<(zc+a3)) and ((50+a4)>zc) then m:=m+2;
end;
end;
end;
begin
ScreenHeight := GetHeight;
ScreenWidth := GetWidth;
ri:=0;
ri2:=0;
sped:=0;
m:=0;
fon := loadImage('/man2.png');
tile1 := loadimage('/tile1.png');
tile := loadimage('/tile.png');
kust := loadimage('/kust.png');
dom := loadimage('/dom.png');
a1:=getImageWidth(loadImage('/play.png'));
a2:=getImageWidth(loadImage('/tile1.png'));
a3:=getImageHeight (loadImage('/play.png'));
a4:=getImageHeight (loadImage('/tile1.png'));
a5:=getImageWidth (loadImage('/kust.png'));
a6:=getImageWidth (loadImage('/tile.png'));
a7:=getImageHeight (loadImage('/kust.png'));
a8:=getImageHeight (loadImage('/tile.png'));
LoadMap;
render;
repeat
key := getKeyPressed;
if key =KE_KEY2 then begin
sped:=sped+6;
pere;
if (m>0) then sped := sped-6;
end;
if key =KE_KEY4 then begin
sped2:=sped2+6;
pere;
if (m>0) then sped2 := sped2-6;
end;
if key =KE_KEY6 then begin
sped2:=sped2-6;
pere;
if (m>0) then sped2 := sped2+6;
end;
if key =KE_KEY8 then begin
sped:=sped-6;
pere;
if (m>0) then sped := sped+6;
end;
render;
until false;
end.[/s]
все картинки в *.png даже не в*.PNG
Последний раз редактировалось KAK? TAK!, 30.03.2009 в 10:44.
|