procedure T2D_Engine.MovePlayer(x,y:Integer);
begin
if x <> 0
then begin
if Karte[Player.Players[Player.
index].x+x,Player.Players[Player.
index].y+y].m <> None
then begin
if (x = +1)
and (Player.Players[Player.
index].x+x >= Player.DX )
then
Player.Players[Player.
index].scrollX:=Player.Players[Player.
index].scrollX+1;
if (x = -1)
and (Player.Players[Player.
index].scrollX-1 >-1)
then begin
Player.Players[Player.
index].scrollX:=Player.Players[Player.
index].scrollX-1;
end;
Player.Players[Player.
index].x:=Player.Players[Player.
index].x+x;
end;
end;
if y <> 0
then begin
if Karte[Player.Players[Player.
index].x+x,Player.Players[Player.
index].y+y].m <> None
then begin
Player.Players[Player.
index].Y:=Player.Players[Player.
index].y+y;
end;
end;
end;
procedure T2D_Engine.CheckKey(Key:Word);
begin
if ((Key = VK_LEFT)
or (Key = VK_NUMPAD4))
and (Player.Players[Player.
index].x-1 >= 0)
then MovePlayer(-1,0);
if ((Key = VK_RIGHT)
or (Key = VK_NUMPAD6))
and (Player.Players[Player.
index].x+1 <= MapX)
then MovePlayer(+1,0);
if ((Key = VK_UP)
or (Key = VK_NUMPAD8))
and (Player.Players[Player.
index].y-1 >=0)
then MovePlayer(0,-1);
if ((Key = VK_DOWN)
or (Key = VK_NUMPAD2))
and (Player.Players[Player.
index].y+1 <= MapY)
then MovePlayer(0,+1);
if (Key = VK_NUMPAD7)
and (Player.
Index+1 <= High(Player.Players))
then Inc(Player.
Index);
if (Key = VK_NUMPAD9)
and (Player.
Index-1 >= 0)
then dec(Player.
Index);
if key = VK_NUMPAD5
then begin
Player.Players[Player.
index].ScrollX:=Player.Players[Player.
index].ScrollX+1;
Player.Players[Player.
index].ScrollY:=0;
end;
end;
procedure T2D_Engine.DrawMap;
var
x,y,i:Integer;
begin
GLXDraw.Clear;
// sx:=0; sy:=0;
for x:=Player.Players[Player.
Index].scrollX
to Player.Players[Player.
Index].scrollX + Player.DX
do begin
for y:=0
to MapY
do begin
if Karte[x,y].typ > -1
then begin
for i:=0
to High(Karte[x,y].Tex)
do begin
GLXImageList.Items[Karte[x,y].typ].Draw( X*MapS,Y*MapS,Karte[x,y].Tex[i] );
end;
end;
end;
end;
for i:=0
to High(Player.Players)
do
GLXImageList.Items[2].Draw( (Player.players[i].X-Player.DX)*MapS,Player.players[i].Y*MapS,Player.players[i].tex );
GLXDraw.Flip;
end;