Changeset 57


Ignore:
Timestamp:
Dec 25, 2022, 9:29:43 AM (2 years ago)
Author:
chronos
Message:
  • Modified: Start new round in delay after tank explosion.
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.pas

    r55 r57  
    191191procedure TFormMain.AShowMapExecute(Sender: TObject);
    192192begin
    193   if not Assigned(FormMap) then FormMap := TFormMap.Create(nil);
     193  if not Assigned(FormMap) then FormMap := TFormMap.Create(Self);
    194194  FormMap.Show;
    195195end;
     
    225225procedure TFormMain.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState
    226226  );
     227const
     228  KeyF11 = 112;
     229var
     230  I: Integer;
    227231begin
    228232  Engine.KeyBoard.KeyState[Key] := False;
     233  {$IFDEF DEBUG}
     234  if Key = KeyF11 then begin
     235    // Destroy first alive player
     236    for I := 0 to Engine.Players.Count - 1 do
     237    with Engine.Players[I] do begin
     238      if not Exploded then begin
     239        Energy := -100;
     240        Break;
     241      end;
     242    end;
     243  end;
     244  {$ENDIF}
    229245end;
    230246
  • trunk/UEngine.pas

    r56 r57  
    66  Dialogs, Classes, SysUtils, Graphics, SpecializedMatrix,
    77  IntfGraphics, FPImage, LCLType, SpecializedBitmap, GraphType, Math, URectangle,
    8   Syncobjs, UThreading, Forms, DateUtils, UAudioSystem, XMLConf, DOM, fgl;
     8  Syncobjs, UThreading, Forms, DateUtils, UAudioSystem, XMLConf, DOM,
     9  Generics.Collections;
    910
    1011const
     
    2728  PlayerHouseSize = 30;
    2829  PlayerHouseDoorSize = 8;
     30  ExplosionDelay = 2;
    2931
    3032type
     
    5658  end;
    5759
    58   TBullets = class(TFPGObjectList<TBullet>)
     60  TBullets = class(TObjectList<TBullet>)
    5961  end;
    6062
     
    7173  { TTanks }
    7274
    73   TTanks = class(TFPGObjectList<TTank>)
     75  TTanks = class(TObjectList<TTank>)
    7476    procedure Assign(Source: TTanks);
    7577  end;
     
    102104    Dig: Boolean;
    103105    LastPos: TPoint;
     106    ExplosionPending: Boolean;
     107    ExplosionTime: TDateTime;
    104108    procedure SetExploded(const AValue: Boolean);
    105109    function ShowTankProc(Item1, Item2: Byte): Byte;
     
    149153  { TPlayers }
    150154
    151   TPlayers = class(TFPGObjectList<TPlayer>)
     155  TPlayers = class(TObjectList<TPlayer>)
    152156    Engine: TEngine;
    153157    function AddNew: TPlayer;
     
    169173  { TMatters }
    170174
    171   TMatters = class(TFPGObjectList<TMatter>)
     175  TMatters = class(TObjectList<TMatter>)
    172176    function AddNew: TMatter;
    173177  end;
     
    238242    PlayerPool: TPlayers;
    239243    Players: TPlayers;
    240     DigMasks: TFPGObjectList<TMatrixByte>;
     244    DigMasks: TObjectList<TMatrixByte>;
    241245    Lock: TCriticalSection;
    242246    CurrentRound: Integer;
     
    714718begin
    715719  // Check energy
    716   if not Engine.IsInsideHouses(Position) then begin
    717     Energy := Energy - 1 / EnergySteps;
     720  if not ExplosionPending then begin
     721    if not Engine.IsInsideHouses(Position) then begin
     722      Energy := Energy - 1 / EnergySteps;
     723    end else begin
     724      if not Exploded then
     725        Energy := Energy + 5 * 1 / EnergySteps;
     726      if Energy > 1 then Energy := 1;
     727    end;
    718728    if Energy <= 0 then begin
    719729      Energy := 0;
    720730      Explosion(Position, ExplosionRange);
    721731      Exploded := True;
     732      ExplosionPending := True;
     733      ExplosionTime := Now;
    722734      Engine.AudioExplode.Play;
    723735    end;
    724   end else begin
    725     if not Exploded then
    726       Energy := Energy + 5 * 1 / EnergySteps;
    727     if Energy > 1 then Energy := 1;
     736  end;
     737  if ExplosionPending and (SecondOf(Now - ExplosionTime) > ExplosionDelay) then begin
     738    ExplosionPending := False;
     739    Synchronize(Engine.CheckGameEnd);
    728740  end;
    729741  if LastEnergy <> Energy then begin
     
    907919  Energy := 0;
    908920  Shield := 0;
    909   //Synchronize(Engine.CheckGameEnd);
    910921end;
    911922
     
    936947      Round(World.Surface.Count.Y * 0.2) + Random(Round(World.Surface.Count.Y * 0.6)));
    937948  Exploded := False;
     949  ExplosionPending := False;
    938950  Bullets.Clear;
    939951  Energy := 1;
     
    15401552  AudioExplode.Open;
    15411553  InitPlayerPool;
    1542   DigMasks := TFPGObjectList<TMatrixByte>.Create;
     1554  DigMasks := TObjectList<TMatrixByte>.Create;
    15431555  InitDigMasks;
    15441556  Redraw;
     
    16211633  I: Integer;
    16221634begin
    1623   Active := False;
    16241635  World.Generate;
    16251636
     
    16281639  ClearBackground := True;
    16291640  Redraw;
    1630   Active := True;
    16311641end;
    16321642
  • trunk/tunneler.lpr

    r55 r57  
    3232  Application.CreateForm(TCore, Core);
    3333  Application.CreateForm(TFormMain, FormMain);
    34   Application.CreateForm(TFormMap, FormMap);
    3534  {$IFDEF DEBUG}
    3635  {$ENDIF}
Note: See TracChangeset for help on using the changeset viewer.