Реализация игры "Шашки" на Delphi
Дипломная работа - Компьютеры, программирование
Другие дипломы по предмету Компьютеры, программирование
nimateStep] div 8);;:= FAnimateSubStep /ANIMATE_SUBSTEP_COUNT;:= 1 - P; := Round(Q*X1+P*X2);:= Round(Q*Y1+P*Y2);.Draw(Image.Canvas, X, Y, FAnimateObject);;.Refresh;;
TPositionFrame.SelectCell(X, Y: Integer);IsWhite(X, Y) then Exit;:= CellToField(X, Y);;;
TPositionFrame.SetFlipBoard(const Value: Boolean);FFlipBoard = Value then Exit;:= Value;;;
TPositionFrame.SetPosition(const Position: TPosition; NeedAnimate: Boolean);:= FPosition;:= Position;AcceptMove then PrepareAccept;NeedAnimate and (Position.MoveStr[0] <> -1)BeginAnimate(Position)RefreshView;
TPositionFrame.CellRect(X, Y: Integer; Grow: Integer = 0): TRect;.Left := X * ImageList.Width - Grow;.Top := Y * ImageList.Height - Grow;.Right := Result.Left + ImageList.Width + 2*Grow;.Bottom := Result.Top + ImageList.Height + 2*Grow;;
TPositionFrame.SetAcceptMove(const Value: Boolean);FAcceptMove = Value then Exit;Value and not PrepareAccept then Exit;:= Value;;
TPositionFrame.InitSelectMoveVars;(FSelectedCells, SizeOf(FSelectedCells), $00);(FEnabledAnswer, SizeOf(FEnabledAnswer), $00);:= 0;;
TPositionFrame.PrepareAccept: Boolean;:= GetMoves(FPosition, @FAnswers, ANSWERS_SIZE);:= (FAnswersCount <> 0) and (FAnswersCount <= ANSWERS_SIZE);;;
TPositionFrame.AddCellToMove(X, Y: Integer);IsWhite(X, Y) then Exit;FUserSelectCount = 0 then(CellToField(X, Y));;;Unselect(CellToField(X, Y)) then Exit;ThinkBetter(CellToField(X, Y)) then Exit;MoveComplete(CellToField(X, Y)) then Exit;(CellToField(X, Y));;
TPositionFrame.BeginMove(Field: Integer);: Integer;: Boolean;:= False;I := 0 to FAnswersCount-1 doFAnswers[I].MoveStr[0] = Field then:= True;[I] := 1;;not FindMove then Exit;[0] := Field;:= 1;[Field] := True;;;
TPositionFrame.Unselect(Field: Integer): Boolean;: Integer;:= False;FUserSelectCount = 0 then Exit;FUserSelect[FUserSelectCount-1] <> Field then Exit;[Field] := False;I := 0 to FAnswersCount-1 doFEnabledAnswer[I] = FUserSelectCount then[I] := FEnabledAnswer[I] - 1;:= FUserSelectCount - 1;;:= True;;
TPositionFrame.ThinkBetter(Field: Integer): Boolean;: Integer;:= False;FUserSelectCount <> 1 then Exit;I := 0 to FAnswersCount-1 doFAnswers[I].MoveStr[0] = Field then;(Field);:= True;;;;;
TPositionFrame.MoveComplete(Field: Integer): Boolean;, J: Integer;: Integer;:= False;:= -1;I := 0 to FAnswersCount-1 doFEnabledAnswer[I] -1 then ExitUserMove := I;;UserMove = -1 then Exit;:= False;(FSelectedCells, SizeOf(FSelectedCells), $00);Assigned(FOnAcceptMove) then FOnAcceptMove(Self, FAnswers[UserMove]);:= True;;
TPositionFrame.ContinueMove(Field: Integer);: Integer;: Boolean;
FreeWay(Field1, Field2: Integer): Boolean;: Integer;: TDirection;:= False;Direction := Low(TDirection) to High(TDirection) do:= Field1;:= DirectionTable[Direction, NextI];NextI = -1 then Break;FPosition.Field[NextI] <> 0 then Break;NextI = Field2 then:= True;;;False;;;
SameDiagonal(StartField, Field1, Field2, Field3: Integer): Boolean;: Integer;: Integer;: TDirection;:= False;Direction := Low(TDirection) to High(TDirection) do:= StartField;:= 0;:= DirectionTable[Direction, NextI];NextI = -1 then Break;NextI = Field1 then FindCount := FindCount + 1;NextI = Field2 then FindCount := FindCount + 1;NextI = Field3 then FindCount := FindCount + 1;FindCount = 3 then:= True;;;False;;;
AcceptMarginaly: Boolean;(FUserSelectCount > 0);:=
(FAnswers[I].MoveStr[FUserSelectCount+1] <> -1) and // это не последнее поле(FAnswers[I].MoveStr[FUserSelectCount], Field) and // можно пройти( // Одна диагональ[I].MoveStr[FUserSelectCount-1],[I].MoveStr[FUserSelectCount],,[I].MoveStr[FUserSelectCount+1]);
function AcceptDirectly: Boolean;:= Field = FAnswers[I].MoveStr[FUserSelectCount];;
AcceptVariant: Boolean;:= AcceptDirectly or AcceptMarginaly;;
:= False;I := 0 to FAnswersCount-1 doif FEnabledAnswer[I] <> FUserSelectCount then Continue;AcceptVariant then:= True;[I] := FEnabledAnswer[I] + 1;; end;FindMove then[FUserSelectCount] := Field;:= FUserSelectCount + 1;[Field] := True;; end;;
TPositionFrame.GetAnimate: Boolean;:= Timer.Enabled;;
TPositionFrame.BeginAnimate(const Position: TPosition);: Integer;: Integer;ProcessPair(Field1, Field2: Integer);: Integer;: Integer;: Integer;:= Abs(Field1 - Field2);Field1 > Field2 thenDelta mod 9 = 0Step := -9Step := -7beginDelta mod 9 = 0Step := 9Step := 7;:= Field1;:= NextI + Step;[AnimateWayPos] := NextI;:= AnimateWayPos + 1;NextI = Field2; ;Position do // Вычисляем путьif MoveStr[0] = -1 then Exit; [0] := DecodeField[MoveStr[0]];:= 1; I := 1;MoveStr[I] <> -1 do begin(DecodeField[MoveStr[I-1]], DecodeField[MoveStr[I]]);:= I + 1; end;FAnimatePosition.Field[MoveStr[0]] of: FAnimateObject := 0;: FAnimateObject := 1;: FAnimateObject := 2;: FAnimateObject := 3; end; ;[AnimateWayPos] := -1;:= 1;:= 0;.Enabled := True;;
TPositionFrame.TimerTimer(Sender: TObject);:= FAnimateSubStep + 1;FAnimateSubStep = ANIMATE_SUBSTEP_COUNT then:= FAnimateStep + 1;FAnimateWay[FAnimateStep] = -1 then Timer.Enabled := False;(FAnimateObject = 0) and (FAnimateWay[FAnimateStep] >= 56) then FAnimateObject := 2;(FAnimateObject = 1) and (FAnimateWay[FAnimateStep] <= 7) then FAnimateObject := 3;:= 0;;;;
.