Ignore:
Timestamp:
Sep 28, 2011, 8:34:06 PM (13 years ago)
Author:
george
Message:
  • Added: Introduced player pool for selection of players for new game.
  • Fixed: Deadlock on program exit during threads termination.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UMainForm.pas

    r22 r23  
    4343    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    4444    procedure FormCreate(Sender: TObject);
     45    procedure FormDestroy(Sender: TObject);
    4546    procedure FormDeactivate(Sender: TObject);
    46     procedure FormDestroy(Sender: TObject);
    4747    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    4848    procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
     
    6060  public
    6161    PersistentForm: TPersistentForm;
     62    Engine: TEngine;
    6263  end;
    6364
     
    8586    try
    8687      Engine.Lock.Acquire;
    87       StatusBar1.Panels[1].Text := IntToStr(TPlayer(Engine.Players[0]).Position.X) + ', ' +
    88         IntToStr(TPlayer(Engine.Players[0]).Position.Y) + ' ' +
    89         IntToStr(TPlayer(Engine.Players[0]).Direction);
     88      //StatusBar1.Panels[1].Text := IntToStr(TPlayer(Engine.Players[0]).Position.X) + ', ' +
     89      //  IntToStr(TPlayer(Engine.Players[0]).Position.Y) + ' ' +
     90      //  IntToStr(TPlayer(Engine.Players[0]).Direction);
    9091      StatusBar1.Panels[2].Text := FloatToStr(RoundTo(DrawDuration / OneMillisecond, -2));
    91       StatusBar1.Panels[3].Text := IntToStr(TPlayer(Engine.Players[0]).Bullets.Count);
     92      //StatusBar1.Panels[3].Text := IntToStr(TPlayer(Engine.Players[0]).Bullets.Count);
    9293    finally
    9394      Engine.Lock.Release;
     
    111112  Randomize;
    112113  DoubleBuffered := True;
     114  Engine := TEngine.Create;
    113115  Engine.Bitmap := Image1.Picture.Bitmap;
    114   with Engine do begin
    115     PlayerCount := 4;
    116     with TPlayer(Players[0]) do begin
    117       Name := 'Player 1';
    118       Keys.Left := 65;
    119       Keys.Down := 83;
    120       Keys.Right := 68;
    121       Keys.Up := 87;
    122       Keys.Shoot := 69;
    123     end;
    124     with TPlayer(Players[1]) do begin
    125       Name := 'Player 2';
    126       Keys.Left := 37;
    127       Keys.Down := 40;
    128       Keys.Right := 39;
    129       Keys.Up := 38;
    130       Keys.Shoot := 17;
    131     end;
    132     with TPlayer(Players[2]) do begin
    133       Name := 'Player 3';
    134       Keys.Left := 76;
    135       Keys.Down := 186;
    136       Keys.Right := 222;
    137       Keys.Up := 80;
    138       Keys.Shoot := 191;
    139     end;
    140     with TPlayer(Players[3]) do begin
    141       Name := 'Player 4';
    142       Keys.Left := 100;
    143       Keys.Down := 98;
    144       Keys.Right := 102;
    145       Keys.Up := 104;
    146       Keys.Shoot := 105;
    147     end;
    148   end;
    149116  Engine.NewGame;
    150117  Engine.Active := True;
     
    160127begin
    161128  PersistentForm.Free;
     129  Engine.Free;
    162130end;
    163131
Note: See TracChangeset for help on using the changeset viewer.