Changeset 34 for trunk/UCore.pas


Ignore:
Timestamp:
Nov 25, 2017, 12:27:33 AM (7 years ago)
Author:
chronos
Message:
  • Modified: Improved New game window.
  • Modified: Used newer version of Common and CoolTranslator packages.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        33backup
        44tunneler.exe
         5tunneler.dbg
         6tunneler.lps
        57heaptrclog.trc
        6 tunneler.lps
         8Components/Common/Languages/*.mo
         9Components/CoolTranslator/Demo/lib
  • trunk/UCore.pas

    r32 r34  
    66
    77uses
    8   Dialogs, Classes, SysUtils, Contnrs, Graphics, SpecializedMatrix, SpecializedList,
     8  Dialogs, Classes, SysUtils, Graphics, SpecializedMatrix, SpecializedList,
    99  IntfGraphics, FPImage, LCLType, SpecializedBitmap, GraphType, Math, URectangle,
    1010  Syncobjs, UThreading, Forms, DateUtils, UAudioSystem, UAudioSystemMPlayer;
     
    9999    function DigProc(Item1, Item2: Byte): Byte;
    100100  public
     101    Color: TColor;
    101102    Id: Integer;
    102103    Enabled: Boolean;
     
    131132    constructor Create;
    132133    destructor Destroy; override;
     134    procedure Assign(Source: TPlayer);
    133135    property Exploded: Boolean read FExploded write SetExploded;
     136  end;
     137
     138  { TPlayers }
     139
     140  TPlayers = class(TListObject)
     141    procedure Assign(Players: TPlayers);
    134142  end;
    135143
     
    207215    Keyboard: TKeyboard;
    208216    World: TWorld;
    209     PlayerPool: TListObject; // TListObject<TPlayer>
    210     Players: TListObject; // TListObject<TPlayer>
     217    PlayerPool: TPlayers; // TListObject<TPlayer>
     218    Players: TPlayers; // TListObject<TPlayer>
    211219    DigMasks: TListObject; // TListObject<TMatrixByte>
    212220    Lock: TCriticalSection;
     
    215223    AudioShot: TMediaPlayer;
    216224    AudioExplode: TMediaPlayer;
     225    DrawDuration: TDatetime;
    217226    procedure CheckGameEnd;
    218227    constructor Create;
     
    242251implementation
    243252
     253uses
     254  UPlatform;
     255
    244256resourcestring
    245257  SPlayer = 'Player';
     258
    246259
    247260
     
    252265  TFastBitmapPixelComponents(Result).R := TFastBitmapPixelComponents(Value).B;
    253266  TFastBitmapPixelComponents(Result).B := TFastBitmapPixelComponents(Value).R;
     267end;
     268
     269{ TPlayers }
     270
     271procedure TPlayers.Assign(Players: TPlayers);
     272var
     273  I: Integer;
     274begin
     275  while Count < Players.Count do Add(TPlayer.Create);
     276  while Count > Players.Count do Delete(Count - 1);
     277  for I := 0 to Count - 1 do
     278    TPlayer(Items[I]).Assign(TPlayer(Players[I]));
    254279end;
    255280
     
    708733var
    709734  Delta: TPoint;
    710   Matter: TMatterIndex;
    711735  NewBullet: TBullet;
    712   I: Integer;
    713   Pos: TPoint;
    714   ColisionState: TColisionState;
    715736begin
    716737  if Exploded then Exit;
     
    815836  P: Integer;
    816837  Pos: TPoint;
    817   D: Real;
    818838begin
    819839  // Check energy
     
    11811201end;
    11821202
     1203procedure TPlayer.Assign(Source: TPlayer);
     1204begin
     1205  Keys := Source.Keys;
     1206  Color := Source.Color;
     1207  Energy := Source.Energy;
     1208  Shield := Source.Shield;
     1209  Name := Source.Name;
     1210  Enabled := Source.Enabled;
     1211  Position := Source.Position;
     1212  Score := Source.Score;
     1213end;
     1214
    11831215{ TEngine }
    11841216
     
    12301262procedure TEngine.DoDrawToBitmap;
    12311263var
    1232   I: Integer;
    12331264  X, Y: Integer;
    12341265  PixelX, PixelY: Integer;
     
    13281359  NewMask: TMatrixByte;
    13291360  I: Integer;
    1330   X, Y: Integer;
    13311361begin
    13321362  DigMasks.Clear;
     
    15421572  FBitmapLock := TCriticalSection.Create;
    15431573  IntfImage := TLazIntfImage.Create(1, 1);
    1544   PlayerPool := TListObject.Create;
    1545   Players := TListObject.Create;
     1574  PlayerPool := TPlayers.Create;
     1575  Players := TPlayers.Create;
    15461576  Players.OwnsObjects := False;
    15471577  Keyboard := TKeyboard.Create;
    15481578  World := TWorld.Create;
    15491579  World.Engine := Self;
    1550   DefaultAudioSystem := TAudioSystemMPlayer.Create(nil);
     1580  //DefaultAudioSystem := TAudioSystemMPlayer.Create(nil);
    15511581  AudioShot := TMediaPlayer.Create(nil);
    15521582  AudioShot.FileName := 'Audio/GE_KF7_Soviet.wav';
     
    15971627var
    15981628  I: Integer;
    1599 begin
    1600   if FRedrawPending then
    1601   begin
     1629  DrawStart: TDateTime;
     1630begin
     1631  if FRedrawPending then begin
     1632    DrawStart := NowPrecise;
    16021633    FRedrawPending := False;
    16031634    try
     
    16111642    end;
    16121643    if not Thread.Terminated then Thread.Synchronize(DoDrawToBitmap);
     1644    DrawDuration := NowPrecise - DrawStart;
    16131645  end;
    16141646end;
     
    16171649var
    16181650  I: Integer;
    1619   I2: Integer;
    16201651begin
    16211652  Active := False;
Note: See TracChangeset for help on using the changeset viewer.