1336
Closed / [FIXED] [BUG] [PLAYER] Platformer may start at very left edge of level
« on: February 22, 2016, 07:17:01 PM »
If the lemming is at the left edge of the level, the terrain checks for starting a platformer are relaxed.
Consider the test map and try to assign a platformer at the very edge of the terrain piece. You will succeed only for the upper left lemming.
Here is again namida's LemCanPlatform function:
It contains the line
PS: I hate non-descriptive variable names like x, x2 or c2.
Consider the test map and try to assign a platformer at the very edge of the terrain piece. You will succeed only for the upper left lemming.
Here is again namida's LemCanPlatform function:
Code: [Select]
function TLemmingGame.LemCanPlatform(L: TLemming): Boolean;
var
x, x2: Integer;
c2: Boolean;
begin
with L do
begin
x := LemX;
if LemDX < 0 then Dec(x, 5);
Result := false;
c2 := true;
for x2 := x to x+5 do
if not HasPixelAt(x2, LemY) then
begin
if x2 < 3 then c2 := false;
Result := true;
end;
if LemDX < 0 then Inc(x, 2);
if c2 and Result then
for x2 := x+1 to x+2 do
if HasPixelAt(x2, LemY-1) then
Result := false;
end;
end;
It contains the line
Code: [Select]
if x2 < 3 then c2 := false;
which sets c2 to false if either the lemming faces left and is among the 8 left-most pixels or if the lemming faces right and is among the 3 left-most pixels. However setting c2=false removes the terrain checks at HasPixelAt(x+1, LemY-1) and HasPixelAt(x+2, LemY-1). So the upper right lemming in the example level does not see the inverted cone hanging above him and hence starts platforming.PS: I hate non-descriptive variable names like x, x2 or c2.