X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_gfx.pas;h=bf8fc5aa2fd8a5e4d90b3dbd8ca47cbfb13ecfaa;hb=refs%2Fheads%2Fplavnota;hp=e9118a313c4c3ad2fecd7f161dc154c1e4d7d129;hpb=987c4a835a103345b59937e8e1be8524a6228712;p=d2df-sdl.git diff --git a/src/game/g_gfx.pas b/src/game/g_gfx.pas index e9118a3..bf8fc5a 100644 --- a/src/game/g_gfx.pas +++ b/src/game/g_gfx.pas @@ -103,6 +103,7 @@ type PParticle = ^TParticle; TParticle = record x, y: Integer; + oldX, oldY: Integer; velX, velY: Single; accelX, accelY: Single; state: TPartState; @@ -139,6 +140,7 @@ type TOnceAnim = record AnimType: Byte; x, y: Integer; + oldX, oldY: Integer; Animation: TAnimation; end; @@ -500,6 +502,8 @@ procedure TParticle.think (); inline; end; begin + oldx := x; + oldy := y; // awake sleeping particle, if necessary if awakeDirty then begin @@ -979,6 +983,8 @@ begin begin x := fX-devX1+Random(devX2); y := fY-devY1+Random(devY2); + oldx := x; + oldy := y; // check for level bounds if (x < g_Map_MinX) or (y < g_Map_MinY) or (x > g_Map_MaxX) or (y > g_Map_MaxY) then continue; @@ -1077,6 +1083,9 @@ begin accelY := 0.8; end; + oldx := x; + oldy := y; + // check for level bounds if (x < g_Map_MinX) or (y < g_Map_MinY) or (x > g_Map_MaxX) or (y > g_Map_MaxY) then continue; @@ -1219,6 +1228,8 @@ begin begin x := fX-devX1+Random(devX2); y := fY-devY1+Random(devY2); + oldx := x; + oldy := y; // check for level bounds if (x < g_Map_MinX) or (y < g_Map_MinY) or (x > g_Map_MaxX) or (y > g_Map_MaxY) then continue; @@ -1388,6 +1399,8 @@ begin begin x := fX-devX1+Random(devX2); y := fY-devY1+Random(devY2); + oldx := x; + oldy := y; // check for level bounds if (x < g_Map_MinX) or (y < g_Map_MinY) or (x > g_Map_MaxX) or (y > g_Map_MaxY) then continue; @@ -1470,6 +1483,8 @@ begin begin x := fX-devX1+Random(devX2); y := fY-devY1+Random(devY2); + oldx := x; + oldy := y; // check for level bounds if (x < g_Map_MinX) or (y < g_Map_MinY) or (x > g_Map_MaxX) or (y > g_Map_MaxY) then continue; @@ -1649,6 +1664,9 @@ begin for a := 0 to High(OnceAnims) do if OnceAnims[a].Animation <> nil then begin + OnceAnims[a].oldx := OnceAnims[a].x; + OnceAnims[a].oldy := OnceAnims[a].y; + case OnceAnims[a].AnimType of ONCEANIM_SMOKE: begin @@ -1673,17 +1691,7 @@ end; procedure g_GFX_Draw (); var - a, len: Integer; -{$IFDEF USE_NANOGL} - type - Vertex = record - x, y: GLfloat; - r, g, b, a: GLfloat; - end; - var - count: Integer; - v: array of Vertex; -{$ENDIF} + a, len, fx, fy: Integer; begin if not gpart_dbg_enabled then exit; @@ -1698,34 +1706,6 @@ begin glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); -{$IFDEF USE_NANOGL} - count := 0; - SetLength(v, Length(Particles)); - for a := 0 to High(Particles) do - begin - with Particles[a] do - begin - if alive and (x >= sX) and (y >= sY) and (x <= sX + sWidth) and (sY <= sY + sHeight) then - begin - v[count].x := x + 0.37; - v[count].y := y + 0.37; - v[count].r := red / 255; - v[count].g := green / 255; - v[count].b := blue / 255; - v[count].a := alpha / 255; - Inc(count); - end; - end; - end; - - glVertexPointer(2, GL_FLOAT, SizeOf(Vertex), @v[0].x); - glColorPointer(4, GL_FLOAT, SizeOf(Vertex), @v[0].r); - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_COLOR_ARRAY); - glDisableClientState(GL_NORMAL_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - glDrawArrays(GL_POINTS, 0, count); -{$ELSE} glBegin(GL_POINTS); len := High(Particles); @@ -1736,14 +1716,15 @@ begin if not alive then continue; if (x >= sX) and (y >= sY) and (x <= sX+sWidth) and (sY <= sY+sHeight) then begin + fx := nlerp(oldx, x, gLerpFactor); + fy := nlerp(oldy, y, gLerpFactor); glColor4ub(red, green, blue, alpha); - glVertex2f(x+0.37, y+0.37); + glVertex2f(fx+0.37, fy+0.37); end; end; end; glEnd(); -{$ENDIF} glDisable(GL_BLEND); end; @@ -1755,7 +1736,12 @@ begin begin if (OnceAnims[a].Animation <> nil) then begin - with OnceAnims[a] do Animation.Draw(x, y, TMirrorType.None); + with OnceAnims[a] do + begin + fx := nlerp(oldx, x, gLerpFactor); + fy := nlerp(oldy, y, gLerpFactor); + Animation.Draw(x, y, TMirrorType.None); + end; end; end; end;