From: Svjatoslav Agejenko Date: Sat, 20 Apr 2024 16:15:13 +0000 (+0300) Subject: Fixed indentation and case X-Git-Url: http://www2.svjatoslav.eu/gitweb/?p=qbasicapps.git;a=commitdiff_plain;h=HEAD;hp=75f1316059c56adea365de9b40dc627486114be1 Fixed indentation and case --- diff --git a/games/checkers/checkers.bas b/games/checkers/checkers.bas index 370dc57..b5274ba 100755 --- a/games/checkers/checkers.bas +++ b/games/checkers/checkers.bas @@ -6,7 +6,7 @@ DECLARE SUB compki (m%, h%, x1%, y1%) DECLARE SUB compgo2 (h%) DECLARE SUB compgo (h%) DECLARE SUB humngo (h%) -DEFINT A-Z +DefInt A-Z DECLARE SUB thinkc () DECLARE SUB thinkh () @@ -21,491 +21,491 @@ DECLARE SUB start () DECLARE SUB mklau () DECLARE SUB showr (x, y) DECLARE SUB show () -DIM SHARED font(0 TO 7, 0 TO 7, 0 TO 255) -DIM SHARED siz, fi, ri, rs -DIM SHARED stri$ -DIM SHARED humx1, humy1, humx2, humy2 -DIM SHARED sug, smax -DIM SHARED npos AS LONG -DIM SHARED cx1, cy1, cx2, cy2 - -siz = 6 ' Board size +Dim Shared font(0 To 7, 0 To 7, 0 To 255) +Dim Shared siz, fi, ri, rs +Dim Shared stri$ +Dim Shared humx1, humy1, humx2, humy2 +Dim Shared sug, smax +Dim Shared npos As Long +Dim Shared cx1, cy1, cx2, cy2 + +siz = 6 ' Board size fi = 0 ri = 2 -smax = 3 ' thinking depth +smax = 3 ' thinking depth -DIM SHARED lau(-1 TO siz + 2, -1 TO siz + 2) +Dim Shared lau(-1 To siz + 2, -1 To siz + 2) start mklau show playg -SUB cmd (a$) - -mitus = 0 -DIM sona$(1 TO 10) -FOR b = 1 TO 10 -sona$(b) = "" -NEXT b - -d = 1 -e = 1 -FOR b = 1 TO LEN(a$) -c$ = RIGHT$(LEFT$(a$, b), 1) -IF c$ = " " THEN -IF e = 0 THEN d = d + 1: e = 1 -GOTO 4 -END IF -e = 0 -sona$(d) = sona$(d) + c$ -4 -NEXT b -IF e = 1 THEN d = d - 1 -mitus = d - - -SELECT CASE sona$(1) -CASE "m" -IF humx1 > 0 THEN msg "move replaced", 14 - -humx1 = ASC(LEFT$(sona$(2), 1)) - 64 -IF humx1 > 32 THEN humx1 = humx1 - 32 -humy1 = VAL(RIGHT$(sona$(2), LEN(sona$(2)) - 1)) -humx2 = ASC(LEFT$(sona$(3), 1)) - 64 -IF humx2 > 32 THEN humx2 = humx2 - 32 -humy2 = VAL(RIGHT$(sona$(3), LEN(sona$(2)) - 1)) - -CASE "h" -msg "h - display help screen", 14 -msg "q - to quit", 14 -msg "m - make move", 14 -msg "n - no. positions processed", 14 - -CASE "q" -SYSTEM - -CASE "n" -b$ = "positions processed:" + STR$(npos) -msg b$, 14 - -END SELECT - -END SUB - -SUB compgo (h) -IF sug > smax THEN h = 0: GOTO 6 -sug = sug + 1 -npos = npos + 1 -freet -IF sug = 1 THEN h1 = -2000 ELSE h1 = -1000 - -'cx1 = x: cy1 = y: cx2 = x - 1: cy2 = y + 1 -b = 0 -c = 0 -m = 0 -FOR y = 1 TO siz ' check for eating -FOR x = 1 TO siz -IF lau(x, y) = 1 THEN -8 -IF (lau(x - 1, y + 1) = 2) AND (lau(x - 2, y + 2) = 0) THEN -SWAP lau(x, y), lau(x - 2, y + 2) -lau(x - 1, y + 1) = 0 -compki m1, h2, x - 2, y + 2 -lau(x - 1, y + 1) = 2 -SWAP lau(x, y), lau(x - 2, y + 2) -m1 = m1 + 1 -IF m1 > m THEN m = m1: h1 = -1000 -IF m1 = m THEN -IF h2 + 1 > h1 THEN -h1 = h2 + 1 -IF npos = 1 THEN cx1 = x: cy1 = y: cx2 = x - 2: cy2 = y + 2 -END IF -END IF -b = 1 -END IF - - -IF (lau(x + 1, y + 1) = 2) AND (lau(x + 2, y + 2) = 0) THEN -SWAP lau(x, y), lau(x + 2, y + 2) -lau(x + 1, y + 1) = 0 -compki m1, h2, x + 2, y + 2 -lau(x + 1, y + 1) = 2 -SWAP lau(x, y), lau(x + 2, y + 2) -m1 = m1 + 1 -IF m1 > m THEN m = m1: h1 = -1000 -IF m1 = m THEN -IF h2 + 1 > h1 THEN -h1 = h2 + 1 -IF npos = 1 THEN cx1 = x: cy1 = y: cx2 = x + 2: cy2 = y + 2 -END IF -END IF -b = 1 -END IF - - -IF (lau(x - 1, y - 1) = 2) AND (lau(x - 2, y - 2) = 0) THEN -SWAP lau(x, y), lau(x - 2, y - 2) -lau(x - 1, y - 1) = 0 -compki m1, h2, x - 2, y - 2 -lau(x - 1, y - 1) = 2 -SWAP lau(x, y), lau(x - 2, y - 2) -m1 = m1 + 1 -IF m1 > m THEN m = m1: h1 = -1000 -IF m1 = m THEN -IF h2 + 1 > h1 THEN -h1 = h2 + 1 -IF npos = 1 THEN cx1 = x: cy1 = y: cx2 = x - 2: cy2 = y - 2 -END IF -END IF -b = 1 -END IF - - -IF (lau(x + 1, y - 1) = 2) AND (lau(x + 2, y - 2) = 0) THEN -SWAP lau(x, y), lau(x + 2, y - 2) -lau(x + 1, y - 1) = 0 -compki m1, h2, x + 2, y - 2 -lau(x + 1, y - 1) = 2 -SWAP lau(x, y), lau(x + 2, y - 2) -m1 = m1 + 1 -IF m1 > m THEN m = m1: h1 = -1000 -IF m1 = m THEN -IF h2 + 1 > h1 THEN -h1 = h2 + 1 -IF npos = 1 THEN cx1 = x: cy1 = y: cx2 = x + 2: cy2 = y - 2 -END IF -END IF -b = 1 -END IF - - - - - -IF c = 1 THEN GOTO 9 -END IF -NEXT x -NEXT y - -9 -IF (b = 1) AND (npos = 1) THEN -cx3 = (cx1 + cx2) / 2 -cy3 = (cy1 + cy2) / 2 -lau(cx3, cy3) = 0 -showr cx3, cy3 - -SWAP lau(cx1, cy1), lau(cx2, cy2) -showr cx1, cy1 -showr cx2, cy2 -msg "NJAM!", 10 -x = cx2 -y = cy2 -c = 1 -b = 0 -GOTO 8 -END IF -IF c = 1 THEN -cx1 = 1: cy1 = 1: cx2 = 1: cy2 = 1 -GOTO 10 -END IF - -IF sug = 1 THEN -msg "l��a ei saa", 4 -msg STR$(h1), 4 -END IF - -FOR y = 1 TO siz ' unuseful move -FOR x = 1 TO siz -IF lau(x, y) = 1 THEN -IF lau(x - 1, y + 1) = 0 THEN -SWAP lau(x, y), lau(x - 1, y + 1) -humngo h2 -SWAP lau(x, y), lau(x - 1, y + 1) -IF h2 > h1 THEN -h1 = h2 -IF sug = 1 THEN cx1 = x: cy1 = y: cx2 = x - 1: cy2 = y + 1 -END IF -END IF - -IF lau(x + 1, y + 1) = 0 THEN -SWAP lau(x, y), lau(x + 1, y + 1) -humngo h2 -SWAP lau(x, y), lau(x + 1, y + 1) -IF h2 > h1 THEN -h1 = h2 -IF sug = 1 THEN cx1 = x: cy1 = y: cx2 = x + 1: cy2 = y + 1 -END IF -END IF - -END IF -NEXT x -NEXT y -h = h1 -10 -sug = sug - 1 -6 -END SUB - -SUB compki (m, h, x1, y1) -h1 = 0 - -FOR y = 1 TO siz -FOR x = 1 TO siz -NEXT x -NEXT y -h = h1 - -END SUB - -SUB freet -a$ = INKEY$ -IF a$ = "" THEN -ELSE -IF a$ = CHR$(8) THEN -IF LEN(stri$) > 0 THEN -stri$ = LEFT$(stri$, LEN(stri$) - 1): GOTO 3 -END IF -END IF -IF a$ = CHR$(13) THEN -IF LEN(stri$) > 0 THEN -msg stri$, 7 -cmd stri$ -stri$ = "" -END IF -GOTO 3 -END IF -stri$ = stri$ + a$ -3 -LINE (400, 468)-(639, 479), 1, BF -prn 405, 469, 14, stri$ -END IF -END SUB - -SUB getfnt -SCREEN 13 -FOR a = 0 TO 255 -IF (a > 5) AND (a < 17) THEN GOTO 2 -LOCATE 1, 1 -PRINT CHR$(a) -2 -FOR y = 0 TO 7 -FOR x = 0 TO 7 -font(x, y, a) = POINT(x, y) -NEXT x -NEXT y -NEXT a - -END SUB - -SUB humngo (h) -npos = npos + 1 -h1 = 1000 - -FOR y = siz TO 1 STEP -1 -FOR x = siz TO 1 STEP -1 -IF lau(x, y) = 2 THEN -IF lau(x - 1, y - 1) = 0 THEN -SWAP lau(x, y), lau(x - 1, y - 1) -compgo h2 -SWAP lau(x, y), lau(x - 1, y - 1) -IF h2 < h1 THEN h1 = h2 -END IF - -IF lau(x + 1, y - 1) = 0 THEN -SWAP lau(x, y), lau(x + 1, y - 1) -compgo h2 -SWAP lau(x, y), lau(x + 1, y - 1) -IF h2 < h1 THEN h1 = h2 -END IF - - -IF (lau(x - 1, y - 1) = 1) AND (lau(x - 2, y - 2) = 0) THEN -SWAP lau(x, y), lau(x - 2, y - 2) -lau(x - 1, y - 1) = 0 -humngo h2 -lau(x - 1, y - 1) = 1 -SWAP lau(x, y), lau(x - 2, y - 2) -IF h2 - 1 < h1 THEN h1 = h2 - 1 -END IF - -IF (lau(x + 1, y - 1) = 1) AND (lau(x + 2, y - 2) = 0) THEN -SWAP lau(x, y), lau(x + 2, y - 2) -lau(x + 1, y - 1) = 0 -humngo h2 -lau(x + 1, y - 1) = 1 -SWAP lau(x, y), lau(x + 2, y - 2) -IF h2 - 1 < h1 THEN h1 = h2 - 1 -END IF - - - - -END IF -NEXT x -NEXT y -h = h1 -END SUB - -SUB mklau -FOR y = -1 TO siz + 2 -FOR x = -1 TO siz + 2 -lau(x, y) = -1 -NEXT x -NEXT y - -FOR y = 1 TO siz -FOR x = 1 TO siz -lau(x, y) = 0 -NEXT x -NEXT y - -FOR y = 1 TO ri -FOR x = 1 TO siz -IF (x + y + fi) / 2 = INT((x + y + fi) / 2) THEN -lau(x, y) = 1 -END IF -NEXT x -NEXT y - -FOR y = siz - ri + 1 TO siz -FOR x = 1 TO siz -IF (x + y + fi) / 2 = INT((x + y + fi) / 2) THEN -lau(x, y) = 2 -END IF -NEXT x -NEXT y - -END SUB - -SUB msg (a$, c) -DIM buf(1 TO 10000) -FOR x = 400 TO 630 STEP 40 -GET (x, 8)-(x + 39, 467), buf(1) -PUT (x, 0), buf(1), PSET -NEXT x -LINE (400, 460)-(639, 467), 0, BF -prn 405, 460, c, a$ -END SUB - -SUB playg -'GOTO 7 -1 -thinkc -show -7 -thinkh -show -GOTO 1 - - -END SUB - -SUB prn (x, y, c, a$) -x1 = x -y1 = y -FOR a = 1 TO LEN(a$) -b = ASC(RIGHT$(LEFT$(a$, a), 1)) -FOR y2 = 0 TO 7 -FOR x2 = 0 TO 7 -IF font(x2, y2, b) > 0 THEN PSET (x2 + x1, y2 + y1), c -NEXT x2 -NEXT y2 -x1 = x1 + 8 -NEXT a -END SUB - -SUB show -FOR y = 1 TO siz -FOR x = 1 TO siz -showr x, y -NEXT x -NEXT y - -sp = rs / 2 -FOR x = 1 TO siz -prn ((x - 1) * rs + 12 + sp), 2, 10, CHR$(64 + x) -prn ((x - 1) * rs + 12 + sp), siz * rs + 11, 10, CHR$(64 + x) -NEXT x - -FOR y = 1 TO siz -a$ = STR$(y) -a$ = RIGHT$(a$, LEN(a$) - 1) -prn 15 - (LEN(a$) * 8), (y - 1) * rs + sp + 7, 10, a$ -prn (siz * rs + 16), (y - 1) * rs + sp + 7, 10, a$ -NEXT y - - -END SUB - -SUB showr (x, y) -IF (x + y + fi) / 2 = INT((x + y + fi) / 2) THEN c = 8 ELSE c = 7 -x1 = (x - 1) * rs + 15 -y1 = (y - 1) * rs + 10 -LINE (x1, y1)-(x1 + rs - 1, y1 + rs - 1), c, BF -IF lau(x, y) > 0 THEN -sp = rs / 2 -IF lau(x, y) = 1 THEN c1 = 15 ELSE c1 = 14 -CIRCLE (x1 + sp, y1 + sp), sp - 1, c1 -PAINT (x1 + sp, y1 + sp), c1 -END IF -END SUB - -SUB start -getfnt -SCREEN 12 -LINE (399, 0)-(399, 479), 13 -msg "type 'h' for help", 14 - -rs = INT(370 / siz) - - -END SUB - -SUB thinkc -msg "computer turn", 14 -sug = 0 -npos = 0 -cx1 = -1 - -compgo h -cmd "n" -IF cx1 = -1 THEN msg "you won!", 10: msg "--------", 10: SYSTEM - -IF h <= -2 THEN msg "oh no...", 10 -IF h = -1 THEN msg "oops!", 10 -IF h = 1 THEN msg "yess! I will eat soon!", 10 -IF h >= 2 THEN msg "HA HA HA YOU ARE IN TROUBLE!", 10 - - -IF ABS(cx1 - cx2) = 2 THEN -cx3 = (cx1 + cx2) / 2 -cy3 = (cy1 + cy2) / 2 -lau(cx3, cy3) = 0 -showr cx3, cy3 -END IF - -SWAP lau(cx1, cy1), lau(cx2, cy2) -showr cx1, cy1 -showr cx2, cy2 - -END SUB - -SUB thinkh -msg "your turn", 14 -5 -freet -IF humx1 = 0 THEN GOTO 5 -SWAP lau(humx2, humy2), lau(humx1, humy1) -showr humx1, humy1 -showr humx2, humy2 -IF ABS(humx1 - humx2) = 2 THEN -cx3 = (humx1 + humx2) / 2 -cy3 = (humy1 + humy2) / 2 -lau(cx3, cy3) = 0 -showr cx3, cy3 -END IF - -humx1 = 0 -END SUB +Sub cmd (a$) + + mitus = 0 + Dim sona$(1 To 10) + For b = 1 To 10 + sona$(b) = "" + Next b + + d = 1 + e = 1 + For b = 1 To Len(a$) + c$ = Right$(Left$(a$, b), 1) + If c$ = " " Then + If e = 0 Then d = d + 1: e = 1 + GoTo 4 + End If + e = 0 + sona$(d) = sona$(d) + c$ + 4 + Next b + If e = 1 Then d = d - 1 + mitus = d + + + Select Case sona$(1) + Case "m" + If humx1 > 0 Then msg "move replaced", 14 + + humx1 = Asc(Left$(sona$(2), 1)) - 64 + If humx1 > 32 Then humx1 = humx1 - 32 + humy1 = Val(Right$(sona$(2), Len(sona$(2)) - 1)) + humx2 = Asc(Left$(sona$(3), 1)) - 64 + If humx2 > 32 Then humx2 = humx2 - 32 + humy2 = Val(Right$(sona$(3), Len(sona$(2)) - 1)) + + Case "h" + msg "h - display help screen", 14 + msg "q - to quit", 14 + msg "m - make move", 14 + msg "n - no. positions processed", 14 + + Case "q" + System + + Case "n" + b$ = "positions processed:" + Str$(npos) + msg b$, 14 + + End Select + +End Sub + +Sub compgo (h) + If sug > smax Then h = 0: GoTo 6 + sug = sug + 1 + npos = npos + 1 + freet + If sug = 1 Then h1 = -2000 Else h1 = -1000 + + 'cx1 = x: cy1 = y: cx2 = x - 1: cy2 = y + 1 + b = 0 + c = 0 + m = 0 + For y = 1 To siz ' check for eating + For x = 1 To siz + If lau(x, y) = 1 Then + 8 + If (lau(x - 1, y + 1) = 2) And (lau(x - 2, y + 2) = 0) Then + Swap lau(x, y), lau(x - 2, y + 2) + lau(x - 1, y + 1) = 0 + compki m1, h2, x - 2, y + 2 + lau(x - 1, y + 1) = 2 + Swap lau(x, y), lau(x - 2, y + 2) + m1 = m1 + 1 + If m1 > m Then m = m1: h1 = -1000 + If m1 = m Then + If h2 + 1 > h1 Then + h1 = h2 + 1 + If npos = 1 Then cx1 = x: cy1 = y: cx2 = x - 2: cy2 = y + 2 + End If + End If + b = 1 + End If + + + If (lau(x + 1, y + 1) = 2) And (lau(x + 2, y + 2) = 0) Then + Swap lau(x, y), lau(x + 2, y + 2) + lau(x + 1, y + 1) = 0 + compki m1, h2, x + 2, y + 2 + lau(x + 1, y + 1) = 2 + Swap lau(x, y), lau(x + 2, y + 2) + m1 = m1 + 1 + If m1 > m Then m = m1: h1 = -1000 + If m1 = m Then + If h2 + 1 > h1 Then + h1 = h2 + 1 + If npos = 1 Then cx1 = x: cy1 = y: cx2 = x + 2: cy2 = y + 2 + End If + End If + b = 1 + End If + + + If (lau(x - 1, y - 1) = 2) And (lau(x - 2, y - 2) = 0) Then + Swap lau(x, y), lau(x - 2, y - 2) + lau(x - 1, y - 1) = 0 + compki m1, h2, x - 2, y - 2 + lau(x - 1, y - 1) = 2 + Swap lau(x, y), lau(x - 2, y - 2) + m1 = m1 + 1 + If m1 > m Then m = m1: h1 = -1000 + If m1 = m Then + If h2 + 1 > h1 Then + h1 = h2 + 1 + If npos = 1 Then cx1 = x: cy1 = y: cx2 = x - 2: cy2 = y - 2 + End If + End If + b = 1 + End If + + + If (lau(x + 1, y - 1) = 2) And (lau(x + 2, y - 2) = 0) Then + Swap lau(x, y), lau(x + 2, y - 2) + lau(x + 1, y - 1) = 0 + compki m1, h2, x + 2, y - 2 + lau(x + 1, y - 1) = 2 + Swap lau(x, y), lau(x + 2, y - 2) + m1 = m1 + 1 + If m1 > m Then m = m1: h1 = -1000 + If m1 = m Then + If h2 + 1 > h1 Then + h1 = h2 + 1 + If npos = 1 Then cx1 = x: cy1 = y: cx2 = x + 2: cy2 = y - 2 + End If + End If + b = 1 + End If + + + + + + If c = 1 Then GoTo 9 + End If + Next x + Next y + + 9 + If (b = 1) And (npos = 1) Then + cx3 = (cx1 + cx2) / 2 + cy3 = (cy1 + cy2) / 2 + lau(cx3, cy3) = 0 + showr cx3, cy3 + + Swap lau(cx1, cy1), lau(cx2, cy2) + showr cx1, cy1 + showr cx2, cy2 + msg "NJAM!", 10 + x = cx2 + y = cy2 + c = 1 + b = 0 + GoTo 8 + End If + If c = 1 Then + cx1 = 1: cy1 = 1: cx2 = 1: cy2 = 1 + GoTo 10 + End If + + If sug = 1 Then + msg "l��a ei saa", 4 + msg Str$(h1), 4 + End If + + For y = 1 To siz ' unuseful move + For x = 1 To siz + If lau(x, y) = 1 Then + If lau(x - 1, y + 1) = 0 Then + Swap lau(x, y), lau(x - 1, y + 1) + humngo h2 + Swap lau(x, y), lau(x - 1, y + 1) + If h2 > h1 Then + h1 = h2 + If sug = 1 Then cx1 = x: cy1 = y: cx2 = x - 1: cy2 = y + 1 + End If + End If + + If lau(x + 1, y + 1) = 0 Then + Swap lau(x, y), lau(x + 1, y + 1) + humngo h2 + Swap lau(x, y), lau(x + 1, y + 1) + If h2 > h1 Then + h1 = h2 + If sug = 1 Then cx1 = x: cy1 = y: cx2 = x + 1: cy2 = y + 1 + End If + End If + + End If + Next x + Next y + h = h1 + 10 + sug = sug - 1 + 6 +End Sub + +Sub compki (m, h, x1, y1) + h1 = 0 + + For y = 1 To siz + For x = 1 To siz + Next x + Next y + h = h1 + +End Sub + +Sub freet + a$ = InKey$ + If a$ = "" Then + Else + If a$ = Chr$(8) Then + If Len(stri$) > 0 Then + stri$ = Left$(stri$, Len(stri$) - 1): GoTo 3 + End If + End If + If a$ = Chr$(13) Then + If Len(stri$) > 0 Then + msg stri$, 7 + cmd stri$ + stri$ = "" + End If + GoTo 3 + End If + stri$ = stri$ + a$ + 3 + Line (400, 468)-(639, 479), 1, BF + prn 405, 469, 14, stri$ + End If +End Sub + +Sub getfnt + Screen 13 + For a = 0 To 255 + If (a > 5) And (a < 17) Then GoTo 2 + Locate 1, 1 + Print Chr$(a) + 2 + For y = 0 To 7 + For x = 0 To 7 + font(x, y, a) = Point(x, y) + Next x + Next y + Next a + +End Sub + +Sub humngo (h) + npos = npos + 1 + h1 = 1000 + + For y = siz To 1 Step -1 + For x = siz To 1 Step -1 + If lau(x, y) = 2 Then + If lau(x - 1, y - 1) = 0 Then + Swap lau(x, y), lau(x - 1, y - 1) + compgo h2 + Swap lau(x, y), lau(x - 1, y - 1) + If h2 < h1 Then h1 = h2 + End If + + If lau(x + 1, y - 1) = 0 Then + Swap lau(x, y), lau(x + 1, y - 1) + compgo h2 + Swap lau(x, y), lau(x + 1, y - 1) + If h2 < h1 Then h1 = h2 + End If + + + If (lau(x - 1, y - 1) = 1) And (lau(x - 2, y - 2) = 0) Then + Swap lau(x, y), lau(x - 2, y - 2) + lau(x - 1, y - 1) = 0 + humngo h2 + lau(x - 1, y - 1) = 1 + Swap lau(x, y), lau(x - 2, y - 2) + If h2 - 1 < h1 Then h1 = h2 - 1 + End If + + If (lau(x + 1, y - 1) = 1) And (lau(x + 2, y - 2) = 0) Then + Swap lau(x, y), lau(x + 2, y - 2) + lau(x + 1, y - 1) = 0 + humngo h2 + lau(x + 1, y - 1) = 1 + Swap lau(x, y), lau(x + 2, y - 2) + If h2 - 1 < h1 Then h1 = h2 - 1 + End If + + + + + End If + Next x + Next y + h = h1 +End Sub + +Sub mklau + For y = -1 To siz + 2 + For x = -1 To siz + 2 + lau(x, y) = -1 + Next x + Next y + + For y = 1 To siz + For x = 1 To siz + lau(x, y) = 0 + Next x + Next y + + For y = 1 To ri + For x = 1 To siz + If (x + y + fi) / 2 = Int((x + y + fi) / 2) Then + lau(x, y) = 1 + End If + Next x + Next y + + For y = siz - ri + 1 To siz + For x = 1 To siz + If (x + y + fi) / 2 = Int((x + y + fi) / 2) Then + lau(x, y) = 2 + End If + Next x + Next y + +End Sub + +Sub msg (a$, c) + Dim buf(1 To 10000) + For x = 400 To 630 Step 40 + Get (x, 8)-(x + 39, 467), buf(1) + Put (x, 0), buf(1), PSet + Next x + Line (400, 460)-(639, 467), 0, BF + prn 405, 460, c, a$ +End Sub + +Sub playg + 'GOTO 7 + 1 + thinkc + show + 7 + thinkh + show + GoTo 1 + + +End Sub + +Sub prn (x, y, c, a$) + x1 = x + y1 = y + For a = 1 To Len(a$) + b = Asc(Right$(Left$(a$, a), 1)) + For y2 = 0 To 7 + For x2 = 0 To 7 + If font(x2, y2, b) > 0 Then PSet (x2 + x1, y2 + y1), c + Next x2 + Next y2 + x1 = x1 + 8 + Next a +End Sub + +Sub show + For y = 1 To siz + For x = 1 To siz + showr x, y + Next x + Next y + + sp = rs / 2 + For x = 1 To siz + prn ((x - 1) * rs + 12 + sp), 2, 10, Chr$(64 + x) + prn ((x - 1) * rs + 12 + sp), siz * rs + 11, 10, Chr$(64 + x) + Next x + + For y = 1 To siz + a$ = Str$(y) + a$ = Right$(a$, Len(a$) - 1) + prn 15 - (Len(a$) * 8), (y - 1) * rs + sp + 7, 10, a$ + prn (siz * rs + 16), (y - 1) * rs + sp + 7, 10, a$ + Next y + + +End Sub + +Sub showr (x, y) + If (x + y + fi) / 2 = Int((x + y + fi) / 2) Then c = 8 Else c = 7 + x1 = (x - 1) * rs + 15 + y1 = (y - 1) * rs + 10 + Line (x1, y1)-(x1 + rs - 1, y1 + rs - 1), c, BF + If lau(x, y) > 0 Then + sp = rs / 2 + If lau(x, y) = 1 Then c1 = 15 Else c1 = 14 + Circle (x1 + sp, y1 + sp), sp - 1, c1 + Paint (x1 + sp, y1 + sp), c1 + End If +End Sub + +Sub start + getfnt + Screen 12 + Line (399, 0)-(399, 479), 13 + msg "type 'h' for help", 14 + + rs = Int(370 / siz) + + +End Sub + +Sub thinkc + msg "computer turn", 14 + sug = 0 + npos = 0 + cx1 = -1 + + compgo h + cmd "n" + If cx1 = -1 Then msg "you won!", 10: msg "--------", 10: System + + If h <= -2 Then msg "oh no...", 10 + If h = -1 Then msg "oops!", 10 + If h = 1 Then msg "yess! I will eat soon!", 10 + If h >= 2 Then msg "HA HA HA YOU ARE IN TROUBLE!", 10 + + + If Abs(cx1 - cx2) = 2 Then + cx3 = (cx1 + cx2) / 2 + cy3 = (cy1 + cy2) / 2 + lau(cx3, cy3) = 0 + showr cx3, cy3 + End If + + Swap lau(cx1, cy1), lau(cx2, cy2) + showr cx1, cy1 + showr cx2, cy2 + +End Sub + +Sub thinkh + msg "your turn", 14 + 5 + freet + If humx1 = 0 Then GoTo 5 + Swap lau(humx2, humy2), lau(humx1, humy1) + showr humx1, humy1 + showr humx2, humy2 + If Abs(humx1 - humx2) = 2 Then + cx3 = (humx1 + humx2) / 2 + cy3 = (humy1 + humy2) / 2 + lau(cx3, cy3) = 0 + showr cx3, cy3 + End If + + humx1 = 0 +End Sub diff --git a/graphics/3D/!.bas b/graphics/3D/!.bas old mode 100755 new mode 100644 index ad670ef..c4e886f --- a/graphics/3D/!.bas +++ b/graphics/3D/!.bas @@ -1,265 +1,233 @@ -' Svjatoslav Agejenko -' Use keys: -' Up, Down, Left, Right, w, z - rotate -' - speed down -' q - quit - -DECLARE SUB getcor () -DECLARE SUB mulcor () -DECLARE SUB nait3d () -DECLARE SUB calcsin () -DEFINT A-Z -DIM SHARED Xn(100), Yn(100), Zn(100) -DIM SHARED Xs1(100), Ys1(100), Xe1(100), Ye1(100) -DIM SHARED x(100), y(100), z(100), pointers1(100), pointers2(100) -DIM SHARED Cosine&(360), Sine&(360) -DIM SHARED np, nl -DIM SHARED jrp, jrl -jrp = 0 -jrl = 0 - - -SCREEN 12 -CLS - - -calcsin -getcor -mulcor -nait3d - - - - -DATA 5, -60, -10 -DATA 15,-50, -10 -DATA 15, 0, -10 -DATA 5, 10, -10 -DATA -5, 10, -10 -DATA -15, 0, -10 -DATA -15,-50, -10 -DATA -5, -60, -10 - -DATA 5, -60, 10 -DATA 15,-50, 10 -DATA 15, 0, 10 -DATA 5, 10, 10 -DATA -5, 10, 10 -DATA -15, 0, 10 -DATA -15,-50, 10 -DATA -5, -60, 10 - -DATA 5, 20, 10 -DATA 15, 30, 10 -DATA 15, 40, 10 -DATA 5, 50, 10 -DATA -5, 50, 10 -DATA -15, 40, 10 -DATA -15, 30, 10 -DATA -5, 20, 10 - -DATA 5, 20, -10 -DATA 15, 30, -10 -DATA 15, 40, -10 -DATA 5, 50, -10 -DATA -5, 50, -10 -DATA -15, 40, -10 -DATA -15, 30, -10 -DATA -5, 20, -10 - -DATA 999,999,999 - -DATA 0,1 -DATA 1,2 -DATA 2,3 -DATA 3,4 -DATA 4,5 -DATA 5,6 -DATA 6,7 -DATA 7,0 - -DATA 8,9 -DATA 9,10 -DATA 10,11 -DATA 11,12 -DATA 12,13 -DATA 13,14 -DATA 14,15 -DATA 15,8 - - -DATA 0,8 -DATA 1,9 -DATA 2,10 -DATA 3,11 -DATA 4,12 -DATA 5,13 -DATA 6,14 -DATA 7,15 - -DATA 16,17 -DATA 17,18 -DATA 18,19 -DATA 19,20 -DATA 20,21 -DATA 21,22 -DATA 22,23 -DATA 23,16 - - -DATA 24,25 -DATA 25,26 -DATA 26,27 -DATA 27,28 -DATA 28,29 -DATA 29,30 -DATA 30,31 -DATA 31,24 - -DATA 24,16 -DATA 25,17 -DATA 26,18 -DATA 27,19 -DATA 28,20 -DATA 29,21 -DATA 30,22 -DATA 31,23 - -DATA 999, 999 - -SUB calcsin -FOR a! = 0 TO 359 / 57.29577951# STEP 1 / 57.29577951# - Cosine&(a) = INT(.5 + COS(a!) * 1024) - Sine&(a) = INT(.5 + SIN(a!) * 1024) - a = a + 1 -NEXT -END SUB - -SUB getcor -FOR a = 0 TO 10000 - READ x(a), y(a), z(a) - IF x(a) = 999 THEN x(a) = 0: y(a) = 0: z(a) = 0: GOTO 1 -NEXT -1 -np = a - -FOR a = 0 TO 10000 - READ pointers1(a), pointers2(a) - IF pointers1(a) = 999 THEN GOTO 2 -NEXT -2 -nl = a - -END SUB - -SUB mulcor -suur = 0 -FOR a = 0 TO np -IF ABS(x(a)) > suur THEN suur = ABS(x(a)) -IF ABS(y(a)) > suur THEN suur = ABS(y(a)) -IF ABS(z(a)) > suur THEN suur = ABS(z(a)) -NEXT a -ksuur = 100 / suur - -FOR a = 0 TO np -x(a) = x(a) * ksuur -y(a) = y(a) * ksuur -z(a) = z(a) * ksuur -NEXT a -END SUB - -SUB nait3d - -DO - - Deg1 = Deg1 + d1 - Deg2 = Deg2 + d2 - Deg3 = Deg3 + d3 - - IF Deg1 <= 0 THEN Deg1 = Deg1 + 360 - IF Deg2 <= 0 THEN Deg2 = Deg2 + 360 - IF Deg3 <= 0 THEN Deg3 = Deg3 + 360 - - IF Deg1 >= 360 THEN Deg1 = Deg1 - 360 - IF Deg2 >= 360 THEN Deg2 = Deg2 - 360 - IF Deg3 >= 360 THEN Deg3 = Deg3 - 360 - - C1& = Cosine&(Deg1): S1& = Sine&(Deg1) - C2& = Cosine&(Deg2): S2& = Sine&(Deg2) - C3& = Cosine&(Deg3): S3& = Sine&(Deg3) - -FOR a = 0 TO np - 1 -R = a -Xo = x(R): Yo = y(R): Zo = z(R) - -X1 = (Xo * C1& - Yo * S1&) \ 1024 -Y1 = (Xo * S1& + Yo * C1&) \ 1024 - -X2& = (X1 * C2& - Zo * S2&) \ 1024 -z1 = (X1 * S2& + Zo * C2&) \ 1024 - -Y2& = (Y1 * C3& - z1 * S3&) \ 1024 -z2 = (Y1 * S3& + z1 * C3&) \ 1024 - -z2 = z2 + 300 -Xn(R) = 320 + (X2& / z2 * 500) -Yn(R) = 240 + (Y2& / z2 * 500) -NEXT - - -FOR a1 = 0 TO nl - 1 -F1 = pointers1(a1) -S1 = pointers2(a1) - -Xn = Xn(F1) -Yn = Yn(F1) - -X1 = Xn(S1) -Y1 = Yn(S1) - -LINE (Xs1(a1), Ys1(a1))-(Xe1(a1), Ye1(a1)), 0 -LINE (X1, Y1)-(Xn, Yn), 15 - - -Xs1(a1) = X1: Ys1(a1) = Y1 -Xe1(a1) = Xn: Ye1(a1) = Yn -NEXT - - -K$ = INKEY$ -IF K$ <> "" THEN - -SELECT CASE K$ - -CASE CHR$(0) + CHR$(72) -d1 = d1 + 1 - -CASE CHR$(0) + CHR$(80) -d1 = d1 - 1 - -CASE CHR$(0) + CHR$(75) -d2 = d2 - 1 - -CASE CHR$(0) + CHR$(77) -d2 = d2 + 1 - -CASE "w" -d3 = d3 - 1 - -CASE "z" -d3 = d3 + 1 - -CASE " " -d1 = d1 / 2 -d2 = d2 / 2 -d3 = d3 / 2 - -CASE CHR$(27) -SYSTEM - -END SELECT -END IF - -LOOP -END SUB - +' 3D Wireframe Exclamation mark +' Author: Svjatoslav Agejenko +' Use keys: +' Up, Down, Left, Right, w, z - rotate +' - speed down +' q - quit + +DECLARE SUB GetCoordinates () +DECLARE SUB ScaleCoordinates () +DECLARE SUB Render3D () +DECLARE SUB CalculateSineCosine () + +DefInt A-Z +Dim Shared Xn(100), Yn(100), Zn(100) +Dim Shared Xs1(100), Ys1(100), Xe1(100), Ye1(100) +Dim Shared x(100), y(100), z(100), pointers1(100), pointers2(100) +Dim Shared Cosine&(360), Sine&(360) +Dim Shared numPoints, numLines +Dim Shared rotationX, rotationY +rotationX = 0 +rotationY = 0 + +Screen 12 +Cls +CalculateSineCosine +GetCoordinates +ScaleCoordinates +Render3D + +' Vertex data +Data 5,-60,-10 +Data 15,-50,-10 +Data 15,0,-10 +Data 5,10,-10 +Data -5,10,-10 +Data -15,0,-10 +Data -15,-50,-10 +Data -5,-60,-10 +Data 5,-60,10 +Data 15,-50,10 +Data 15,0,10 +Data 5,10,10 +Data -5,10,10 +Data -15,0,10 +Data -15,-50,10 +Data -5,-60,10 +Data 5,20,10 +Data 15,30,10 +Data 15,40,10 +Data 5,50,10 +Data -5,50,10 +Data -15,40,10 +Data -15,30,10 +Data -5,20,10 +Data 5,20,-10 +Data 15,30,-10 +Data 15,40,-10 +Data 5,50,-10 +Data -5,50,-10 +Data -15,40,-10 +Data -15,30,-10 +Data -5,20,-10 +Data 999,999,999 + +' Line data +Data 0,1 +Data 1,2 +Data 2,3 +Data 3,4 +Data 4,5 +Data 5,6 +Data 6,7 +Data 7,0 +Data 8,9 +Data 9,10 +Data 10,11 +Data 11,12 +Data 12,13 +Data 13,14 +Data 14,15 +Data 15,8 +Data 0,8 +Data 1,9 +Data 2,10 +Data 3,11 +Data 4,12 +Data 5,13 +Data 6,14 +Data 7,15 +Data 16,17 +Data 17,18 +Data 18,19 +Data 19,20 +Data 20,21 +Data 21,22 +Data 22,23 +Data 23,16 +Data 24,25 +Data 25,26 +Data 26,27 +Data 27,28 +Data 28,29 +Data 29,30 +Data 30,31 +Data 31,24 +Data 24,16 +Data 25,17 +Data 26,18 +Data 27,19 +Data 28,20 +Data 29,21 +Data 30,22 +Data 31,23 +Data 999,999 + +Sub CalculateSineCosine + ' Precalculate sine and cosine values for faster computation + For angle! = 0 To 359 / 57.29577951# Step 1 / 57.29577951# + Cosine&(angle) = Int(.5 + Cos(angle!) * 1024) + Sine&(angle) = Int(.5 + Sin(angle!) * 1024) + angle = angle + 1 + Next +End Sub + +Sub GetCoordinates + ' Read vertex coordinates from DATA statements + For i = 0 To 10000 + Read x(i), y(i), z(i) + If x(i) = 999 Then x(i) = 0: y(i) = 0: z(i) = 0: GoTo EndVertexData + Next + EndVertexData: + numPoints = i + + ' Read line data from DATA statements + For i = 0 To 10000 + Read pointers1(i), pointers2(i) + If pointers1(i) = 999 Then GoTo EndLineData + Next + EndLineData: + numLines = i +End Sub + +Sub ScaleCoordinates + ' Scale coordinates to fit the screen + maxValue = 0 + For i = 0 To numPoints + If Abs(x(i)) > maxValue Then maxValue = Abs(x(i)) + If Abs(y(i)) > maxValue Then maxValue = Abs(y(i)) + If Abs(z(i)) > maxValue Then maxValue = Abs(z(i)) + Next i + scaleFactor = 100 / maxValue + For i = 0 To numPoints + x(i) = x(i) * scaleFactor + y(i) = y(i) * scaleFactor + z(i) = z(i) * scaleFactor + Next i +End Sub + +Sub Render3D + Do + ' Update rotation angles + rotationX = rotationX + dx + rotationY = rotationY + dy + rotationZ = rotationZ + dz + Sound 0, 1 + + ' Wrap rotation angles within 0 to 359 degrees + If rotationX <= 0 Then rotationX = rotationX + 360 + If rotationY <= 0 Then rotationY = rotationY + 360 + If rotationZ <= 0 Then rotationZ = rotationZ + 360 + If rotationX >= 360 Then rotationX = rotationX - 360 + If rotationY >= 360 Then rotationY = rotationY - 360 + If rotationZ >= 360 Then rotationZ = rotationZ - 360 + + ' Get sine and cosine values for rotation angles + cosX& = Cosine&(rotationX): sinX& = Sine&(rotationX) + cosY& = Cosine&(rotationY): sinY& = Sine&(rotationY) + cosZ& = Cosine&(rotationZ): sinZ& = Sine&(rotationZ) + + ' Rotate and project vertices + For i = 0 To numPoints - 1 + Xo = x(i): Yo = y(i): Zo = z(i) + X1 = (Xo * cosX& - Yo * sinX&) \ 1024 + Y1 = (Xo * sinX& + Yo * cosX&) \ 1024 + X2& = (X1 * cosY& - Zo * sinY&) \ 1024 + Z1 = (X1 * sinY& + Zo * cosY&) \ 1024 + Y2& = (Y1 * cosZ& - Z1 * sinZ&) \ 1024 + Z2 = (Y1 * sinZ& + Z1 * cosZ&) \ 1024 + Z2 = Z2 + 300 + Xn(i) = 320 + (X2& / Z2 * 500) + Yn(i) = 240 + (Y2& / Z2 * 500) + Next + + ' Draw lines between vertices + For i = 0 To numLines - 1 + startVertex = pointers1(i) + endVertex = pointers2(i) + Xn = Xn(startVertex) + Yn = Yn(startVertex) + X1 = Xn(endVertex) + Y1 = Yn(endVertex) + Line (Xs1(i), Ys1(i))-(Xe1(i), Ye1(i)), 0 + Line (X1, Y1)-(Xn, Yn), 15 + Xs1(i) = X1: Ys1(i) = Y1 + Xe1(i) = Xn: Ye1(i) = Yn + Next + + ' Handle user input + K$ = InKey$ + If K$ <> "" Then + Select Case K$ + Case Chr$(0) + Chr$(72) ' Up arrow + dx = dx + 1 + Case Chr$(0) + Chr$(80) ' Down arrow + dx = dx - 1 + Case Chr$(0) + Chr$(75) ' Left arrow + dy = dy - 1 + Case Chr$(0) + Chr$(77) ' Right arrow + dy = dy + 1 + Case "w" + dz = dz - 1 + Case "z" + dz = dz + 1 + Case " " ' Space bar + dx = dx / 2 + dy = dy / 2 + dz = dz / 2 + Case Chr$(27) ' Escape key + System + End Select + End If + Loop +End Sub \ No newline at end of file diff --git a/graphics/3D/stars.bas b/graphics/3D/stars.bas index 60a03dc..dbd0701 100755 --- a/graphics/3D/stars.bas +++ b/graphics/3D/stars.bas @@ -1,140 +1,137 @@ -' 3D starfield -' made by Svjatoslav Agejenko -' in 2003.03 -' H-Page: svjatoslav.eu -' E-Mail: svjatoslav@svjatoslav.eu - -DECLARE SUB setstar (x2!, y2!, z2!) -DECLARE SUB galaxy () -DIM SHARED mitu -DIM SHARED mituv - - -RANDOMIZE TIMER -mituv = 2000 -mitu = mituv -rns = 500 -wl = 0 - -DIM SHARED px(1 TO mitu + 1000) -DIM SHARED py(1 TO mitu + 1000) -DIM SHARED pz(1 TO mitu + 1000) - -FOR a = 1 TO mitu -pz(a) = RND * 500 + 20 - n = RND * 100 - px(a) = SIN(n) * 20 - py(a) = COS(n) * 20 -NEXT a - - -SCREEN 13 - - -frm = 10 -1 -fps = fps + 1 -IF tm$ <> TIME$ THEN -'LOCATE 1, 1 -'PRINT fps -IF fps > 20 THEN wl = wl + 2 ELSE wl = wl - 1 -IF wl < 0 THEN wl = 0 -fps = 0 -tm$ = TIME$ -END IF -frm = frm + 1 -xp = SIN(frm / 21) * 3 -yp = SIN(frm / 18) * 3 - -nrk = (3.1412) / 2 + SIN(frm / 35) / 100 + SIN(frm / 21) / 100 -rs1 = SIN(nrk) -rc1 = COS(nrk) - -FOR a = 1 TO mitu -x = px(a) -y = py(a) -z = pz(a) -x1 = x / z * 160 + 160 -y1 = y / z * 100 + 100 -PSET (x1, y1), 0 - -x5 = x * rs1 - y * rc1 -y5 = x * rc1 + y * rs1 - -x = x5 -y = y5 - -z = z - 3 -x = x + xp -y = y + yp -IF z < 10 THEN -z = RND * 300 + 400 -x = RND * 800 - 400 -y = RND * 800 - 400 -END IF - -x1 = x / z * 160 + 160 -y1 = y / z * 100 + 100 -c = 3000 / z + 15 -IF c > 31 THEN c = 31 -PSET (x1, y1), c - -px(a) = x -py(a) = y -pz(a) = z -NEXT a - - -IF mituv - mitu > rns THEN galaxy: rns = RND * 800 + 100 - -FOR a = 1 TO 2 -b = RND * (mitu - 10) + 1 -SWAP px(mitu), px(b) -SWAP py(mitu), py(b) -SWAP pz(mitu), pz(b) - -x = px(mitu) -y = py(mitu) -z = pz(mitu) -x1 = x / z * 160 + 160 -y1 = y / z * 100 + 100 -PSET (x1, y1), 0 -mitu = mitu - 1 -NEXT a - -'LOCATE 2, 1 -'PRINT wl -FOR a = 0 TO wl -FOR b = 0 TO 1000 -c = c / 100 -NEXT b -NEXT a - -IF INKEY$ <> "" THEN SYSTEM -GOTO 1 - -SUB galaxy - -xf = RND * 4 - 2 -yf = RND * 4 - 2 -xp = RND * 200 - 100 -yp = RND * 200 - 100 - -FOR a = 1 TO RND * 15 + 10 STEP .04 -x = SIN(a) * a * a / 10 -y = COS(a) * a * a / 10 -setstar x + RND * a * a / 30 + xp, y + RND * a * a / 30 + yp, 700 + RND * a * a / 30 + (x * xf) + (y * yf) -NEXT a - -'SOUND 1000, 1 -END SUB - -SUB setstar (x2, y2, z2) -mitu = mitu + 1 -s = mitu - -px(s) = x2 -py(s) = y2 -pz(s) = z2 -END SUB +' 3D Starfield Simulation +' Originally made by Svjatoslav Agejenko in 2003.03 +' In 2024 code was modernized using artificial intelligence +' Homepage: svjatoslav.eu +' Email: svjatoslav@svjatoslav.eu + +DECLARE SUB AddStar (xPosition AS SINGLE, yPosition AS SINGLE, zPosition AS SINGLE) +DECLARE SUB CreateGalaxy () + +Dim Shared totalStars As Integer +Dim Shared maxStars As Integer + +Randomize Timer +maxStars = 2000 +totalStars = maxStars +starFieldDepth = 500 + +Dim Shared starXPositions(1 To maxStars + 1000) As Single +Dim Shared starYPositions(1 To maxStars + 1000) As Single +Dim Shared starZPositions(1 To maxStars + 1000) As Single + +' Initialize the positions of the stars +For starIndex = 1 To totalStars + starZPositions(starIndex) = Rnd * starFieldDepth + 20 + angle = Rnd * 100 + starXPositions(starIndex) = Sin(angle) * 20 + starYPositions(starIndex) = Cos(angle) * 20 +Next starIndex + +Screen 13 + + +Do + + ' Calculate the camera's rotation and position offsets + frameCount = frameCount + 1 + cameraRotation = (3.1412 / 2) + Sin(frameCount / 35) / 100 + Sin(frameCount / 21) / 100 + rs1 = Sin(cameraRotation) + rc1 = Cos(cameraRotation) + + ' Update and draw each star + For starIndex = 1 To totalStars + x = starXPositions(starIndex) + y = starYPositions(starIndex) + z = starZPositions(starIndex) + + ' Project the star's 3D position onto the 2D screen + projectedX = (x / z) * 160 + 160 + projectedY = (y / z) * 100 + 100 + PSet (projectedX, projectedY), 0 ' Erase the previous position + + ' Rotate the star's position around the camera + x5 = x * rs1 - y * rc1 + y5 = x * rc1 + y * rs1 + + ' Update the star's position with camera movement + x = x5 + Sin(frameCount / 21) * 3 + y = y5 + Sin(frameCount / 18) * 3 + + ' Move the star closer to the viewer and wrap around if too close + z = z - 3 + If z < 10 Then + z = Rnd * 300 + 400 + x = Rnd * 800 - 400 + y = Rnd * 800 - 400 + End If + + ' Project the new position and draw with perspective-based brightness + projectedX = (x / z) * 160 + 160 + projectedY = (y / z) * 100 + 100 + colorCode = 3000 / z + 15 + If colorCode > 31 Then colorCode = 31 + PSet (projectedX, projectedY), colorCode + + ' Update the star's array positions + starXPositions(starIndex) = x + starYPositions(starIndex) = y + starZPositions(starIndex) = z + Next starIndex + + ' Add new stars to the galaxy if needed + If maxStars - totalStars > Rnd * 800 + 100 Then CreateGalaxy: totalStars = totalStars + 1 + + ' Remove the two farthest stars and replace them with new ones + For a = 1 To 2 + starIndex = Int(Rnd * (totalStars - 10)) + 1 + Swap starXPositions(totalStars), starXPositions(starIndex) + Swap starYPositions(totalStars), starYPositions(starIndex) + Swap starZPositions(totalStars), starZPositions(starIndex) + + x = starXPositions(totalStars) + y = starYPositions(totalStars) + z = starZPositions(totalStars) + projectedX = (x / z) * 160 + 160 + projectedY = (y / z) * 100 + 100 + PSet (projectedX, projectedY), 0 ' Erase the star + totalStars = totalStars - 1 + Next a + + + ' Check for user input to exit the program + If InKey$ <> "" Then System + + ' sleep, to limit framerate + Sound 0, 1 +Loop + +' Subroutine to create a new galaxy of stars +Sub CreateGalaxy + xForce = Rnd * 4 - 2 + yForce = Rnd * 4 - 2 + xPositionOffset = Rnd * 200 - 100 + yPositionOffset = Rnd * 200 - 100 + + ' Add a new set of stars with varying positions and velocities + For starIndex = 1 To Int(Rnd * 15) + 10 Step .04 + x = Sin(starIndex) * starIndex * starIndex / 10 + y = Cos(starIndex) * starIndex * starIndex / 10 + AddStar x + RND * starIndex * starIndex / 30 + xPositionOffset, _ + y + RND * starIndex * starIndex / 30 + yPositionOffset, _ + 700 + RND * starIndex * starIndex / 30 + (x * xForce) + (y * yForce) + Next starIndex + + ' Play a sound when creating new stars (commented out) + ' SOUND 1000, 1 +End Sub + +' Subroutine to add a new star at the specified position +Sub AddStar (xPosition As Single, yPosition As Single, zPosition As Single) + totalStars = totalStars + 1 + starIndex = totalStars + + starXPositions(starIndex) = xPosition + starYPositions(starIndex) = yPosition + starZPositions(starIndex) = zPosition +End Sub diff --git a/networking/LPT communication driver/lptdrv.asm b/networking/LPT communication driver/lptdrv.asm old mode 100755 new mode 100644 diff --git a/networking/LPT communication driver/lptdrv.txt b/networking/LPT communication driver/lptdrv.txt old mode 100755 new mode 100644 diff --git a/networking/LPT communication driver/test.ASM b/networking/LPT communication driver/test.ASM old mode 100755 new mode 100644