X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Frenders%2Fopengl%2Fr_map.pas;h=f9ac5dc08648eb151615af14be70b31991d30058;hb=b36923c380a9760c74967bc8c850517c386747db;hp=4ffd6e18345e203525615484b677c7390e090f50;hpb=df1f12c26369a0d5e9e996583b30c9879570fe99;p=d2df-sdl.git diff --git a/src/game/renders/opengl/r_map.pas b/src/game/renders/opengl/r_map.pas index 4ffd6e1..f9ac5dc 100644 --- a/src/game/renders/opengl/r_map.pas +++ b/src/game/renders/opengl/r_map.pas @@ -45,7 +45,7 @@ interface implementation uses - Math, + Math, SysUtils, {$IFDEF USE_GLES1} GLES11, {$ELSE} @@ -67,7 +67,7 @@ implementation {$IFDEF ENABLE_GFX} g_gfx, {$ENDIF} - r_textures, r_draw + r_textures, r_draw, r_common ; const @@ -177,35 +177,35 @@ implementation ShotAnim: array [0..WEAPON_LAST] of record name: AnsiString; w, h: Integer; - count: Integer; + anim: TAnimInfo; end = ( - (name: ''; w: 0; h: 0; count: 0), // 0 KASTET - (name: ''; w: 0; h: 0; count: 0), // 1 SAW - (name: ''; w: 0; h: 0; count: 0), // 2 PISTOL - (name: ''; w: 0; h: 0; count: 0), // 3 SHOTGUN1 - (name: ''; w: 0; h: 0; count: 0), // 4 SHOTGUN2 - (name: ''; w: 0; h: 0; count: 0), // 5 CHAINGUN - (name: 'BROCKET'; w: 64; h: 32; count: 1), // 6 ROCKETLAUNCHER - (name: 'BPLASMA'; w: 16; h: 16; count: 2), // 7 PLASMA - (name: 'BBFG'; w: 64; h: 64; count: 2), // 8 BFG - (name: ''; w: 0; h: 0; count: 0), // 9 SUPERPULEMET - (name: 'FLAME'; w: 32; h: 32; count: 0{11}), // 10 FLAMETHROWER - (name: ''; w: 0; h: 0; count: 0), // 11 - (name: ''; w: 0; h: 0; count: 0), // 12 - (name: ''; w: 0; h: 0; count: 0), // 13 - (name: ''; w: 0; h: 0; count: 0), // 14 - (name: ''; w: 0; h: 0; count: 0), // 15 - (name: ''; w: 0; h: 0; count: 0), // 16 - (name: ''; w: 0; h: 0; count: 0), // 17 - (name: ''; w: 0; h: 0; count: 0), // 18 - (name: ''; w: 0; h: 0; count: 0), // 19 - (name: ''; w: 0; h: 0; count: 0), // 20 ZOMPY_PISTOL - (name: 'BIMPFIRE'; w: 16; h: 16; count: 2), // 21 IMP_FIRE - (name: 'BBSPFIRE'; w: 16; h: 16; count: 2), // 22 BSP_FIRE - (name: 'BCACOFIRE'; w: 16; h: 16; count: 2), // 23 CACO_FIRE - (name: 'BBARONFIRE'; w: 64; h: 16; count: 2), // 24 BARON_FIRE - (name: 'BMANCUBFIRE'; w: 64; h: 32; count: 2), // 25 MANCUB_FIRE - (name: 'BSKELFIRE'; w: 64; h: 64; count: 2) // 26 SKEL_FIRE + (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 0 KASTET + (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 1 SAW + (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 2 PISTOL + (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 3 SHOTGUN1 + (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 4 SHOTGUN2 + (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 5 CHAINGUN + (name: 'BROCKET'; w: 64; h: 32; anim: (loop: true; delay: 1; frames: 1; back: false)), // 6 ROCKETLAUNCHER + (name: 'BPLASMA'; w: 16; h: 16; anim: (loop: true; delay: 5; frames: 2; back: false)), // 7 PLASMA + (name: 'BBFG'; w: 64; h: 64; anim: (loop: true; delay: 6; frames: 2; back: false)), // 8 BFG + (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 9 SUPERPULEMET + (name: 'FLAME'; w: 32; h: 32; anim: (loop: true; delay: 6; frames: 0{11}; back: false)), // 10 FLAMETHROWER + (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 11 + (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 12 + (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 13 + (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 14 + (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 15 + (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 16 + (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 17 + (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 18 + (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 19 + (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 20 ZOMPY_PISTOL + (name: 'BIMPFIRE'; w: 16; h: 16; anim: (loop: true; delay: 4; frames: 2; back: false)), // 21 IMP_FIRE + (name: 'BBSPFIRE'; w: 16; h: 16; anim: (loop: true; delay: 4; frames: 2; back: false)), // 22 BSP_FIRE + (name: 'BCACOFIRE'; w: 16; h: 16; anim: (loop: true; delay: 4; frames: 2; back: false)), // 23 CACO_FIRE + (name: 'BBARONFIRE'; w: 64; h: 16; anim: (loop: true; delay: 4; frames: 2; back: false)), // 24 BARON_FIRE + (name: 'BMANCUBFIRE'; w: 64; h: 32; anim: (loop: true; delay: 4; frames: 2; back: false)), // 25 MANCUB_FIRE + (name: 'BSKELFIRE'; w: 64; h: 64; anim: (loop: true; delay: 5; frames: 2; back: false)) // 26 SKEL_FIRE ); {$IFDEF ENABLE_SHELLS} @@ -219,6 +219,7 @@ implementation ); {$ENDIF} + PunchAnim: TAnimInfo = (loop: false; delay: 1; frames: 4; back: false); FlagAnim: TAnimInfo = (loop: true; delay: 8; frames: 5; back: false); type @@ -260,9 +261,6 @@ implementation {$ENDIF} end; - StubShotAnim: TAnimState; // TODO remove this hack - FlagFrame: LongInt; - {$IFDEF ENABLE_SHELLS} ShellTextures: array [0..SHELL_LAST] of TGLTexture; {$ENDIF} @@ -278,6 +276,7 @@ implementation end = nil; {$ENDIF} + FlagFrame: LongInt; plist: TBinHeapPanelDraw = nil; class function TBinHeapPanelDrawCmp.less (const a, b: TPanel): Boolean; inline; @@ -289,7 +288,6 @@ implementation procedure r_Map_Initialize; begin - StubShotAnim := TAnimState.Create(true, 1, 1); FlagFrame := 0; plist := TBinHeapPanelDraw.Create(); end; @@ -298,7 +296,6 @@ implementation begin plist.Free; FlagFrame := 0; - StubShotAnim.Invalidate; end; procedure r_Map_FreeModel (i: Integer); @@ -447,8 +444,8 @@ implementation {$ENDIF} // --------- shots --------- // for i := 0 to WEAPON_LAST do - if ShotAnim[i].count > 0 then - ShotTextures[i] := r_Textures_LoadMultiFromFileAndInfo(GameWad + ':TEXTURES/' + ShotAnim[i].name, ShotAnim[i].w, ShotAnim[i].h, ShotAnim[i].count, false); + 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); // --------- flags --------- // FlagTextures[FLAG_NONE] := nil; FlagTextures[FLAG_RED] := r_Textures_LoadMultiFromFileAndInfo(GameWad + ':TEXTURES/FLAGRED', 64, 64, 5, false); @@ -463,7 +460,7 @@ implementation 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, PunchAnim.back); end; // --------- other --------- // InvulPenta := r_Textures_LoadFromFile(GameWad + ':TEXTURES/PENTA'); @@ -819,7 +816,7 @@ implementation 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 @@ -829,21 +826,26 @@ implementation 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; @@ -1075,7 +1077,7 @@ implementation {$ENDIF} procedure r_Map_DrawShots (x, y, w, h: Integer); - var i, a, fX, fY, pX, pY, typ: Integer; tex: TGLMultiTexture; anim: ^TAnimState; + var i, a, fX, fY, pX, pY, typ: Integer; count, frame: LongInt; t: TGLMultiTexture; tex: TGLTexture; begin if Shots <> nil then begin @@ -1084,8 +1086,8 @@ implementation typ := Shots[i].ShotType; if typ <> 0 then begin - tex := ShotTextures[typ]; - if tex <> nil then + t := ShotTextures[typ]; + if t <> nil then begin a := 0; case typ of @@ -1095,9 +1097,9 @@ implementation Shots[i].Obj.Lerp(gLerpFactor, fX, fY); pX := Shots[i].Obj.Rect.Width div 2; pY := Shots[i].Obj.Rect.Height div 2; - // TODO fix this hack - if Shots[i].Animation.IsValid() then anim := @Shots[i].Animation else anim := @StubShotAnim; - r_Draw_MultiTextureRepeatRotate(tex, anim^, fX, fY, tex.width, tex.height, false, 255, 255, 255, 255, false, pX, pY, a); + g_Anim_GetFrameByTime(ShotAnim[typ].anim, (gTime - Shots[i].time) DIV GAME_TICK, count, frame); + tex := t.GetTexture(frame); + r_Draw_TextureRepeatRotate(tex, fX, fY, tex.width, tex.height, false, 255, 255, 255, 255, false, pX, pY, a); end; end; end;