- Timestamp:
- Dec 11, 2020, 11:42:27 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:ignore
set to
GamePack
GamePack.res
GamePack.lps
lib
-
Property svn:ignore
set to
-
trunk/Games/UClovece.pas
r1 r2 6 6 7 7 uses 8 Classes, SysUtils, Controls, UGame, fgl, UGraphics, UCanvas;8 Classes, SysUtils, Controls, Forms, UGame, fgl, UGraphics, UCanvas; 9 9 10 10 type … … 70 70 NextTile: TTile; 71 71 NextTileHome: TTile; 72 AnimateToken: TToken; 72 73 function GetNext(Steps: Integer; Player: TPlayer): TTile; 74 procedure GetNextSteps(Steps: Integer; Player: TPlayer; Tiles: TTiles); 73 75 procedure Paint(Canvas: TCanvas); 74 76 property Owner: TPlayer read FOwner write SetOwner; … … 101 103 private 102 104 MetaCanvas: TMetaCanvas; 105 Processing: Boolean; 106 procedure AnimateTokenMovement(Token: TToken; NewTile: TTile); 103 107 public 104 108 Board: TBoard; … … 195 199 end; 196 200 end else Result := Self; 201 end; 202 203 procedure TTile.GetNextSteps(Steps: Integer; Player: TPlayer; Tiles: TTiles); 204 begin 205 if Steps > 0 then begin 206 Tiles.Add(Self); 207 if Assigned(NextTileHome) and (NextTileHome.Owner = Player) then begin 208 NextTileHome.GetNextSteps(Steps - 1, Player, Tiles) 209 end else begin 210 if Assigned(NextTile) then NextTile.GetNextSteps(Steps - 1, Player, Tiles); 211 end; 212 end; 197 213 end; 198 214 … … 218 234 ); 219 235 end; 236 if Assigned(AnimateToken) then begin 237 Canvas.Pen.Width := 5; 238 Canvas.Brush.Color := AnimateToken.Player.Color; 239 Canvas.Ellipse( 240 Position.X - TokenSize div 2, 241 Position.Y - TokenSize div 2, 242 Position.X + TokenSize div 2, 243 Position.Y + TokenSize div 2 244 ); 245 end; 220 246 end; 221 247 … … 441 467 442 468 { TClovece } 469 470 procedure TClovece.AnimateTokenMovement(Token: TToken; NewTile: TTile); 471 var 472 I: Integer; 473 Steps: TTiles; 474 begin 475 Steps := TTiles.Create(False); 476 Token.Tile.GetNextSteps(DiceValue, CurrentPlayer, Steps); 477 Token.Tile := nil; 478 for I := 0 to Steps.Count - 1 do begin 479 Steps[I].AnimateToken := Token; 480 Repaint; 481 Application.ProcessMessages; 482 Sleep(200); 483 Steps[I].AnimateToken := nil; 484 end; 485 Steps.Free; 486 Token.Tile := NewTile; 487 end; 443 488 444 489 procedure TClovece.ThrowDice; … … 479 524 // Move opponents token back to its yard 480 525 NewTile.Token.Tile := NewTile.Token.Player.YardTiles.GetTileWithoutToken; 481 Token.Tile := NewTile;526 AnimateTokenMovement(Token, NewTile); 482 527 TurnDone := True; 483 528 Break; … … 485 530 end else begin 486 531 // Normal token move 487 Token.Tile := NewTile;532 AnimateTokenMovement(Token, NewTile); 488 533 TurnDone := True; 489 534 Break; … … 506 551 procedure TClovece.MouseUp(Button: TMouseButton; Position: TPoint); 507 552 begin 508 if State = gsRunning then 553 if (State = gsRunning) and not Processing then begin 554 Processing := True; 509 555 ThrowDice; 556 Processing := False; 557 end; 510 558 end; 511 559 … … 551 599 begin 552 600 with Canvas do begin 601 Pen.Color := clBlack; 553 602 Brush.Opacity := $ff; 554 603 Brush.Color := clGray; … … 572 621 Brush.Opacity := 0; 573 622 Pen.Color := clBlack; 623 Brush.Style := bsSolid; 624 Brush.Color := CurrentPlayer.Color; 574 625 TextOut(Point(0, 0), 'Player: ' + CurrentPlayer.Name); 626 Brush.Style := bsClear; 575 627 TextOut(Point(0, 30), 'Dice: ' + IntToStr(DiceValue) + ' ' + IntToStr(LastDiceValue)); 576 628 TextOut(Point(0, 60), 'Throw: ' + IntToStr(DiceThrow)); -
trunk/Packages/Common
-
Property svn:ignore
set to
lib
-
Property svn:ignore
set to
-
trunk/UFormMain.pas
r1 r2 68 68 procedure TGameCanvas.TextOut(const Pos: TPoint; Text: string); 69 69 begin 70 if Brush. Opacity = 0then Canvas.Brush.Style := Graphics.bsClear70 if Brush.Style = bsClear then Canvas.Brush.Style := Graphics.bsClear 71 71 else Canvas.Brush.Style := Graphics.bsSolid; 72 72 Canvas.Brush.Color := Brush.Color; … … 77 77 procedure TGameCanvas.Rectangle(const Rect: TRect); 78 78 begin 79 //Canvas.Brush.Style := Brush.Style; 79 if Brush.Style = bsClear then Canvas.Brush.Style := Graphics.bsClear 80 else Canvas.Brush.Style := Graphics.bsSolid; 80 81 Canvas.Brush.Color := Brush.Color; 81 //Canvas.Pen.Style := Pen.Style; 82 if Brush.Style = bsClear then Canvas.Pen.Style := Graphics.psClear 83 else Canvas.Pen.Style := Graphics.psSolid; 82 84 Canvas.Pen.Color := Pen.Color; 83 85 Canvas.FillRect(Rect); … … 86 88 procedure TGameCanvas.Line(const P1, P2: TPoint); 87 89 begin 90 if Brush.Style = bsClear then Canvas.Brush.Style := Graphics.bsClear 91 else Canvas.Brush.Style := Graphics.bsSolid; 92 Canvas.Brush.Color := Brush.Color; 93 if Brush.Style = bsClear then Canvas.Pen.Style := Graphics.psClear 94 else Canvas.Pen.Style := Graphics.psSolid; 95 Canvas.Pen.Color := Pen.Color; 88 96 Canvas.Pen.Width := Pen.Width; 89 97 Canvas.Line(P1, P2); … … 92 100 procedure TGameCanvas.Ellipse(const Bounds: TRect); 93 101 begin 102 if Brush.Style = bsClear then Canvas.Brush.Style := Graphics.bsClear 103 else Canvas.Brush.Style := Graphics.bsSolid; 104 Canvas.Brush.Color := Brush.Color; 105 if Brush.Style = bsClear then Canvas.Pen.Style := Graphics.psClear 106 else Canvas.Pen.Style := Graphics.psSolid; 107 Canvas.Pen.Color := Pen.Color; 94 108 Canvas.Pen.Width := Pen.Width; 95 Canvas.Brush.Color := Brush.Color;96 109 Canvas.Ellipse(Bounds); 97 110 end;
Note:
See TracChangeset
for help on using the changeset viewer.