summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3af68bc)
raw | patch | inline | side by side (parent: 3af68bc)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Mon, 3 Jan 2022 19:19:39 +0000 (22:19 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Mon, 3 Jan 2022 19:19:39 +0000 (22:19 +0300) |
diff --git a/src/game/Doom2DF.lpr b/src/game/Doom2DF.lpr
index 500f7034b7b61fc85ddff1b797ca45c5de0edce7..47a40d4c92dd343e610958f852faf87c5a0e9a28 100644 (file)
--- a/src/game/Doom2DF.lpr
+++ b/src/game/Doom2DF.lpr
{$IFDEF ENABLE_HOLMES}
InitHolmes;
{$ENDIF}
+ r_Render_Load;
g_Game_Init;
{$IFNDEF HEADLESS}
g_Menu_Init;
g_GUI_Destroy;
g_Menu_Free;
{$ENDIF}
+ r_Render_Free;
{$IFDEF ENABLE_HOLMES}
FreeHolmes;
{$ENDIF}
index d12a9a24e4ba74789cfbe74fbaa0713e4b0c376f..acac0c61d3b8a87cc78bc9598d65d834ef6817c2 100644 (file)
--- a/src/game/g_textures.pas
+++ b/src/game/g_textures.pas
TLevelTextureArray = array of TLevelTexture;
+ TAnimationState = class{$IFDEF USE_MEMPOOL}(TPoolObject){$ENDIF}
+ private
+ mAlpha: Byte;
+ mBlending: Boolean;
+ mCounter: Byte; // Ñ÷åò÷èê îæèäàíèÿ ìåæäó êàäðàìè
+ mSpeed: Byte; // Âðåìÿ îæèäàíèÿ ìåæäó êàäðàìè
+ mCurrentFrame: Integer; // Òåêóùèé êàäð (íà÷èíàÿ ñ 0)
+ mLoop: Boolean; // Ïåðåõîäèòü íà ïåðâûé êàäð ïîñëå ïîñëåäíåãî?
+ mEnabled: Boolean; // Ðàáîòà ðàçðåøåíà?
+ mPlayed: Boolean; // Ïðîèãðàíà âñÿ õîòÿ áû ðàç?
+ mMinLength: Byte; // Îæèäàíèå ïîñëå ïðîèãðûâàíèÿ
+ mRevert: Boolean; // Ñìåíà êàäðîâ îáðàòíàÿ?
+
+ mLength: Integer;
+
+ public
+ constructor Create (aloop: Boolean; aspeed: Byte; len: Integer);
+ destructor Destroy (); override;
+
+ procedure reset ();
+ procedure update ();
+ procedure enable ();
+ procedure disable ();
+ procedure revert (r: Boolean);
+
+ procedure saveState (st: TStream);
+ procedure loadState (st: TStream);
+
+// function totalFrames (): Integer; inline;
+
+ public
+ property played: Boolean read mPlayed;
+ property enabled: Boolean read mEnabled;
+ property isReverse: Boolean read mRevert;
+ property loop: Boolean read mLoop write mLoop;
+ property speed: Byte read mSpeed write mSpeed;
+ property minLength: Byte read mMinLength write mMinLength;
+ property currentFrame: Integer read mCurrentFrame write mCurrentFrame;
+ property currentCounter: Byte read mCounter write mCounter;
+ property counter: Byte read mCounter;
+ property blending: Boolean read mBlending write mBlending;
+ property alpha: Byte read mAlpha write mAlpha;
+ end;
+
TAnimation = class{$IFDEF USE_MEMPOOL}(TPoolObject){$ENDIF}
private
mId: LongWord;
g_game, e_log, g_basic, g_console, wadreader, r_animations,
g_language, utils, xstreams;
+
+
+
+constructor TAnimationState.Create (aloop: Boolean; aspeed: Byte; len: Integer);
+begin
+ assert(len >= 0);
+ mLength := len;
+
+ mMinLength := 0;
+ mLoop := aloop;
+ mSpeed := aspeed;
+ mEnabled := true;
+ mCurrentFrame := 0;
+ mAlpha := 0;
+ mPlayed := false;
+end;
+
+destructor TAnimationState.Destroy;
+begin
+ inherited;
+end;
+
+procedure TAnimationState.update;
+begin
+ if (not mEnabled) then exit;
+
+ mCounter += 1;
+
+ if (mCounter >= mSpeed) then
+ begin
+ // Îæèäàíèå ìåæäó êàäðàìè çàêîí÷èëîñü
+ // Îáðàòíûé ïîðÿäîê êàäðîâ?
+ if mRevert then
+ begin
+ // Äîøëè äî êîíöà àíèìàöèè. Âîçìîæíî, æäåì åùå
+ if (mCurrentFrame = 0) then
+ begin
+ if (mLength * mSpeed + mCounter < mMinLength) then exit;
+ end;
+
+ mCurrentFrame -= 1;
+ mPlayed := (mCurrentFrame < 0);
+
+ // Ïîâòîðÿòü ëè àíèìàöèþ ïî êðóãó?
+ if mPlayed then
+ begin
+ if mLoop then
+ mCurrentFrame := mLength - 1
+ else
+ mCurrentFrame += 1
+ end;
+
+ mCounter := 0;
+ end
+ else
+ begin
+ // Ïðÿìîé ïîðÿäîê êàäðîâ
+ // Äîøëè äî êîíöà àíèìàöèè. Âîçìîæíî, æäåì åùå
+ if (mCurrentFrame = mLength - 1) then
+ begin
+ if (mLength * mSpeed + mCounter < mMinLength) then exit;
+ end;
+
+ mCurrentFrame += 1;
+ mPlayed := (mCurrentFrame > mLength - 1);
+
+ // Ïîâòîðÿòü ëè àíèìàöèþ ïî êðóãó?
+ if mPlayed then
+ begin
+ if mLoop then mCurrentFrame := 0 else mCurrentFrame -= 1;
+ end;
+
+ mCounter := 0;
+ end;
+ end;
+end;
+
+procedure TAnimationState.reset;
+begin
+ if mRevert then
+ mCurrentFrame := mLength - 1
+ else
+ mCurrentFrame := 0;
+ mCounter := 0;
+ mPlayed := false
+end;
+
+procedure TAnimationState.disable;
+begin
+ mEnabled := false
+end;
+
+procedure TAnimationState.enable;
+begin
+ mEnabled := true
+end;
+
+procedure TAnimationState.revert (r: Boolean);
+begin
+ mRevert := r;
+ reset
+end;
+
+procedure TAnimationState.saveState (st: TStream);
+begin
+ if (st = nil) then exit;
+
+ utils.writeSign(st, 'ANIM');
+ utils.writeInt(st, Byte(0)); // version
+ // Ñ÷åò÷èê îæèäàíèÿ ìåæäó êàäðàìè
+ utils.writeInt(st, Byte(mCounter));
+ // Òåêóùèé êàäð
+ utils.writeInt(st, LongInt(mCurrentFrame));
+ // Ïðîèãðàíà ëè àíèìàöèÿ öåëèêîì
+ utils.writeBool(st, mPlayed);
+ // Alpha-êàíàë âñåé òåêñòóðû
+ utils.writeInt(st, Byte(mAlpha));
+ // Ðàçìûòèå òåêñòóðû
+ utils.writeInt(st, Byte(mBlending));
+ // Âðåìÿ îæèäàíèÿ ìåæäó êàäðàìè
+ utils.writeInt(st, Byte(mSpeed));
+ // Çàöèêëåíà ëè àíèìàöèÿ
+ utils.writeBool(st, mLoop);
+ // Âêëþ÷åíà ëè
+ utils.writeBool(st, mEnabled);
+ // Îæèäàíèå ïîñëå ïðîèãðûâàíèÿ
+ utils.writeInt(st, Byte(mMinLength));
+ // Îáðàòíûé ëè ïîðÿäîê êàäðîâ
+ utils.writeBool(st, mRevert);
+end;
+
+
+procedure TAnimationState.loadState (st: TStream);
+begin
+ if (st = nil) then exit;
+
+ if not utils.checkSign(st, 'ANIM') then raise XStreamError.Create('animation chunk expected');
+ if (utils.readByte(st) <> 0) then raise XStreamError.Create('invalid animation chunk version');
+ // Ñ÷åò÷èê îæèäàíèÿ ìåæäó êàäðàìè
+ mCounter := utils.readByte(st);
+ // Òåêóùèé êàäð
+ mCurrentFrame := utils.readLongInt(st);
+ // Ïðîèãðàíà ëè àíèìàöèÿ öåëèêîì
+ mPlayed := utils.readBool(st);
+ // Alpha-êàíàë âñåé òåêñòóðû
+ mAlpha := utils.readByte(st);
+ // Ðàçìûòèå òåêñòóðû
+ mBlending := utils.readBool(st);
+ // Âðåìÿ îæèäàíèÿ ìåæäó êàäðàìè
+ mSpeed := utils.readByte(st);
+ // Çàöèêëåíà ëè àíèìàöèÿ
+ mLoop := utils.readBool(st);
+ // Âêëþ÷åíà ëè
+ mEnabled := utils.readBool(st);
+ // Îæèäàíèå ïîñëå ïðîèãðûâàíèÿ
+ mMinLength := utils.readByte(st);
+ // Îáðàòíûé ëè ïîðÿäîê êàäðîâ
+ mRevert := utils.readBool(st);
+end;
+
+
+
+
+
+
constructor TAnimation.Create (aframesID: LongWord; aloop: Boolean; aspeed: Byte);
begin
if (aframesID >= Length(framesArray)) then
diff --git a/src/game/g_weapons.pas b/src/game/g_weapons.pas
index bf9a0953c5cd188ff87fba09f52609c084a243be..fb89fcc3a1f6b09871823aedd1d0183abc827243 100644 (file)
--- a/src/game/g_weapons.pas
+++ b/src/game/g_weapons.pas
SpawnerUID: Word;
Triggers: DWArray;
Obj: TObj;
- Animation: TAnimation;
- TextureID: DWORD;
+ Animation: TAnimationState;
Timeout: DWORD;
Stopped: Byte;
WP_FIRST = WEAPON_KASTET;
WP_LAST = WEAPON_FLAMETHROWER;
-
var
gwep_debug_fast_trace: Boolean = true;
function g_Weapon_CreateShot(I: Integer; ShotType: Byte; Spawner, TargetUID: Word; X, Y, XV, YV: Integer): LongWord;
var
find_id: DWord;
- FramesID: DWORD = 0;
begin
if I < 0 then
find_id := FindShot()
Animation := nil;
Triggers := nil;
ShotType := WEAPON_ROCKETLAUNCHER;
- g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID);
end;
end;
Triggers := nil;
ShotType := WEAPON_PLASMA;
- g_Frames_Get(FramesID, 'FRAMES_WEAPON_PLASMA');
- Animation := TAnimation.Create(FramesID, True, 5);
+ Animation := TAnimationState.Create(True, 5, 2); // !!! put values into table
end;
end;
Triggers := nil;
ShotType := WEAPON_BFG;
- g_Frames_Get(FramesID, 'FRAMES_WEAPON_BFG');
- Animation := TAnimation.Create(FramesID, True, 6);
+ Animation := TAnimationState.Create(True, 6, 2); // !!! put values into table
end;
end;
Triggers := nil;
ShotType := WEAPON_FLAMETHROWER;
- Animation := nil;
- TextureID := 0;
- g_Frames_Get(TextureID, 'FRAMES_FLAME');
+ // Animation := TAnimationState.Create(True, 6, 0); // drawed as gfx
end;
end;
Triggers := nil;
ShotType := WEAPON_IMP_FIRE;
- g_Frames_Get(FramesID, 'FRAMES_WEAPON_IMPFIRE');
- Animation := TAnimation.Create(FramesID, True, 4);
+ Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
end;
end;
Triggers := nil;
ShotType := WEAPON_CACO_FIRE;
- g_Frames_Get(FramesID, 'FRAMES_WEAPON_CACOFIRE');
- Animation := TAnimation.Create(FramesID, True, 4);
+ Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
end;
end;
Triggers := nil;
ShotType := WEAPON_MANCUB_FIRE;
- g_Frames_Get(FramesID, 'FRAMES_WEAPON_MANCUBFIRE');
- Animation := TAnimation.Create(FramesID, True, 4);
+ Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
end;
end;
Triggers := nil;
ShotType := WEAPON_BARON_FIRE;
- g_Frames_Get(FramesID, 'FRAMES_WEAPON_BARONFIRE');
- Animation := TAnimation.Create(FramesID, True, 4);
+ Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
end;
end;
Triggers := nil;
ShotType := WEAPON_BSP_FIRE;
- g_Frames_Get(FramesID, 'FRAMES_WEAPON_BSPFIRE');
- Animation := TAnimation.Create(FramesID, True, 4);
+ Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
end;
end;
Triggers := nil;
ShotType := WEAPON_SKEL_FIRE;
target := TargetUID;
- g_Frames_Get(FramesID, 'FRAMES_WEAPON_SKELFIRE');
- Animation := TAnimation.Create(FramesID, True, 5);
+ Animation := TAnimationState.Create(True, 5, 2); // !!! put values into table
end;
end;
end;
g_Sound_CreateWADEx('SOUND_PLAYER_SHELL1', GameWAD+':SOUNDS\SHELL1');
g_Sound_CreateWADEx('SOUND_PLAYER_SHELL2', GameWAD+':SOUNDS\SHELL2');
- g_Texture_CreateWADEx('TEXTURE_WEAPON_ROCKET', GameWAD+':TEXTURES\BROCKET');
- g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_SKELFIRE', GameWAD+':TEXTURES\BSKELFIRE', 64, 16, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BFG', GameWAD+':TEXTURES\BBFG', 64, 64, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_PLASMA', GameWAD+':TEXTURES\BPLASMA', 16, 16, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_IMPFIRE', GameWAD+':TEXTURES\BIMPFIRE', 16, 16, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BSPFIRE', GameWAD+':TEXTURES\BBSPFIRE', 16, 16, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_CACOFIRE', GameWAD+':TEXTURES\BCACOFIRE', 16, 16, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BARONFIRE', GameWAD+':TEXTURES\BBARONFIRE', 64, 16, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_MANCUBFIRE', GameWAD+':TEXTURES\BMANCUBFIRE', 64, 32, 2);
- g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_ROCKET', GameWAD+':TEXTURES\EROCKET', 128, 128, 6);
- g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_SKELFIRE', GameWAD+':TEXTURES\ESKELFIRE', 64, 64, 3);
- g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BFG', GameWAD+':TEXTURES\EBFG', 128, 128, 6);
- g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_IMPFIRE', GameWAD+':TEXTURES\EIMPFIRE', 64, 64, 3);
- g_Frames_CreateWAD(nil, 'FRAMES_BFGHIT', GameWAD+':TEXTURES\BFGHIT', 64, 64, 4);
- g_Frames_CreateWAD(nil, 'FRAMES_FIRE', GameWAD+':TEXTURES\FIRE', 64, 128, 8);
- g_Frames_CreateWAD(nil, 'FRAMES_FLAME', GameWAD+':TEXTURES\FLAME', 32, 32, 11);
- g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_PLASMA', GameWAD+':TEXTURES\EPLASMA', 32, 32, 4, True);
- g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BSPFIRE', GameWAD+':TEXTURES\EBSPFIRE', 32, 32, 5);
- g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_CACOFIRE', GameWAD+':TEXTURES\ECACOFIRE', 64, 64, 3);
- g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BARONFIRE', GameWAD+':TEXTURES\EBARONFIRE', 64, 64, 3);
- g_Frames_CreateWAD(nil, 'FRAMES_SMOKE', GameWAD+':TEXTURES\SMOKE', 32, 32, 10, False);
-
g_Texture_CreateWADEx('TEXTURE_SHELL_BULLET', GameWAD+':TEXTURES\EBULLET');
g_Texture_CreateWADEx('TEXTURE_SHELL_SHELL', GameWAD+':TEXTURES\ESHELL');
g_Sound_Delete('SOUND_PLAYER_CASING2');
g_Sound_Delete('SOUND_PLAYER_SHELL1');
g_Sound_Delete('SOUND_PLAYER_SHELL2');
-
- g_Texture_Delete('TEXTURE_WEAPON_ROCKET');
- g_Frames_DeleteByName('FRAMES_WEAPON_BFG');
- g_Frames_DeleteByName('FRAMES_WEAPON_PLASMA');
- g_Frames_DeleteByName('FRAMES_WEAPON_IMPFIRE');
- g_Frames_DeleteByName('FRAMES_WEAPON_BSPFIRE');
- g_Frames_DeleteByName('FRAMES_WEAPON_CACOFIRE');
- g_Frames_DeleteByName('FRAMES_WEAPON_MANCUBFIRE');
- g_Frames_DeleteByName('FRAMES_EXPLODE_ROCKET');
- g_Frames_DeleteByName('FRAMES_EXPLODE_BFG');
- g_Frames_DeleteByName('FRAMES_EXPLODE_IMPFIRE');
- g_Frames_DeleteByName('FRAMES_BFGHIT');
- g_Frames_DeleteByName('FRAMES_FIRE');
- g_Frames_DeleteByName('FRAMES_EXPLODE_PLASMA');
- g_Frames_DeleteByName('FRAMES_EXPLODE_BSPFIRE');
- g_Frames_DeleteByName('FRAMES_EXPLODE_CACOFIRE');
- g_Frames_DeleteByName('FRAMES_SMOKE');
- g_Frames_DeleteByName('FRAMES_WEAPON_BARONFIRE');
- g_Frames_DeleteByName('FRAMES_EXPLODE_BARONFIRE');
end;
Animation := nil;
triggers := nil;
- g_Texture_Get('TEXTURE_WEAPON_ROCKET', TextureID);
end;
Shots[find_id].SpawnerUID := SpawnerUID;
procedure g_Weapon_revf(x, y, xd, yd: Integer; SpawnerUID, TargetUID: Word;
WID: Integer = -1; Silent: Boolean = False);
var
- find_id, FramesID: DWORD;
+ find_id: DWORD;
dx, dy: Integer;
begin
if WID < 0 then
triggers := nil;
target := TargetUID;
- g_Frames_Get(FramesID, 'FRAMES_WEAPON_SKELFIRE');
- Animation := TAnimation.Create(FramesID, True, 5);
+ Animation := TAnimationState.Create(True, 5, 2); // !!! put values into table
end;
Shots[find_id].SpawnerUID := SpawnerUID;
procedure g_Weapon_plasma(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
Silent: Boolean = False);
var
- find_id, FramesID: DWORD;
+ find_id: DWORD;
dx, dy: Integer;
begin
if WID < 0 then
throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
triggers := nil;
- g_Frames_Get(FramesID, 'FRAMES_WEAPON_PLASMA');
- Animation := TAnimation.Create(FramesID, True, 5);
+ Animation := TAnimationState.Create(True, 5, 2); // !!! put values into table
end;
Shots[find_id].SpawnerUID := SpawnerUID;
triggers := nil;
Animation := nil;
- TextureID := 0;
- g_Frames_Get(TextureID, 'FRAMES_FLAME');
end;
Shots[find_id].SpawnerUID := SpawnerUID;
procedure g_Weapon_ball1(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
Silent: Boolean = False);
var
- find_id, FramesID: DWORD;
+ find_id: DWORD;
dx, dy: Integer;
begin
if WID < 0 then
throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
triggers := nil;
- g_Frames_Get(FramesID, 'FRAMES_WEAPON_IMPFIRE');
- Animation := TAnimation.Create(FramesID, True, 4);
+ Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
end;
Shots[find_id].SpawnerUID := SpawnerUID;
procedure g_Weapon_ball2(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
Silent: Boolean = False);
var
- find_id, FramesID: DWORD;
+ find_id: DWORD;
dx, dy: Integer;
begin
if WID < 0 then
throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
triggers := nil;
- g_Frames_Get(FramesID, 'FRAMES_WEAPON_CACOFIRE');
- Animation := TAnimation.Create(FramesID, True, 4);
+ Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
end;
Shots[find_id].SpawnerUID := SpawnerUID;
procedure g_Weapon_ball7(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
Silent: Boolean = False);
var
- find_id, FramesID: DWORD;
+ find_id: DWORD;
dx, dy: Integer;
begin
if WID < 0 then
throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
triggers := nil;
- g_Frames_Get(FramesID, 'FRAMES_WEAPON_BARONFIRE');
- Animation := TAnimation.Create(FramesID, True, 4);
+ Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
end;
Shots[find_id].SpawnerUID := SpawnerUID;
procedure g_Weapon_aplasma(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
Silent: Boolean = False);
var
- find_id, FramesID: DWORD;
+ find_id: DWORD;
dx, dy: Integer;
begin
if WID < 0 then
triggers := nil;
- g_Frames_Get(FramesID, 'FRAMES_WEAPON_BSPFIRE');
- Animation := TAnimation.Create(FramesID, True, 4);
+ Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
end;
Shots[find_id].SpawnerUID := SpawnerUID;
procedure g_Weapon_manfire(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
Silent: Boolean = False);
var
- find_id, FramesID: DWORD;
+ find_id: DWORD;
dx, dy: Integer;
begin
if WID < 0 then
triggers := nil;
- g_Frames_Get(FramesID, 'FRAMES_WEAPON_MANCUBFIRE');
- Animation := TAnimation.Create(FramesID, True, 4);
+ Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
end;
Shots[find_id].SpawnerUID := SpawnerUID;
procedure g_Weapon_bfgshot(x, y, xd, yd: Integer; SpawnerUID: Word; WID: Integer = -1;
Silent: Boolean = False);
var
- find_id, FramesID: DWORD;
+ find_id: DWORD;
dx, dy: Integer;
begin
if WID < 0 then
throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16);
triggers := nil;
- g_Frames_Get(FramesID, 'FRAMES_WEAPON_BFG');
- Animation := TAnimation.Create(FramesID, True, 6);
+ Animation := TAnimationState.Create(True, 6, 2); // !!! put values into table
end;
Shots[find_id].SpawnerUID := SpawnerUID;
Anim: TAnimation;
t: DWArray;
st: Word;
+ TextureID: DWORD = DWORD(-1);
s: String;
o: TObj;
spl: Boolean;
cx := Obj.X + (Obj.Rect.Width div 2);
cy := Obj.Y + (Obj.Rect.Height div 2);
+ TextureID := DWORD(-1); // !!!
+
case ShotType of
WEAPON_ROCKETLAUNCHER, WEAPON_SKEL_FIRE: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
begin
if (gTime mod LongWord(tf) = 0) then
begin
+ g_Frames_Get(TextureID, 'FRAMES_FLAME');
Anim := TAnimation.Create(TextureID, False, 2 + Random(2));
Anim.Alpha := 0;
case Stopped of
procedure g_Weapon_LoadState (st: TStream);
var
count, tc, i, j: Integer;
- dw: LongWord;
begin
if (st = nil) then exit;
Shots[i].Stopped := utils.readByte(st);
// Óñòàíîâêà òåêñòóðû èëè àíèìàöèè
- Shots[i].TextureID := DWORD(-1);
Shots[i].Animation := nil;
case Shots[i].ShotType of
WEAPON_ROCKETLAUNCHER, WEAPON_SKEL_FIRE:
begin
- g_Texture_Get('TEXTURE_WEAPON_ROCKET', Shots[i].TextureID);
end;
WEAPON_PLASMA:
begin
- g_Frames_Get(dw, 'FRAMES_WEAPON_PLASMA');
- Shots[i].Animation := TAnimation.Create(dw, True, 5);
+ Shots[i].Animation := TAnimationState.Create(True, 5, 2); // !!! put values into table
end;
WEAPON_BFG:
begin
- g_Frames_Get(dw, 'FRAMES_WEAPON_BFG');
- Shots[i].Animation := TAnimation.Create(dw, True, 6);
+ Shots[i].Animation := TAnimationState.Create(True, 6, 2); // !!! put values into table
end;
WEAPON_IMP_FIRE:
begin
- g_Frames_Get(dw, 'FRAMES_WEAPON_IMPFIRE');
- Shots[i].Animation := TAnimation.Create(dw, True, 4);
+ Shots[i].Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
end;
WEAPON_BSP_FIRE:
begin
- g_Frames_Get(dw, 'FRAMES_WEAPON_BSPFIRE');
- Shots[i].Animation := TAnimation.Create(dw, True, 4);
+ Shots[i].Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
end;
WEAPON_CACO_FIRE:
begin
- g_Frames_Get(dw, 'FRAMES_WEAPON_CACOFIRE');
- Shots[i].Animation := TAnimation.Create(dw, True, 4);
+ Shots[i].Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
end;
WEAPON_BARON_FIRE:
begin
- g_Frames_Get(dw, 'FRAMES_WEAPON_BARONFIRE');
- Shots[i].Animation := TAnimation.Create(dw, True, 4);
+ Shots[i].Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
end;
WEAPON_MANCUB_FIRE:
begin
- g_Frames_Get(dw, 'FRAMES_WEAPON_MANCUBFIRE');
- Shots[i].Animation := TAnimation.Create(dw, True, 4);
+ Shots[i].Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table
end;
end;
end;
cx, cy: Integer;
Anim: TAnimation;
s: string;
+ TextureID: DWORD = DWORD(-1);
begin
if Shots = nil then
Exit;
index 1b634051753716d481178091eaf2134a6bbe88bb..156869b82640047a1f888265e1c36887b932736a 100644 (file)
procedure r_Animation_Draw (t: TAnimation; x, y: Integer; mirror: TMirrorType);
procedure r_Animation_DrawEx (t: TAnimation; x, y: Integer; mirror: TMirrorType; rpoint: TDFPoint; angle: SmallInt);
+ procedure r_AnimationState_Draw (TID: DWORD; t: TAnimationState; x, y: Integer; mirror: TMirrorType);
+ procedure r_AnimationState_DrawEx (FID: DWORD; t: TAnimationState; x, y: Integer; mirror: TMirrorType; rpoint: TDFPoint; angle: SmallInt);
+
function g_CreateFramesImg (ia: TDynImageDataArray; ID: PDWORD; const Name: AnsiString; BackAnimation: Boolean = false): Boolean;
function g_Frames_CreateWAD (ID: PDWORD; const Name, Resource: AnsiString; mWidth, mHeight, mCount: Word; BackAnimation: Boolean=false): Boolean;
e_DrawAdv(framesArray[t.id].TexturesID[t.currentFrame], x, y, t.alpha, true, t.blending, angle, @rpoint, mirror)
end;
+ procedure r_AnimationState_Draw (TID: DWORD; t: TAnimationState; x, y: Integer; mirror: TMirrorType);
+ begin
+ if t.enabled then
+ e_DrawAdv(framesArray[TID].TexturesID[t.currentFrame], x, y, t.alpha, true, t.blending, 0, nil, mirror)
+ end;
+
+ procedure r_AnimationState_DrawEx (FID: DWORD; t: TAnimationState; x, y: Integer; mirror: TMirrorType; rpoint: TDFPoint; angle: SmallInt);
+ begin
+ if t.enabled then
+ e_DrawAdv(framesArray[FID].TexturesID[t.currentFrame], x, y, t.alpha, true, t.blending, angle, @rpoint, mirror)
+ end;
+
function allocFrameSlot (): LongWord;
var
f: integer;
index b768075d9dd1ecf0c84e12c92445f0f354e0dfa2..4db3f641a7f4376825cfdaa2881d1398fd4dbed0 100644 (file)
procedure r_Render_Finalize;
procedure r_Render_Resize (w, h: Integer);
+ procedure r_Render_Load;
+ procedure r_Render_Free;
+
procedure r_Render_Apply;
implementation
SysUtils, Classes, Math,
e_log, g_system,
g_game, g_options, g_console,
- r_window, r_graphics, r_console, r_playermodel
+ r_window, r_graphics, r_console, r_playermodel,
+ r_weapons
;
var
end
end;
+ procedure r_Render_Load;
+ begin
+ r_Weapon_Load;
+ end;
+
+ procedure r_Render_Free;
+ begin
+ r_Weapon_Free;
+ end;
+
procedure r_Render_Initialize;
begin
if sys_SetDisplayMode(gRC_Width, gRC_Height, gBPP, gRC_FullScreen, gRC_Maximized) = False then
index 94d1d4ade21ae5e423c512a020269bc8d431763d..648ff507201165d6cdcd9ad20b5017dbd61b7b6b 100644 (file)
interface
+ procedure r_Weapon_Load;
+ procedure r_Weapon_Free;
procedure r_Weapon_Draw;
implementation
uses
SysUtils, Classes, Math,
MAPDEF,
- r_graphics, r_animations,
- g_base, g_basic, g_game,
+ r_graphics, r_animations, r_textures,
+ g_base, g_basic, g_game, g_options,
g_weapons
;
+ var
+ ShotTexture, ShotFrames: array [WEAPON_KASTET..WEAPON_SKEL_FIRE] of DWORD;
+
+ procedure r_Weapon_Load;
+ begin
+ g_Texture_CreateWADEx('TEXTURE_WEAPON_ROCKET', GameWAD+':TEXTURES\BROCKET');
+ g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_SKELFIRE', GameWAD+':TEXTURES\BSKELFIRE', 64, 16, 2);
+ g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BFG', GameWAD+':TEXTURES\BBFG', 64, 64, 2);
+ g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_PLASMA', GameWAD+':TEXTURES\BPLASMA', 16, 16, 2);
+ g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_IMPFIRE', GameWAD+':TEXTURES\BIMPFIRE', 16, 16, 2);
+ g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BSPFIRE', GameWAD+':TEXTURES\BBSPFIRE', 16, 16, 2);
+ g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_CACOFIRE', GameWAD+':TEXTURES\BCACOFIRE', 16, 16, 2);
+ g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BARONFIRE', GameWAD+':TEXTURES\BBARONFIRE', 64, 16, 2);
+ g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_MANCUBFIRE', GameWAD+':TEXTURES\BMANCUBFIRE', 64, 32, 2);
+ g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_ROCKET', GameWAD+':TEXTURES\EROCKET', 128, 128, 6);
+ g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_SKELFIRE', GameWAD+':TEXTURES\ESKELFIRE', 64, 64, 3);
+ g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BFG', GameWAD+':TEXTURES\EBFG', 128, 128, 6);
+ g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_IMPFIRE', GameWAD+':TEXTURES\EIMPFIRE', 64, 64, 3);
+ g_Frames_CreateWAD(nil, 'FRAMES_BFGHIT', GameWAD+':TEXTURES\BFGHIT', 64, 64, 4);
+ g_Frames_CreateWAD(nil, 'FRAMES_FIRE', GameWAD+':TEXTURES\FIRE', 64, 128, 8);
+ g_Frames_CreateWAD(nil, 'FRAMES_FLAME', GameWAD+':TEXTURES\FLAME', 32, 32, 11);
+ g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_PLASMA', GameWAD+':TEXTURES\EPLASMA', 32, 32, 4, True);
+ g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BSPFIRE', GameWAD+':TEXTURES\EBSPFIRE', 32, 32, 5);
+ g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_CACOFIRE', GameWAD+':TEXTURES\ECACOFIRE', 64, 64, 3);
+ g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BARONFIRE', GameWAD+':TEXTURES\EBARONFIRE', 64, 64, 3);
+ g_Frames_CreateWAD(nil, 'FRAMES_SMOKE', GameWAD+':TEXTURES\SMOKE', 32, 32, 10, False);
+
+ g_Texture_CreateWADEx('TEXTURE_SHELL_BULLET', GameWAD+':TEXTURES\EBULLET');
+ g_Texture_CreateWADEx('TEXTURE_SHELL_SHELL', GameWAD+':TEXTURES\ESHELL');
+
+ (* WEAPON_ROCKETLAUNCHER *)
+ g_Texture_Get('TEXTURE_WEAPON_ROCKET', ShotTexture[WEAPON_ROCKETLAUNCHER]);
+
+ (* WEAPON_PLASMA *)
+ g_Frames_Get(ShotFrames[WEAPON_PLASMA], 'FRAMES_WEAPON_PLASMA');
+ // Animation := TAnimation.Create(FramesID, True, 5);
+
+ (* WEAPON_BFG *)
+ g_Frames_Get(ShotFrames[WEAPON_BFG], 'FRAMES_WEAPON_BFG');
+ // Animation := TAnimation.Create(FramesID, True, 6);
+
+ (* WEAPON_FLAMETHROWER *)
+ //g_Frames_Get(ShotTexture[WEAPON_FLAMETHROWER], 'FRAMES_FLAME');
+ //g_Frames_Get(ShotFrames[WEAPON_FLAMETHROWER], 'FRAMES_FLAME');
+
+ (* WEAPON_IMP_FIRE *)
+ g_Frames_Get(ShotFrames[WEAPON_IMP_FIRE], 'FRAMES_WEAPON_IMPFIRE');
+ // Animation := TAnimation.Create(FramesID, True, 4);
+
+ (* WEAPON_CACO_FIRE *)
+ g_Frames_Get(ShotFrames[WEAPON_CACO_FIRE], 'FRAMES_WEAPON_CACOFIRE');
+ // Animation := TAnimation.Create(FramesID, True, 4);
+
+ (* WEAPON_MANCUB_FIRE *)
+ g_Frames_Get(ShotFrames[WEAPON_MANCUB_FIRE], 'FRAMES_WEAPON_MANCUBFIRE');
+ // Animation := TAnimation.Create(FramesID, True, 4);
+
+ (* WEAPON_BARON_FIRE *)
+ g_Frames_Get(ShotFrames[WEAPON_BARON_FIRE], 'FRAMES_WEAPON_BARONFIRE');
+ // Animation := TAnimation.Create(FramesID, True, 4);
+
+ (* WEAPON_BSP_FIRE *)
+ g_Frames_Get(ShotFrames[WEAPON_BSP_FIRE], 'FRAMES_WEAPON_BSPFIRE');
+ // Animation := TAnimation.Create(FramesID, True, 4);
+
+ (* WEAPON_SKEL_FIRE *)
+ g_Frames_Get(ShotFrames[WEAPON_SKEL_FIRE], 'FRAMES_WEAPON_SKELFIRE');
+ // Animation := TAnimation.Create(FramesID, True, 5);
+ end;
+
+ procedure r_Weapon_Free;
+ begin
+ g_Texture_Delete('TEXTURE_WEAPON_ROCKET');
+ g_Frames_DeleteByName('FRAMES_WEAPON_BFG');
+ g_Frames_DeleteByName('FRAMES_WEAPON_PLASMA');
+ g_Frames_DeleteByName('FRAMES_WEAPON_IMPFIRE');
+ g_Frames_DeleteByName('FRAMES_WEAPON_BSPFIRE');
+ g_Frames_DeleteByName('FRAMES_WEAPON_CACOFIRE');
+ g_Frames_DeleteByName('FRAMES_WEAPON_MANCUBFIRE');
+ g_Frames_DeleteByName('FRAMES_EXPLODE_ROCKET');
+ g_Frames_DeleteByName('FRAMES_EXPLODE_BFG');
+ g_Frames_DeleteByName('FRAMES_EXPLODE_IMPFIRE');
+ g_Frames_DeleteByName('FRAMES_BFGHIT');
+ g_Frames_DeleteByName('FRAMES_FIRE');
+ g_Frames_DeleteByName('FRAMES_EXPLODE_PLASMA');
+ g_Frames_DeleteByName('FRAMES_EXPLODE_BSPFIRE');
+ g_Frames_DeleteByName('FRAMES_EXPLODE_CACOFIRE');
+ g_Frames_DeleteByName('FRAMES_SMOKE');
+ g_Frames_DeleteByName('FRAMES_WEAPON_BARONFIRE');
+ g_Frames_DeleteByName('FRAMES_EXPLODE_BARONFIRE');
+ end;
+
procedure r_Weapon_Draw;
var i, fX, fY, xx, yy: Integer; a: SmallInt; p: TDFPoint;
begin
if Animation <> nil then
begin
if Shots[i].ShotType in [WEAPON_BARON_FIRE, WEAPON_MANCUB_FIRE, WEAPON_SKEL_FIRE] then
- r_Animation_DrawEx(Animation, fX, fY, TMirrorType.None, p, a)
+ r_AnimationState_DrawEx(ShotFrames[Shots[i].ShotType], Animation, fX, fY, TMirrorType.None, p, a)
else
- r_Animation_Draw(Animation, fX, fY, TMirrorType.None);
+ r_AnimationState_Draw(ShotFrames[Shots[i].ShotType], Animation, fX, fY, TMirrorType.None);
end
- else if TextureID <> 0 then
+ else if ShotTexture[Shots[i].ShotType] <> 0 then
begin
if (Shots[i].ShotType = WEAPON_ROCKETLAUNCHER) then
- e_DrawAdv(TextureID, fX, fY, 0, True, False, a, @p, TMirrorType.None)
+ e_DrawAdv(ShotTexture[Shots[i].ShotType], fX, fY, 0, True, False, a, @p, TMirrorType.None)
else if (Shots[i].ShotType <> WEAPON_FLAMETHROWER) then
- e_Draw(TextureID, fX, fY, 0, True, False);
+ e_Draw(ShotTexture[Shots[i].ShotType], fX, fY, 0, True, False);
end;
if g_debug_Frames then