index 07028727cabe135dfabf24efd119bad1868fe4bc..87379696680a2cf7d33bd88b5ea097f0891c72b7 100644 (file)
implementation
uses
- Math,
+ Math, SysUtils,
{$IFDEF USE_GLES1}
GLES11,
{$ELSE}
{$IFDEF ENABLE_GFX}
g_gfx,
{$ENDIF}
- r_textures, r_draw
+ r_textures, r_draw, r_common
;
const
);
{$ENDIF}
+ PunchAnim: TAnimInfo = (loop: false; delay: 1; frames: 4; back: false);
FlagAnim: TAnimInfo = (loop: true; delay: 8; frames: 5; back: false);
+ VileFireAnim: TAnimInfo = (loop: true; delay: 2; frames: 8; back: false);
type
TBinHeapPanelDrawCmp = class
RenTextures: array of record
spec: LongInt;
tex: TGLMultiTexture;
+ anim: TAnimInfo;
end;
Items: array [0..ITEM_LAST] of record
tex: TGLMultiTexture;
Models[i].anim[d, a].base := nil;
Models[i].anim[d, a].mask := nil;
if m.anim[d, a].resource <> '' then
- Models[i].anim[d, a].base := r_Textures_LoadMultiFromFileAndInfo(prefix + m.anim[d, a].resource, 64, 64, m.anim[d, a].frames, m.anim[d, a].back, true);
+ Models[i].anim[d, a].base := r_Textures_LoadMultiFromFileAndInfo(prefix + m.anim[d, a].resource, 64, 64, m.anim[d, a].frames, true);
if m.anim[d, a].mask <> '' then
- Models[i].anim[d, a].mask := r_Textures_LoadMultiFromFileAndInfo(prefix + m.anim[d, a].mask, 64, 64, m.anim[d, a].frames, m.anim[d, a].back, true);
+ Models[i].anim[d, a].mask := r_Textures_LoadMultiFromFileAndInfo(prefix + m.anim[d, a].mask, 64, 64, m.anim[d, a].frames, true);
end
end;
{$IFDEF ENABLE_GIBS}
w,
h,
count,
- False,
False
);
end
ItemAnim[i].w,
ItemAnim[i].h,
ItemAnim[i].anim.frames,
- ItemAnim[i].anim.back,
false
);
Items[i].frame := 0;
for j := 0 to ANIM_LAST do
for d := TDirection.D_LEFT to TDirection.D_RIGHT do
r_Map_LoadMonsterAnim(i, j, d);
- VileFire := r_Textures_LoadMultiFromFileAndInfo(GameWAD + ':TEXTURES/FIRE', 64, 128, 8, False, False);
+ VileFire := r_Textures_LoadMultiFromFileAndInfo(GameWAD + ':TEXTURES/FIRE', 64, 128, VileFireAnim.frames);
// --------- player models --------- //
if PlayerModelsArray <> nil then
begin
{$IFDEF ENABLE_GFX}
for i := 1 to R_GFX_LAST do
if GFXAnim[i].anim.frames > 0 then
- GFXTextures[i] := r_Textures_LoadMultiFromFileAndInfo(GameWad + ':TEXTURES/' + GFXAnim[i].name, GFXAnim[i].w, GFXAnim[i].h, GFXAnim[i].anim.frames, GFXAnim[i].anim.back);
+ GFXTextures[i] := r_Textures_LoadMultiFromFileAndInfo(GameWad + ':TEXTURES/' + GFXAnim[i].name, GFXAnim[i].w, GFXAnim[i].h, GFXAnim[i].anim.frames);
{$ENDIF}
// --------- shots --------- //
for i := 0 to WEAPON_LAST do
if ShotAnim[i].anim.frames > 0 then
- ShotTextures[i] := r_Textures_LoadMultiFromFileAndInfo(GameWad + ':TEXTURES/' + ShotAnim[i].name, ShotAnim[i].w, ShotAnim[i].h, ShotAnim[i].anim.frames, ShotAnim[i].anim.back);
+ ShotTextures[i] := r_Textures_LoadMultiFromFileAndInfo(GameWad + ':TEXTURES/' + ShotAnim[i].name, ShotAnim[i].w, ShotAnim[i].h, ShotAnim[i].anim.frames);
// --------- flags --------- //
FlagTextures[FLAG_NONE] := nil;
- FlagTextures[FLAG_RED] := r_Textures_LoadMultiFromFileAndInfo(GameWad + ':TEXTURES/FLAGRED', 64, 64, 5, false);
- FlagTextures[FLAG_BLUE] := r_Textures_LoadMultiFromFileAndInfo(GameWad + ':TEXTURES/FLAGBLUE', 64, 64, 5, false);
- // FlagTextures[FLAG_DOM] := r_Textures_LoadMultiFromFileAndInfo(GameWad + ':TEXTURES/FLAGDOM', 64, 64, 8, false);
+ FlagTextures[FLAG_RED] := r_Textures_LoadMultiFromFileAndInfo(GameWad + ':TEXTURES/FLAGRED', 64, 64, 5);
+ FlagTextures[FLAG_BLUE] := r_Textures_LoadMultiFromFileAndInfo(GameWad + ':TEXTURES/FLAGBLUE', 64, 64, 5);
+ // FlagTextures[FLAG_DOM] := r_Textures_LoadMultiFromFileAndInfo(GameWad + ':TEXTURES/FLAGDOM', 64, 64, 8);
// --------- shells --------- //
{$IFDEF ENABLE_SHELLS}
for i := 0 to SHELL_LAST do
for b := false to true do
begin
for i := 0 to 2 do
- PunchTextures[b, i] := r_Textures_LoadMultiFromFileAndInfo(GameWad + ':WEAPONS/' + PunchName[b] + WeapPos[i], 64, 64, 4, false);
+ PunchTextures[b, i] := r_Textures_LoadMultiFromFileAndInfo(GameWad + ':WEAPONS/' + PunchName[b] + WeapPos[i], 64, 64, PunchAnim.frames);
end;
// --------- other --------- //
InvulPenta := r_Textures_LoadFromFile(GameWad + ':TEXTURES/PENTA');
end;
procedure r_Map_LoadTextures;
- var i, n: Integer;
+ const DefaultAnimInfo: TAnimInfo = (loop: true; delay: 1; frames: 1; back: false);
+ var i, n: Integer; txt: TAnimTextInfo;
begin
if Textures <> nil then
begin
SetLength(RenTextures, n);
for i := 0 to n - 1 do
begin
+ txt.anim := DefaultAnimInfo;
RenTextures[i].tex := nil;
case Textures[i].TextureName of
TEXTURE_NAME_WATER: RenTextures[i].spec := TEXTURE_SPECIAL_WATER;
TEXTURE_NAME_ACID2: RenTextures[i].spec := TEXTURE_SPECIAL_ACID2;
else
RenTextures[i].spec := 0;
- RenTextures[i].tex := r_Textures_LoadMultiFromFile(Textures[i].FullName);
+ e_LogWritefln('r_Map_LoadTextures: begin load texture: %s', [Textures[i].FullName]);
+ RenTextures[i].tex := r_Textures_LoadMultiTextFromFile(Textures[i].FullName, txt);
+ e_LogWritefln('r_Map_LoadTextures: end load texture: %s', [Textures[i].FullName]);
if RenTextures[i].tex = nil then
e_LogWritefln('r_Map_LoadTextures: failed to load texture: %s', [Textures[i].FullName]);
end;
+ RenTextures[i].anim := txt.anim;
end;
end;
if gMapInfo.SkyFullName <> '' then
end;
procedure r_Map_DrawPanel (p: TPanel);
- var Texture: Integer; t: TGLMultiTexture;
+ var Texture: Integer; t: TGLMultiTexture; tex: TGLTexture; count, frame: LongInt; a: TAnimInfo;
begin
ASSERT(p <> nil);
if p.FCurTexture >= 0 then
begin
Texture := p.TextureIDs[p.FCurTexture].Texture;
t := RenTextures[Texture].tex;
-
if (RenTextures[Texture].spec = 0) or (t <> nil) then
begin
- if t = nil then
- r_Draw_TextureRepeat(nil, p.x, p.y, p.width, p.height, false, 255, 255, 255, 255 - p.alpha, p.blending)
- else if p.TextureIDs[p.FCurTexture].AnTex.IsValid() then
- r_Draw_MultiTextureRepeat(t, p.TextureIDs[p.FCurTexture].AnTex, p.x, p.y, p.width, p.height, false, 255, 255, 255, 255 - p.alpha, p.blending)
+ count := 0; frame := 0;
+ if p.AnimTime <= gTime then
+ begin
+ a := RenTextures[Texture].anim;
+ a.loop := p.AnimLoop;
+ g_Anim_GetFrameByTime(a, (gTime - p.AnimTime) DIV GAME_TICK, count, frame);
+ end;
+ if t <> nil then
+ begin
+ tex := t.GetTexture(frame);
+ r_Draw_TextureRepeat(tex, p.x, p.y, p.width, p.height, false, 255, 255, 255, 255 - p.alpha, p.blending);
+ end
else
- r_Draw_TextureRepeat(t.GetTexture(0), p.x, p.y, p.width, p.height, false, 255, 255, 255, 255 - p.alpha, p.blending)
+ r_Draw_TextureRepeat(nil, p.x, p.y, p.width, p.height, false, 255, 255, 255, 255, false);
end;
if t = nil then
end;
procedure r_Map_DrawMonsterAttack (constref mon: TMonster);
- var o: TObj;
+ var o: TObj; count, frame: LongInt; tex: TGLTexture;
begin
if VileFire <> nil then
if (mon.MonsterType = MONSTER_VILE) and (mon.MonsterState = MONSTATE_SHOOT) then
- if mon.VileFireAnim.IsValid() and GetPos(mon.MonsterTargetUID, @o) then
- r_Draw_MultiTextureRepeat(VileFire, mon.VileFireAnim, o.x + o.rect.x + (o.rect.width div 2) - VILEFIRE_DX, o.y + o.rect.y + o.rect.height - VILEFIRE_DY, VileFire.width, VileFire.height, False, 255, 255, 255, 255, false);
+ if (mon.VileFireTime <= gTime) and GetPos(mon.MonsterTargetUID, @o) then
+ begin
+ g_Anim_GetFrameByTime(VileFireAnim, (gTime - mon.VileFireTime) DIV GAME_TICK, count, frame);
+ tex := VileFire.GetTexture(frame);
+ r_Draw_TextureRepeat(tex, o.x + o.rect.x + (o.rect.width div 2) - VILEFIRE_DX, o.y + o.rect.y + o.rect.height - VILEFIRE_DY, tex.width, tex.height, False, 255, 255, 255, 255, false);
+ end;
end;
procedure r_Map_DrawMonster (constref mon: TMonster);
mon.obj.Lerp(gLerpFactor, fX, fY);
if r_Map_GetMonsterTexture(m, a, d, t, dx, dy, flip) then
- r_Draw_MultiTextureRepeat(t, mon.DirAnim[a, d], fX + dx, fY + dy, t.width, t.height, flip, 255, 255, 255, 255, false);
+ r_Draw_MultiTextureRepeat(t, mon.DirAnim[a, d], false, fX + dx, fY + dy, t.width, t.height, flip, 255, 255, 255, 255, false);
// TODO draw g_debug_frames
end;
end;
procedure r_Map_DrawPlayerModel (pm: TPlayerModel; x, y: Integer; alpha: Byte);
- var a, pos, act, xx, yy, angle: Integer; d: TDirection; flip: Boolean; t: TGLMultiTexture; tex: TGLTexture; c: TRGB;
+ var a, pos, act, xx, yy, angle: Integer; d: TDirection; flip, back: Boolean; t: TGLMultiTexture; tex: TGLTexture; c: TRGB;
begin
a := pm.CurrentAnimation;
d := pm.Direction;
if r_Map_GetPlayerModelTex(pm.id, a, d, flip) then
begin
t := Models[pm.id].anim[d, a].base;
- r_Draw_MultiTextureRepeat(t, pm.AnimState, x, y, t.width, t.height, flip, 255, 255, 255, alpha, false);
+ back := PlayerModelsArray[pm.id].anim[d, a].back;
+ r_Draw_MultiTextureRepeat(t, pm.AnimState, back, x, y, t.width, t.height, flip, 255, 255, 255, alpha, false);
t := Models[pm.id].anim[d, a].mask;
if t <> nil then
begin
c := pm.Color;
- r_Draw_MultiTextureRepeat(t, pm.AnimState, x, y, t.width, t.height, flip, c.r, c.g, c.b, alpha, false);
+ r_Draw_MultiTextureRepeat(t, pm.AnimState, back, x, y, t.width, t.height, flip, c.r, c.g, c.b, alpha, false);
end;
end;
end;
procedure r_Map_DrawPlayer (p, drawed: TPlayer);
- var fX, fY, fSlope, ax, ay, w, h: Integer; b, flip: Boolean; t: TGLMultiTexture; alpha: Byte;
+ var fX, fY, fSlope, ax, ay, w, h: Integer; b, flip: Boolean; t: TGLMultiTexture; tex: TGLTexture; alpha: Byte; count, frame: LongInt;
begin
if p.alive then
begin
fSlope := nlerp(p.SlopeOld, p.obj.slopeUpLeft, gLerpFactor);
(* punch effect *)
- if p.PunchAnim.IsValid() and p.PunchAnim.enabled then
+ if p.PunchTime <= gTime then
begin
- b := R_BERSERK in p.FRulez;
- if p.FKeys[KEY_DOWN].pressed then
- t := PunchTextures[b, 2]
- else if p.FKeys[KEY_UP].pressed then
- t := PunchTextures[b, 1]
- else
- t := PunchTextures[b, 0];
- if t <> nil then
+ g_Anim_GetFrameByTime(PunchAnim, (gTime - p.PunchTime) DIV GAME_TICK, count, frame);
+ if count < 1 then
begin
- flip := p.Direction = TDirection.D_LEFT;
- ax := IfThen(flip, 15 - p.Obj.Rect.X, p.Obj.Rect.X - 15); // ???
- ay := p.Obj.Rect.Y - 11;
- r_Draw_MultiTextureRepeat(t, p.PunchAnim, fx + ax, fy + fSlope + ay, t.width, t.height, flip, 255, 255, 255, 255, false)
+ b := R_BERSERK in p.FRulez;
+ if p.FKeys[KEY_DOWN].pressed then
+ t := PunchTextures[b, 2]
+ else if p.FKeys[KEY_UP].pressed then
+ t := PunchTextures[b, 1]
+ else
+ t := PunchTextures[b, 0];
+ if t <> nil then
+ begin
+ flip := p.Direction = TDirection.D_LEFT;
+ ax := IfThen(flip, 15 - p.Obj.Rect.X, p.Obj.Rect.X - 15); // ???
+ ay := p.Obj.Rect.Y - 11;
+ tex := t.GetTexture(frame);
+ r_Draw_TextureRepeat(tex, fx + ax, fy + fSlope + ay, tex.width, tex.height, flip, 255, 255, 255, 255, false)
+ end;
end;
end;