summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: be528d3)
raw | patch | inline | side by side (parent: be528d3)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sat, 2 Sep 2017 20:00:27 +0000 (23:00 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sat, 2 Sep 2017 20:01:55 +0000 (23:01 +0300) |
src/game/g_gfx.pas | patch | blob | history |
diff --git a/src/game/g_gfx.pas b/src/game/g_gfx.pas
index c365e662fe81db704f64ea09438007fcbd7bcc46..593613e79e07c3f636746a793f63606c3761d859 100644 (file)
--- a/src/game/g_gfx.pas
+++ b/src/game/g_gfx.pas
procedure freeze (); inline; // remove velocities and acceleration
procedure sleep (); inline; // switch to sleep mode
+ function checkAirStreams (): Boolean; // `true`: affected by air stream
+
function alive (): Boolean; inline;
procedure die (); inline;
procedure think (); inline;
end;
+// `true`: affected by air stream
+function TParticle.checkAirStreams (): Boolean;
+var
+ pan: TPanel;
+begin
+ pan := g_Map_PanelAtPoint(x, y, GridTagLift);
+ result := (pan <> nil);
+ if result then
+ begin
+ if ((pan.PanelType and PANEL_LIFTUP) <> 0) then
+ begin
+ if (velY > -4-Random(3)) then velY -= 0.8;
+ if (abs(velX) > 0.1) then velX -= velX/10.0;
+ velX += (Random-Random)*0.2;
+ accelY := 0.15;
+ end
+ else if ((pan.PanelType and PANEL_LIFTLEFT) <> 0) then
+ begin
+ if (velX > -8-Random(3)) then velX -= 0.8;
+ accelY := 0.15;
+ end
+ else if ((pan.PanelType and PANEL_LIFTRIGHT) <> 0) then
+ begin
+ if (velX < 8+Random(3)) then velX += 0.8;
+ accelY := 0.15;
+ end
+ else
+ begin
+ result := false;
+ end;
+ // awake
+ if result and (state = TPartState.Sleeping) then state := TPartState.Normal;
+ end;
+end;
+
+
// switch to sleep mode
procedure TParticle.sleep (); inline;
begin
- state := TPartState.Sleeping;
- freeze();
+ if not checkAirStreams() then
+ begin
+ state := TPartState.Sleeping;
+ freeze();
+ end;
end;
if result then begin velY := 0.5; accelY := 0.15; end;
end;
- // `true`: affected by air stream
- function checkAirStreams (): Boolean;
- var
- pan: TPanel;
- begin
- pan := g_Map_PanelAtPoint(x, y, GridTagLift);
- result := (pan <> nil);
- if result then
- begin
- if ((pan.PanelType and PANEL_LIFTUP) <> 0) then
- begin
- if (velY > -4-Random(3)) then velY -= 0.8;
- if (abs(velX) > 0.1) then velX -= velX/10.0;
- velX += (Random-Random)*0.2;
- accelY := 0.15;
- end
- else if ((pan.PanelType and PANEL_LIFTLEFT) <> 0) then
- begin
- if (velX > -8-Random(3)) then velX -= 0.8;
- accelY := 0.15;
- end
- else if ((pan.PanelType and PANEL_LIFTRIGHT) <> 0) then
- begin
- if (velX < 8+Random(3)) then velX += 0.8;
- accelY := 0.15;
- end
- else
- begin
- result := false;
- end;
- // awake
- if result and (state = TPartState.Sleeping) then state := TPartState.Normal;
- end;
- end;
-
// switch to freefall mode
procedure freefall ();
begin
if gAdvBlood then
begin
- // still check for air streams when sleeping
- if (state = TPartState.Sleeping) then begin checkAirStreams(); goto _done; end; // so blood will dissolve
+ // still check for air streams when sleeping (no)
+ if (state = TPartState.Sleeping) then begin {checkAirStreams();} goto _done; end; // so blood will dissolve
// process stuck particles
if (state = TPartState.Stuck) then
dX := round(velX);
dY := round(velY);
+ if (state = TPartState.Normal) then checkAirStreams();
+
// gravity, if not stuck
if (state <> TPartState.Stuck) and (abs(velX) < 0.1) and (abs(velY) < 0.1) then
begin
// either in a wall, or in a liquid
//if ((pan.tag and GridTagObstacle) <> 0) then continue; // don't spawn in walls
//env := TEnvType.ELiquid;
- continue;
+ //continue;
+ env := TEnvType.EAir;
end
else
begin