Hello,
I am trying to display a game map using a TImage.
I want a black background, and then I would display the tiles.
procedure DrawMap;
var
i, j : Integer;
begin
frmMain.imgMap.Canvas.Brush.Color := clBlack;
frmMain.imgMap.Canvas.Rectangle(0, 0, frmMain.imgMap.Width, frmMain.imgMap.Height);
for i := ShiftX to ShiftX+10 do
begin
for j := ShiftY to shiftY+10 do
DrawTile(i, j);
end;
end;
procedure DrawTile(AX : Integer; AY : Integer);
var
LPosition : TPoint;
begin
if gGame.FMap.IsVisible(AX, AY) then
begin
LPosition := MapToScreen(AX, AY);
gLogger.Log('(%d, %d)', [LPosition.X, LPosition.Y]);
case gGame.FMap.GetTileAt(AX, AY) of
OCEAN : frmMain.Canvas.Draw(LPosition.X, LPosition.Y, GetImage('ocean'));
GRASSLAND : frmMain.Canvas.Draw(LPosition.X, LPosition.Y, GetImage('grassland'));
end;
frmMain.imgMap.Canvas.TextOut(LPosition.X+30, LPosition.Y+30, Format('%d, %d', [ax, ay]));
end;
end;
But it does not work well : only the black background is displayed.