Changeset 67


Ignore:
Timestamp:
Jan 8, 2023, 12:29:51 AM (23 months ago)
Author:
chronos
Message:
  • Fixed: Speed of shield hit and refresh.
  • Fixed: Game statistics. Track meters dug, meters travelled, shots count and shots hit.
  • Fixed: Cleanup bullets before new round.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.pas

    r64 r67  
    44
    55uses
    6   XMLConf, Classes, SysUtils, FileUtil, Forms, Controls, Graphics,
     6  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, LCLType,
    77  Dialogs, ExtCtrls, ComCtrls, Menus, ActnList, UEngine, UPlatform, Math,
    88  DateUtils, GraphType, UPersistentForm, UApplicationInfo, UTranslator,
    9   LCLType, URegistry, UAboutDialog, DOM;
     9  URegistry, UAboutDialog;
    1010
    1111type
  • trunk/Languages/Tunneler.cs.po

    r62 r67  
    190190msgstr "Instrukce"
    191191
     192#: uengine.smetersdug
     193msgid "Meters dug"
     194msgstr ""
     195
     196#: uengine.smeterstravelled
     197msgid "Meters travelled"
     198msgstr ""
     199
    192200#: uengine.sorange
    193201msgid "Orange"
    194202msgstr "Oranşová"
     203
     204#: uengine.spercenthit
     205msgid "Percent hit"
     206msgstr ""
    195207
    196208#: uengine.spink
     
    218230msgid "Shot fired"
    219231msgstr "Střel vystřeleno"
     232
     233#: uengine.sshotshit
     234msgid "Shot hit"
     235msgstr ""
    220236
    221237#: uengine.sstartgame
     
    244260msgid "%0:s of %1:s"
    245261msgstr "%0:s z %1:s"
     262
  • trunk/Languages/Tunneler.pot

    r62 r67  
    154154msgstr ""
    155155
     156#: uengine.smetersdug
     157msgid "Meters dug"
     158msgstr ""
     159
     160#: uengine.smeterstravelled
     161msgid "Meters travelled"
     162msgstr ""
     163
    156164#: uengine.sorange
    157165msgid "Orange"
    158166msgstr ""
    159167
     168#: uengine.spercenthit
     169msgid "Percent hit"
     170msgstr ""
     171
    160172#: uengine.spink
    161173msgid "Pink"
     
    180192#: uengine.sshotsfired
    181193msgid "Shot fired"
     194msgstr ""
     195
     196#: uengine.sshotshit
     197msgid "Shot hit"
    182198msgstr ""
    183199
  • trunk/UEngine.pas

    r66 r67  
    1616  EnergyDecreaseOutside = 0.00003; // ~5 minutes of live
    1717  EnergyIncreaseHome = 0.001;
    18   ShieldSteps = 40;
     18  ShieldIncreaseHome = 0.001;
     19  ShieldDecreaseHit = 0.15;
    1920  ExplosionBulletCount = 100;
    2021  ExplosionRange = 20;
     
    6061    Player: TPlayer;
    6162    Position: TRealPoint;
     63    PositionTail: TRealPoint;
    6264    Direction: TRealPoint;
    6365    MaxDistance: Integer;
    6466    Distance: Real;
    6567    StopByDirt: Boolean;
     68    CanKill: Boolean;
    6669    constructor Create;
    6770  end;
    6871
     72  { TBullets }
     73
    6974  TBullets = class(TObjectList<TBullet>)
     75    procedure HideAll;
    7076  end;
    7177
     
    129135    LastShield: Real;
    130136    House: TRectangle;
    131     ShootCount: Integer;
     137    ShotsCount: Integer;
     138    ShotsHit: Integer;
     139    MetersDug: Integer;
     140    MetersTravelled: Integer;
    132141    procedure ResetTank;
    133142    procedure Init;
     
    277286  SStatistics = 'Statistics';
    278287  SShotsFired = 'Shot fired';
     288  SShotsHit = 'Shot hit';
     289  SPercentHit = 'Percent hit';
     290  SMetersDug = 'Meters dug';
     291  SMetersTravelled = 'Meters travelled';
    279292  SWinnerIs = 'The winner is';
    280293  SGreen = 'Green';
     
    287300  SGray = 'Gray';
    288301
     302{ TBullets }
     303
     304procedure TBullets.HideAll;
     305var
     306  I: Integer;
     307begin
     308  for I := 0 to Count - 1 do
     309  with Items[I] do begin
     310    Player.Engine.World.Surface.ItemsXY[Trunc(Position.X), Trunc(Position.Y)] := Byte(miSpace);
     311    Player.Engine.World.Surface.ItemsXY[Trunc(PositionTail.X), Trunc(PositionTail.Y)] := Byte(miSpace);
     312  end;
     313end;
     314
    289315{ TTanks }
    290316
     
    424450  MaxDistance := -1;
    425451  Distance := 0;
     452  CanKill := True;
    426453end;
    427454
     
    491518    if (Bullets.Count < MaxBulletCount) and
    492519    ((Now - LastShootTime) > ShootDelay * OneSecond) then begin
    493       Inc(ShootCount);
     520      Inc(ShotsCount);
    494521      NewBullet := TBullet.Create;
    495522      NewBullet.Player := Self;
     
    537564        Direction := NewDirection;
    538565        Result := True;
     566        Inc(MetersDug);
    539567      end;
    540568    end else begin
     
    546574        LastMoveTime := Now;
    547575        Energy := Energy - EnergyDecreaseMove;
     576        Inc(MetersTravelled);
    548577      end;
    549578    end;
     
    588617  if House.IsInside(Position) then begin
    589618    if not Exploded then
    590       Shield := Shield + 0.2 * 1 / ShieldSteps;
     619      Shield := Shield + ShieldIncreaseHome;
    591620    if Shield > 1 then Shield := 1;
    592621  end;
     
    612641    P := Trunc(Direction.Y);
    613642
     643    PositionTail := Position;
    614644    Position.X := Position.X + Direction.X;
    615645    Position.Y := Position.Y + Direction.Y;
     
    641671          if (Self.Id <> P) and
    642672            (Engine.World.Matters[ItemsXY[Pos.X, Pos.Y]].Kind = mkTankBody) and
    643             (Engine.World.Matters[ItemsXY[Pos.X, Pos.Y]].Player = P) then
    644             Shield := Shield - 1 / ShieldSteps;
     673            (Engine.World.Matters[ItemsXY[Pos.X, Pos.Y]].Player = P) and CanKill then begin
     674              Shield := Shield - ShieldDecreaseHit;
     675              Inc(Self.ShotsHit);
     676            end;
    645677          if StopByDirt then Explosion(LastPos, BulletExplosionRange);
    646678          Bullets.Delete(I);
     
    788820  Position := StartPosition;
    789821  ExplosionPending := False;
     822  Bullets.HideAll;
    790823  Bullets.Clear;
    791824  Energy := 1;
    792825  Shield := 1;
    793826  Direction := 0;
    794   ShootCount := 0;
    795827  ShowTank;
    796828  Exploded := False;
     
    804836  Position := StartPosition;
    805837  PlaceHouse;
     838  ShotsCount := 0;
     839  ShotsHit := 0;
     840  MetersDug := 0;
     841  MetersTravelled := 0;
    806842end;
    807843
     
    824860      NewBullet.Position.Y := Position.Y; // + NewBullet.Direction.Y * 3;
    825861      NewBullet.MaxDistance := Random(Distance);
     862      NewBullet.CanKill := False;
    826863      Bullets.Add(NewBullet);
    827864    end;
     
    958995  StartPosition := Source.StartPosition;
    959996  Score := Source.Score;
    960   ShootCount := Source.ShootCount;
     997  ShotsCount := Source.ShotsCount;
     998  ShotsHit := Source.ShotsHit;
     999  MetersDug := Source.MetersDug;
     1000  MetersTravelled := Source.MetersTravelled;
    9611001  FExploded := Source.FExploded;
    9621002  Tanks.Assign(Source.Tanks);
     
    15351575var
    15361576  X: Integer;
     1577  Y: Integer;
    15371578  Text: string;
    15381579  Winner: TPlayer;
     1580  I: Integer;
     1581  ShotsPercent: Integer;
     1582const
     1583  LineHeight = 40;
    15391584begin
    15401585  with Bitmap.Canvas do begin
     
    15561601    Font.Size := 20;
    15571602
    1558     //Text := SShotsFired + ' ' + IntToStr(ShootCount);
    1559     //TextOut(X - TextWidth(Text) div 2, Bitmap.Height div 10, Text);
    1560 
     1603    Y := Bitmap.Height div 10 + 3 * LineHeight;
     1604    X := Bitmap.Width div 2 + 50;
     1605    Inc(Y, LineHeight);
     1606    Text := SShotsFired;
     1607    TextOut(X, Y, Text);
     1608    Inc(Y, LineHeight);
     1609    Text := SShotsHit;
     1610    TextOut(X, Y, Text);
     1611    Inc(Y, LineHeight);
     1612    Text := SPercentHit;
     1613    TextOut(X, Y, Text);
     1614    Inc(Y, LineHeight);
     1615    Inc(Y, LineHeight);
     1616    Text := SMetersDug;
     1617    TextOut(X, Y, Text);
     1618    Inc(Y, LineHeight);
     1619    Text := SMetersTravelled;
     1620    TextOut(X, Y, Text);
     1621    Inc(Y, LineHeight);
     1622
     1623    for I := 0 to Players.Count - 1 do
     1624    with Players[I] do begin
     1625      Y := Bitmap.Height div 10 + 3 * LineHeight;
     1626      X := Bitmap.Width div 2 + 50 + 500 + 200 * I;
     1627      Font.Color := Color1;
     1628      Text := Name;
     1629      TextOut(X - TextWidth(Text) , Y, Text);
     1630      Inc(Y, LineHeight);
     1631      Text := IntToStr(ShotsCount);
     1632      TextOut(X - TextWidth(Text), Y, Text);
     1633      Inc(Y, LineHeight);
     1634      Text := IntToStr(ShotsHit);
     1635      TextOut(X - TextWidth(Text), Y, Text);
     1636      Inc(Y, LineHeight);
     1637      if ShotsCount > 0 then
     1638        ShotsPercent := Round(ShotsHit / ShotsCount * 100)
     1639        else ShotsPercent := 0;
     1640      Text := IntToStr(ShotsPercent) + '%';
     1641      TextOut(X - TextWidth(Text), Y, Text);
     1642      Inc(Y, LineHeight);
     1643      Inc(Y, LineHeight);
     1644      Text := IntToStr(MetersDug);
     1645      TextOut(X - TextWidth(Text), Y, Text);
     1646      Inc(Y, LineHeight);
     1647      Text := IntToStr(MetersTravelled);
     1648      TextOut(X - TextWidth(Text), Y, Text);
     1649      Inc(Y, LineHeight);
     1650    end;
     1651
     1652    Inc(Y, 3 * LineHeight);
     1653
     1654    X := Bitmap.Width div 2 + 50;
     1655    Font.Color := clOrange;
    15611656    Winner := Players.GetWinner;
    15621657    if Assigned(Winner) then begin
    1563       Text := SWinnerIs + ' ' + Winner.Name;
    1564       TextOut(X - TextWidth(Text) div 2, Bitmap.Height div 10 + 60, Text);
     1658      Text := SWinnerIs;
     1659      TextOut(X, Y, Text);
     1660      X := X + TextWidth(Text) + 20;
     1661      Font.Color := Winner.Color1;
     1662      Text := Winner.Name;
     1663      TextOut(X, Y, Text);
    15651664    end;
    15661665  end;
Note: See TracChangeset for help on using the changeset viewer.