Better code readability
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Thu, 21 Aug 2025 17:26:41 +0000 (20:26 +0300)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Thu, 21 Aug 2025 17:26:41 +0000 (20:26 +0300)
Games/Pomppu Paavo.bas

index 628fcc1..1cb3e84 100755 (executable)
@@ -468,9 +468,23 @@ IF LivesRemaining% < 0 THEN END
 END SUB\r
 \r
 SUB DrawSprite (p, o, m, fr, teler)\r
+\r
+' Renders a sprite on screen based on predefined character patterns.\r
+'\r
+' How it works:\r
+' The subroutine uses a lookup table (ao array) containing string representations\r
+' of each sprite. Each character in these strings represents a pixel color.\r
+' Depending on the parameters, it either:\r
+'   - Draws individual pixels (ScaleFactor=1)\r
+'   - Draws filled rectangles for each pixel (ScaleFactor>1 but not 50)\r
+'   - Draws flipped version of individual pixels (SpriteVariant=50)\r
+'\r
+' This flexible approach allows the same sprite data to be rendered at different\r
+' sizes and orientations without storing multiple copies of the sprite data.\r
+\r
 DIM ao(1 TO 100) AS STRING\r
 SELECT CASE m\r
-CASE 1\r
+CASE 1 ' Solid block pattern\r
 ao(1) = "00000000000000000000"\r
 ao(2) = "00111111111111111100"\r
 ao(3) = "01222222222222222210"\r
@@ -491,7 +505,7 @@ ao(17) = "01233333333333333210"
 ao(18) = "01222222222222222210"\r
 ao(19) = "00111111111111111100"\r
 ao(20) = "00000000000000000000"\r
-CASE 2\r
+CASE 2 ' Cloud sprite\r
 ao(1) = "000000022200000222220000002222222200000000000222222000000000"\r
 ao(2) = "000000022222002222222000222222222222000000222222222220000000"\r
 ao(3) = "000000222222222222222202222222222222222222222222222222200000"\r
@@ -831,7 +845,7 @@ ao(17) = "00000000330330000000"
 ao(18) = "00000000000000000000"\r
 ao(19) = "00000000000000000000"\r
 ao(20) = "00000000000000000000"\r
-CASE 17\r
+CASE 17 ' Door sprite\r
 ao(1) = "00000022222222000000"\r
 ao(2) = "00002222222222220000"\r
 ao(3) = "00022220000000222000"\r
@@ -867,30 +881,30 @@ END SELECT
 IF fr = 50 THEN GOTO 8\r
 IF fr > 1 THEN GOTO 4\r
 FOR a = 1 TO 100\r
-IF ao(a) = "" THEN GOTO 1\r
+IF ao(a) = "" THEN GOTO FinishDrawing\r
 FOR b = 1 TO LEN(ao(a))\r
 PSET ((p + b) \ teler, (o + a) \ teler), ASC(RIGHT$(LEFT$(ao(a), b), 1)) - 48\r
 NEXT b\r
 NEXT a\r
-GOTO 1\r
+GOTO FinishDrawing\r
 4\r
 FOR a = 1 TO 100\r
-IF ao(a) = "" THEN GOTO 1\r
+IF ao(a) = "" THEN GOTO FinishDrawing\r
 FOR b = 1 TO LEN(ao(a))\r
 c = ASC(RIGHT$(LEFT$(ao(a), b), 1)) - 48\r
 LINE (p + (b * fr), o + (a * fr))-(p + (b * fr) + fr, o + (a * fr) + fr), c, BF\r
 NEXT b\r
 NEXT a\r
-GOTO 1\r
+GOTO FinishDrawing\r
 8\r
 FOR a = 1 TO 100\r
-IF ao(a) = "" THEN GOTO 1\r
+IF ao(a) = "" THEN GOTO FinishDrawing\r
 FOR b = 1 TO LEN(ao(a))\r
 PSET ((p + b) \ teler, (o + a) \ teler), ASC(LEFT$(RIGHT$(ao(a), b), 1)) - 48\r
 NEXT b\r
 NEXT a\r
 \r
-1\r
+FinishDrawing:\r
 ERASE ao\r
 END SUB\r
 \r