Code:
procedure TMain.EditorDrawGrid;
var x,y,z : integer;
begin
// 15 lines
for y := 0 to Map.MapLength-1 do
// 4 layers
for z := 0 to 3 do
// 20 columns
for x := 0 to 19 do
begin
// create/modify sprite with image
if map.Layer[z].Lines[y,x].ImageIndex <> 0 then
begin
// if sprite was not created I create it
if BackGround[z,x,y] = nil then
begin
BackGround[z,x,y] := TBackGround.Create(SpriteEngine);
BackGround[z,x,y].ImageName:= Images.Item[map.Layer[z].Lines[y,x].ImageIndex].Name;
BackGround[z,x,y].X:=x*32;
BackGround[z,x,y].Y:=y*32;
BackGround[z,x,y].VisibleArea:= rect(-32,-32,640,480);
BackGround[z,x,y].Z:=z;
end
// otherwise I only set new image
else
begin
BackGround[z,x,y].ImageName:= Images.Item[map.Layer[z].Lines[y,x].ImageIndex].Name;
end;
// animation properties
if BackGround[z,x,y].PatternCount = 1 then
begin
BackGround[z,x,y].DoAnimate:=false;
end
else
begin
BackGround[z,x,y].AnimStart:=0;
BackGround[z,x,y].AnimCount:=map.Layer[z].Lines[y,x].AnimCount;
BackGround[z,x,y].AnimSpeed:=map.Layer[z].Lines[y,x].AnimSpeed;
BackGround[z,x,y].AnimPos:=(EditorAnimationCounter mod BackGround[z,x,y].AnimCount)+map.Layer[z].Lines[y,x].AnimStart;
BackGround[z,x,y].DoAnimate:=true;
BackGround[z,x,y].AnimLooped:=true;
end;
end
// if sprite is empty, I kill it , and set the array entry to nil
else
begin
if BackGround[z,x,y] <> nil then
begin
BackGround[z,x,y].Dead;
BackGround[z,x,y]:=Nil;
end;
end;
end;
end;
BackGround[z,x,y].VisibleArea:= rect(-32,-32,640,480); if I make this smaller , like 380, the Visible area is smaller, but the speed stays the same not to mention the memory usage, it seems even though it's NOT drawing, the part that does the calculations and who knows what are still taking a considerable tax on the machine.
Bookmarks