back to scratko.xyz
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorscratko <m@scratko.xyz>2024-03-22 01:26:07 +0300
committerscratko <m@scratko.xyz>2024-03-22 01:26:07 +0300
commite9a54e7ad4cd49b4e5583da9f8ccfacf904d276c (patch)
tree0f66c90390264299981d71f8ef2be31db38730aa
parent7524bcbda6a6aa8db0b6989563602aeb5e159bdf (diff)
downloadtetris-e9a54e7ad4cd49b4e5583da9f8ccfacf904d276c.tar.gz
tetris-e9a54e7ad4cd49b4e5583da9f8ccfacf904d276c.tar.bz2
tetris-e9a54e7ad4cd49b4e5583da9f8ccfacf904d276c.zip
minor changes
-rw-r--r--figure.pp52
-rw-r--r--tetris.pas49
2 files changed, 50 insertions, 51 deletions
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
diff --git a/tetris.pas b/tetris.pas
index f3ce680..5196f9c 100644
--- a/tetris.pas
+++ b/tetris.pas
@@ -107,7 +107,7 @@ begin
esc: status.GoOut := true;
WhiteSpace: status.pause := true
end
- end;
+ end;
ClrBuf
end;
@@ -130,7 +130,7 @@ begin
end
end;
-procedure NewTetramino(var shape, NextShape: ShapeList; CurBorders: borders;
+procedure NewTetramino(var shape, NextShape: ShapeList; CurBorders: borders;
var status: GameStatus);
begin
if NextShape.first = nil then
@@ -219,12 +219,12 @@ const
type
LinesType = array [1..RulesTotal] of string[MaxLength];
var
- lines: LinesType =
+ lines: LinesType =
(
- 'Control keys:', 'moving left - <-', 'moving right - ->',
+ 'Control keys:', 'moving left - <-', 'moving right - ->',
'figure turn - ^', 'fall down - (down arrow)', 'pause - whitespace',
'exit - esc', 'Scoring system:', '50 points for completing 1 row',
- 'combo X2, X3 and X4 to the current points',
+ 'combo X2, X3 and X4 to the current points',
'You need to score 100 000 points'
);
i, x, y: integer;
@@ -278,7 +278,7 @@ begin
for i := y to y+height do
for j := x to x+width do
begin
- if ((j = x) or (j = x+width)) and (i >= y + 1) and
+ if ((j = x) or (j = x+width)) and (i >= y + 1) and
(i <= y + height - 1) then
begin
GotoXY(j, i);
@@ -288,7 +288,7 @@ begin
begin
GotoXY(j, i);
write('-')
- end
+ end
end
end;
@@ -298,7 +298,7 @@ var
begin
for i := CurBorders.up to CurBorders.down do
for j := CurBorders.left to CurBorders.right+1 do
- if (j = CurBorders.left) or
+ if (j = CurBorders.left) or
(j = CurBorders.right+1) then
begin
GotoXY(j, i);
@@ -309,7 +309,7 @@ begin
write('-')
end;
-procedure SetParamsGame(var status: GameStatus; var arr: WayFinding;
+procedure SetParamsGame(var status: GameStatus; var arr: WayFinding;
GoOut: boolean; CurBorders: borders);
begin
status.GoOut := GoOut;
@@ -329,7 +329,7 @@ begin
status.IsWin := false;
end;
-procedure ReloadGame(var arr: WayFinding; var status: GameStatus;
+procedure ReloadGame(var arr: WayFinding; var status: GameStatus;
CurBorders: borders);
const
Msg = 'Reload Game? Y/N';
@@ -368,7 +368,7 @@ begin
end
end;
-procedure CheckFillLine(var arr: WayFinding; var shape: ShapeList;
+procedure CheckFillLine(var arr: WayFinding; var shape: ShapeList;
CurBorders: borders; var status: GameStatus);
var
PosFillLine: integer;
@@ -395,8 +395,8 @@ begin
end
end;
-procedure StayAtBottom(var shape, ChangedShape, NextShape: ShapeList;
- var arr: WayFinding; CurBorders: borders;
+procedure StayAtBottom(var shape, ChangedShape, NextShape: ShapeList;
+ var arr: WayFinding; CurBorders: borders;
var status: GameStatus);
begin
ClearShape(ChangedShape.first);
@@ -413,7 +413,7 @@ begin
NewTetramino(shape, NextShape, CurBorders, status)
end;
-procedure SolveBorderProblem(var shape, ChangedShape: ShapeList;
+procedure SolveBorderProblem(var shape, ChangedShape: ShapeList;
CurBorders: borders; var status: GameStatus);
begin
ClearShape(ChangedShape.first);
@@ -450,7 +450,7 @@ begin
end;
PrintTurnsCount(status.TurnsCount)
end
- else
+ else
begin
{default direction}
shape.CurDir := down;
@@ -460,8 +460,8 @@ begin
end
end;
-procedure SolveTetraminoCollision(var shape, ChangedShape, NextShape: ShapeList;
- var arr: WayFinding; CurBorders: borders;
+procedure SolveTetraminoCollision(var shape, ChangedShape, NextShape: ShapeList;
+ var arr: WayFinding; CurBorders: borders;
var status: GameStatus);
begin
ClearShape(ChangedShape.first);
@@ -476,7 +476,7 @@ begin
exit
else
NewTetramino(shape, NextShape, CurBorders, status);
- exit
+ exit
end;
if status.TurnsCount >= LimitTurns then
begin
@@ -519,7 +519,7 @@ begin
end;
PrintTurnsCount(status.TurnsCount)
end
- else
+ else
begin
{default direction}
shape.CurDir := down;
@@ -529,7 +529,7 @@ begin
end
end;
-procedure RepositionTetramino(var shape, ChangedShape: ShapeList;
+procedure RepositionTetramino(var shape, ChangedShape: ShapeList;
CurBorders: borders; var status: GameStatus);
const
FallDown = 50;
@@ -588,7 +588,7 @@ begin
{select next direction from user}
if not status.fall then
begin
- if (status.TurnsCount < LimitTurns) and
+ if (status.TurnsCount < LimitTurns) and
FigureInVision(shape, CurBorders) and KeyPressed then
begin
SetUserDirection(shape, status);
@@ -615,7 +615,7 @@ begin
if status.pause then
begin
MakePause(status);
- delay(FastDuration)
+ delay(FastDuration)
end;
shape.CurDir := down;
status.IsUserInput := false;
@@ -637,7 +637,6 @@ const
msg2 = 'Please press any key...';
var
x, y: integer;
- key: integer;
begin
if (ScreenWidth < width) or (ScreenHeight < height) then
begin
@@ -689,7 +688,7 @@ begin
{IsObstacle's init in CheckBorders each time}
CheckBorders(shape, ChangedShape, CurBorders, IsObstacle);
if IsObstacle and (shape.CurDir = down) then
- StayAtBottom(shape, ChangedShape, NextShape, arr, CurBorders,
+ StayAtBottom(shape, ChangedShape, NextShape, arr, CurBorders,
status)
else if IsObstacle then
SolveBorderProblem(shape, ChangedShape, CurBorders, status)
@@ -697,7 +696,7 @@ begin
begin
LineInspection(shape, ChangedShape, arr, IsObstacle);
if IsObstacle then
- SolveTetraminoCollision(shape, ChangedShape, NextShape, arr,
+ SolveTetraminoCollision(shape, ChangedShape, NextShape, arr,
CurBorders, status)
else
RepositionTetramino(shape, ChangedShape, CurBorders, status)