From: Svjatoslav Agejenko Date: Thu, 21 Aug 2025 17:26:41 +0000 (+0300) Subject: Better code readability X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=5cb3bfaf7f446b5cbc6d66ce4eb6b7eb87349ed4;p=qbasicapps.git Better code readability --- diff --git a/Games/Pomppu Paavo.bas b/Games/Pomppu Paavo.bas index 628fcc1..1cb3e84 100755 --- a/Games/Pomppu Paavo.bas +++ b/Games/Pomppu Paavo.bas @@ -468,9 +468,23 @@ IF LivesRemaining% < 0 THEN END END SUB SUB DrawSprite (p, o, m, fr, teler) + +' Renders a sprite on screen based on predefined character patterns. +' +' How it works: +' The subroutine uses a lookup table (ao array) containing string representations +' of each sprite. Each character in these strings represents a pixel color. +' Depending on the parameters, it either: +' - Draws individual pixels (ScaleFactor=1) +' - Draws filled rectangles for each pixel (ScaleFactor>1 but not 50) +' - Draws flipped version of individual pixels (SpriteVariant=50) +' +' This flexible approach allows the same sprite data to be rendered at different +' sizes and orientations without storing multiple copies of the sprite data. + DIM ao(1 TO 100) AS STRING SELECT CASE m -CASE 1 +CASE 1 ' Solid block pattern ao(1) = "00000000000000000000" ao(2) = "00111111111111111100" ao(3) = "01222222222222222210" @@ -491,7 +505,7 @@ ao(17) = "01233333333333333210" ao(18) = "01222222222222222210" ao(19) = "00111111111111111100" ao(20) = "00000000000000000000" -CASE 2 +CASE 2 ' Cloud sprite ao(1) = "000000022200000222220000002222222200000000000222222000000000" ao(2) = "000000022222002222222000222222222222000000222222222220000000" ao(3) = "000000222222222222222202222222222222222222222222222222200000" @@ -831,7 +845,7 @@ ao(17) = "00000000330330000000" ao(18) = "00000000000000000000" ao(19) = "00000000000000000000" ao(20) = "00000000000000000000" -CASE 17 +CASE 17 ' Door sprite ao(1) = "00000022222222000000" ao(2) = "00002222222222220000" ao(3) = "00022220000000222000" @@ -867,30 +881,30 @@ END SELECT IF fr = 50 THEN GOTO 8 IF fr > 1 THEN GOTO 4 FOR a = 1 TO 100 -IF ao(a) = "" THEN GOTO 1 +IF ao(a) = "" THEN GOTO FinishDrawing FOR b = 1 TO LEN(ao(a)) PSET ((p + b) \ teler, (o + a) \ teler), ASC(RIGHT$(LEFT$(ao(a), b), 1)) - 48 NEXT b NEXT a -GOTO 1 +GOTO FinishDrawing 4 FOR a = 1 TO 100 -IF ao(a) = "" THEN GOTO 1 +IF ao(a) = "" THEN GOTO FinishDrawing FOR b = 1 TO LEN(ao(a)) c = ASC(RIGHT$(LEFT$(ao(a), b), 1)) - 48 LINE (p + (b * fr), o + (a * fr))-(p + (b * fr) + fr, o + (a * fr) + fr), c, BF NEXT b NEXT a -GOTO 1 +GOTO FinishDrawing 8 FOR a = 1 TO 100 -IF ao(a) = "" THEN GOTO 1 +IF ao(a) = "" THEN GOTO FinishDrawing FOR b = 1 TO LEN(ao(a)) PSET ((p + b) \ teler, (o + a) \ teler), ASC(LEFT$(RIGHT$(ao(a), b), 1)) - 48 NEXT b NEXT a -1 +FinishDrawing: ERASE ao END SUB