From e9a54e7ad4cd49b4e5583da9f8ccfacf904d276c Mon Sep 17 00:00:00 2001 From: scratko Date: Fri, 22 Mar 2024 01:26:07 +0300 Subject: minor changes --- figure.pp | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'figure.pp') diff --git a/figure.pp b/figure.pp index dd88668..3f2e0d1 100644 --- a/figure.pp +++ b/figure.pp @@ -57,16 +57,16 @@ function FindSquareShape(shape: ShapeList): boolean; function IsAboveTop(square: SquareItemPtr; CurBorders: borders): boolean; procedure SetBorders(var CurBorders: borders; left, right, up, down: integer); procedure CreateSquare(var shape: ShapeList; color: word); -procedure PrintAndHideShape(shape: ShapeList; CurBorders: borders; +procedure PrintAndHideShape(shape: ShapeList; CurBorders: borders; HideShape, HideCenter: boolean); -procedure CheckBorders(var shape, ChangedShape: ShapeList; CurBorders: borders; +procedure CheckBorders(var shape, ChangedShape: ShapeList; CurBorders: borders; var IsObstacle: boolean); procedure FigureInitial(var shape: ShapeList; CurBorders: borders); procedure CalculateNewXY(shape: ShapeList; var ChangedShape: ShapeList); procedure FindCenterFigure(var shape: ShapeList); procedure ComputeTurn(var ChangedShape: ShapeList); procedure ClearShape(var square: SquareItemPtr); -procedure InitEdges(var LeftEdge, RightEdge, UpEdge, DownEdge: EdgeType; +procedure InitEdges(var LeftEdge, RightEdge, UpEdge, DownEdge: EdgeType; shape: ShapeList); procedure PrintPreviewShape(NextShape: ShapeList); @@ -79,7 +79,7 @@ type MadeTurn = record x: integer; y: integer; - end; + end; ArrTurn = array [1..MaxSquaresFromCenter] of MadeTurn; AllTurnsType = record left, right: ArrTurn; @@ -122,7 +122,7 @@ begin end; square := square^.next end; - FindSquareShape := (sides.CountX1 = SquareSide) and + FindSquareShape := (sides.CountX1 = SquareSide) and (sides.CountX2 = SquareSide) end; @@ -205,15 +205,15 @@ begin place.FromX := tmp^.x; place.FromY := tmp^.y; place.CurSide := direction(random(sides)); - while not CorrectPos(place, shape) or + while not CorrectPos(place, shape) or ((place.CurSide = down) and ((place.FromY + HeightSquare) > 1)) do place.CurSide := direction(random(sides)); case place.CurSide of - left: SetLastSquare(shape, place.FromX - WidthSquare, place.FromY, + left: SetLastSquare(shape, place.FromX - WidthSquare, place.FromY, left); right: SetLastSquare(shape, place.FromX + WidthSquare, place.FromY, right); - up: SetLastSquare(shape, place.FromX, place.FromY - HeightSquare, + up: SetLastSquare(shape, place.FromX, place.FromY - HeightSquare, up); down: SetLastSquare(shape, place.FromX, place.FromY + HeightSquare, down) @@ -274,7 +274,7 @@ begin square := ChangedShape.first; while square <> nil do begin - if (square^.x < CurBorders.left) or + if (square^.x < CurBorders.left) or (square^.x + WidthSquare - 1 > CurBorders.right) or (square^.y + HeightSquare - 1 > CurBorders.down) then begin @@ -377,7 +377,7 @@ begin end; for j := i-1 downto 1 do begin - if (PosArr[j].square^.x = square^.x + dx) and + if (PosArr[j].square^.x = square^.x + dx) and (PosArr[j].square^.y = square^.y + dy) then begin case square^.CurDir of @@ -410,7 +410,7 @@ begin end end; -procedure PrintAndHideShape(shape: ShapeList; CurBorders: borders; +procedure PrintAndHideShape(shape: ShapeList; CurBorders: borders; HideShape, HideCenter: boolean); var square: SquareItemPtr; @@ -426,7 +426,7 @@ begin begin if not IsAboveTop(square, CurBorders) then begin - if not shape.IsSquare and (square^.x+j = shape.cx) + if not shape.IsSquare and (square^.x+j = shape.cx) and (square^.y+i = shape.cy) and not HideShape and not HideCenter then IsCenter := true; @@ -465,23 +465,23 @@ begin square := shape.first; while square <> nil do begin - TempSquare := shape.first; + TempSquare := shape.first; while TempSquare <> nil do begin - if (square <> TempSquare) and + if (square <> TempSquare) and (square^.CurDir = TempSquare^.CurDir) then begin shape.cx := square^.x; shape.cy := square^.y; exit end; - TempSquare := TempSquare^.next; + TempSquare := TempSquare^.next end; - square := square^.next; + square := square^.next end end; -procedure InitEdges(var LeftEdge, RightEdge, UpEdge, DownEdge: EdgeType; +procedure InitEdges(var LeftEdge, RightEdge, UpEdge, DownEdge: EdgeType; shape: ShapeList); var square: SquareItemPtr; @@ -710,8 +710,8 @@ begin ProcValues.last^.ActualSquare := square end; -procedure MakeOffset(CurXY: MadeTurn; var pos: SquareItemPtr; - CurDir: direction; var TotalOffset: integer; +procedure MakeOffset(CurXY: MadeTurn; var pos: SquareItemPtr; + CurDir: direction; var TotalOffset: integer; var RememberValue: integer; var ProcValues: ProcValuesType); var FoundPos: SquareItemPtr; @@ -835,7 +835,7 @@ begin end end; -procedure ExtractFromArr(CurArr: ArrTurn; var pos: SquareItemPtr; +procedure ExtractFromArr(CurArr: ArrTurn; var pos: SquareItemPtr; CurDir: direction; var ProcValues: ProcValuesType); var i: integer = 1; @@ -843,7 +843,7 @@ var RememberValue: integer; FoundPos: SquareItemPtr; begin - while (i <= MaxSquaresFromCenter) and + while (i <= MaxSquaresFromCenter) and (CurArr[i].x = 0) and (CurArr[i].y = 0) do i := i + 1; if i <= MaxSquaresFromCenter then @@ -941,7 +941,7 @@ begin if (CurArr[i].x = 0) and (CurArr[i].y = 0) then continue else - MakeOffset(CurArr[i], pos, CurDir, ShiftQuantity, RememberValue, + MakeOffset(CurArr[i], pos, CurDir, ShiftQuantity, RememberValue, ProcValues) end; @@ -971,7 +971,7 @@ begin write(msg) end; -procedure UpdateChangedShape(var ChangedShape: ShapeList; +procedure UpdateChangedShape(var ChangedShape: ShapeList; AllTurns: AllTurnsType); var square: SquareItemPtr; @@ -995,7 +995,7 @@ begin ExtractFromArr(AllTurns.down, square, down, ProcValues) end; -procedure FixTurnViaArr(square: SquareItemPtr; cx, cy, NewX, NewY: integer; +procedure FixTurnViaArr(square: SquareItemPtr; cx, cy, NewX, NewY: integer; var AllTurns: AllTurnsType); begin if (square^.x <> cx) or (square^.y <> cy) then @@ -1048,7 +1048,7 @@ begin begin NewX := ChangedShape.cx - (square^.y - ChangedShape.cy); NewY := ChangedShape.cy + (square^.x - ChangedShape.cx); - FixTurnViaArr(square, ChangedShape.cx, ChangedShape.cy, NewX, NewY, + FixTurnViaArr(square, ChangedShape.cx, ChangedShape.cy, NewX, NewY, AllTurns); square := square^.next end; @@ -1097,7 +1097,7 @@ var i: integer; AllColors: array [1..ColorCount] of word = ( - Green, Cyan, Magenta, Brown, + Green, Cyan, Magenta, Brown, LightGray, DarkGray, LightBlue, LightGreen, LightCyan, LightRed, LightMagenta, Yellow, White -- cgit v1.2.3