Changeset 4 for trunk/UMainForm.pas


Ignore:
Timestamp:
Mar 6, 2011, 6:43:01 PM (14 years ago)
Author:
george
Message:
  • Added: Complete map visualizaiton.
  • Added: Generating map rock border.
  • Added: Tank movement colision detection.
  • Added: Some bullet shooting test.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UMainForm.pas

    r3 r4  
    1919    MenuItem2: TMenuItem;
    2020    MenuItem3: TMenuItem;
     21    MenuItemShowMap: TMenuItem;
    2122    StatusBar1: TStatusBar;
    22     Timer1: TTimer;
     23    TimerDraw: TTimer;
     24    TimerEngineTick: TTimer;
    2325    procedure FormCreate(Sender: TObject);
    2426    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    2527    procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
     28    procedure FormShow(Sender: TObject);
    2629    procedure Image1Resize(Sender: TObject);
    2730    procedure MenuItem2Click(Sender: TObject);
    2831    procedure MenuItem3Click(Sender: TObject);
    29     procedure Timer1Timer(Sender: TObject);
     32    procedure MenuItemShowMapClick(Sender: TObject);
     33    procedure TimerDrawTimer(Sender: TObject);
     34    procedure TimerEngineTickTimer(Sender: TObject);
    3035  private
    31     { private declarations }
    3236  public
    3337    { public declarations }
     
    4145{$R *.lfm}
    4246
     47uses
     48  UMapForm;
     49
    4350{ TMainForm }
    4451
    45 procedure TMainForm.Timer1Timer(Sender: TObject);
     52procedure TMainForm.TimerDrawTimer(Sender: TObject);
    4653begin
    4754  try
    48     Timer1.Enabled := False;
    49     Engine.Tick;
     55    TimerDraw.Enabled := False;
     56    Engine.Draw;
    5057    StatusBar1.Panels[1].Text := IntToStr(TPlayer(Engine.Players[0]).Position.X) + ', ' +
    5158      IntToStr(TPlayer(Engine.Players[0]).Position.Y) + ' ' +
    5259      IntToStr(TPlayer(Engine.Players[0]).Direction);
    5360  finally
    54     Timer1.Enabled := True;
     61    TimerDraw.Enabled := True;
    5562  end;
     63end;
     64
     65procedure TMainForm.TimerEngineTickTimer(Sender: TObject);
     66begin
     67  Engine.Tick;
    5668end;
    5769
     
    5971begin
    6072  Engine.Bitmap := Image1.Picture.Bitmap;
    61   Image1Resize(Self);
    6273  with Engine do begin
    63     PlayerCount := 2;
     74    PlayerCount := 4;
    6475    with TPlayer(Players[0]) do begin
    6576      Keys.Left := 65;
    66       Keys.Down := 87;
     77      Keys.Down := 83;
    6778      Keys.Right := 68;
    68       Keys.Up := 83;
     79      Keys.Up := 87;
    6980      Keys.Shoot := 69;
    7081    end;
    7182    with TPlayer(Players[1]) do begin
    7283      Keys.Left := 37;
    73       Keys.Down := 38;
     84      Keys.Down := 40;
    7485      Keys.Right := 39;
    75       Keys.Up := 40;
     86      Keys.Up := 38;
    7687      Keys.Shoot := 17;
     88    end;
     89    with TPlayer(Players[2]) do begin
     90      Keys.Left := 76;
     91      Keys.Down := 186;
     92      Keys.Right := 222;
     93      Keys.Up := 80;
     94      Keys.Shoot := 186;
     95    end;
     96    with TPlayer(Players[3]) do begin
     97      Keys.Left := 100;
     98      Keys.Down := 98;
     99      Keys.Right := 102;
     100      Keys.Up := 104;
     101      Keys.Shoot := 98;
    77102    end;
    78103  end;
    79104  Engine.NewGame;
     105  Image1Resize(Self);
    80106end;
    81107
     
    93119end;
    94120
     121procedure TMainForm.FormShow(Sender: TObject);
     122begin
     123end;
     124
    95125procedure TMainForm.Image1Resize(Sender: TObject);
    96126begin
    97 //  Image1.Picture.Bitmap.SetSize(Image1.Width, Image1.Height);
    98   Image1.Picture.Bitmap.SetSize(80, 60);
     127  Image1.Picture.Bitmap.SetSize(Image1.Width, Image1.Height);
    99128  Engine.ResizePlayerFrames;
    100129end;
     
    110139end;
    111140
     141procedure TMainForm.MenuItemShowMapClick(Sender: TObject);
     142begin
     143  MapForm.Show;
     144end;
     145
    112146end.
    113147
Note: See TracChangeset for help on using the changeset viewer.