Changeset 10


Ignore:
Timestamp:
Feb 16, 2014, 11:58:42 PM (11 years ago)
Author:
chronos
Message:
  • Added: Player mode human or computer.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/UFormMain.pas

    r9 r10  
    7777procedure TFormMain.PaintBox1Paint(Sender: TObject);
    7878begin
    79   with TPlayer(Game.Players[0]) do begin
     79  with Game.CurrentPlayer do begin
    8080    View := Bounds(View.Left, View.Top, PaintBox1.Width,
    8181      PaintBox1.Height);
     
    143143begin
    144144  if Button = mbLeft then begin
    145     StartMousePoint := Point(X, Y);
    146     StartViewPoint := Point(TPlayer(Game.Players[0]).View.Left, TPlayer(Game.Players[0]).View.Top);
    147     MoveActive := True;
     145    if Game.CurrentPlayer.Mode = pmHuman then begin
     146      StartMousePoint := Point(X, Y);
     147      StartViewPoint := Point(Game.CurrentPlayer.View.Left, Game.CurrentPlayer.View.Top);
     148      MoveActive := True;
     149    end;
    148150  end;
    149151end;
     
    158160begin
    159161  if MoveActive then begin
    160     TPlayer(Game.Players[0]).View := Bounds(StartViewPoint.X + StartMousePoint.X - X,
    161       StartViewPoint.Y + StartMousePoint.Y - Y,
    162       TPlayer(Game.Players[0]).View.Right - TPlayer(Game.Players[0]).View.Left,
    163       TPlayer(Game.Players[0]).View.Bottom - TPlayer(Game.Players[0]).View.Top);
    164     Redraw;
     162    if Game.CurrentPlayer.Mode = pmHuman then begin
     163      Game.CurrentPlayer.View := Bounds(StartViewPoint.X + StartMousePoint.X - X,
     164        StartViewPoint.Y + StartMousePoint.Y - Y,
     165        Game.CurrentPlayer.View.Right - Game.CurrentPlayer.View.Left,
     166        Game.CurrentPlayer.View.Bottom - Game.CurrentPlayer.View.Top);
     167      Redraw;
     168    end;
    165169  end;
    166170end;
     
    170174begin
    171175  if (StartMousePoint.X = X) and (StartMousePoint.Y = Y) then begin
    172     TPlayer(Game.Players[0]).SelectCell(Point(X, Y));
    173     Redraw;
     176    if Game.CurrentPlayer.Mode = pmHuman then begin
     177      Game.CurrentPlayer.SelectCell(Point(X, Y));
     178      Redraw;
     179    end;
    174180  end;
    175181  MoveActive := False;
  • trunk/UGame.pas

    r9 r10  
    4747  end;
    4848
     49  TPlayerMode = (pmHuman, pmComputer);
     50
    4951  { TPlayer }
    5052
     
    5658    ViewZoom: Double;
    5759    SelectedCell: TPoint;
     60    Mode: TPlayerMode;
     61    procedure ComputerTurn;
    5862    procedure SelectCell(Pos: TPoint);
    5963    procedure Paint(PaintBox: TPaintBox);
     
    131135
    132136{ TPlayer }
     137
     138procedure TPlayer.ComputerTurn;
     139begin
     140
     141end;
    133142
    134143procedure TPlayer.SelectCell(Pos: TPoint);
Note: See TracChangeset for help on using the changeset viewer.