Author Topic: Competition  (Read 35233 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Competition
« Reply #90 on: October 12, 2021, 11:56:24 pm »
BTW I've been wondering how this thing might be judged. I think all who have participated earn the right to vote. If everyone votes for them self or there is a tie, a person could be nominated and voted by for by the participants after Halloween to break the tie.

I was going to say voting day is November 2 but need a week after Halloween to try out the others to form a fair and balanced decision for your creation ha, ha! So yeah, that might be a rule, you aren't allowed to vote for yourself. And therefore the votes are to be made publicly. Or is all this just too formal for you guys?

Prize, did I hear someone wonder about that? How about a very strong recommendation by me to Qwerkey to immortalize your work in the Library?

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Competition
« Reply #91 on: October 13, 2021, 03:58:36 pm »
Anyone up for invaders with FLAPPY BATS? Oh, and just edited in, The Great Pumpkin as the "Mother ship."

Code: QB64: [Select]
  1. DIM SHARED intro%: intro% = -1
  2. skip_intro:
  3. DIM SHARED lmargin%, rmargin%, topmargin%, screenwidth%, level, ibk, ileadingrow
  4. DIM SHARED irow, icol, inextrnd, imaxalienmissiles, alienforce%, ileadingmax, imaxalienforce, ihits, score$
  5.  
  6.  
  7. score$ = "000000"
  8. imaxalienforce = 6
  9. imaxalienmissiles = 3
  10. lmargin% = 2
  11. rmargin% = 79
  12. topmargin% = 3
  13. ialiencolstat = 6
  14. iwin = 3 ' 3 Levels.
  15. screenwidth% = rmargin% - lmargin% + 1
  16. ibk = 0 ' Background color
  17.  
  18. DIM SHARED a(imaxalienforce) AS STRING * 68
  19.  
  20. SCREEN 0, 0, 0, 0
  21.  
  22. 'fontpath$ = ENVIRON$("SYSTEMROOT") + "\fonts\lucon.ttf" 'Find Windows Folder Path.
  23. 'font& = _LOADFONT(fontpath$, 25, "monospace")
  24. '_FONT font&
  25.  
  26. COLOR 7, 0: CLS
  27.  
  28. REM Make aliens
  29. a1$ = "^^" + CHR$(79) + "^^  "
  30. a$ = a1$ + a1$ + a1$ + a1$ + a1$ + a1$ + a1$ + a1$ + a1$ + a1$
  31. alt1$ = "--" + CHR$(79) + "--  "
  32. a$ = a1$ + alt1$ + a1$ + alt1$ + a1$ + alt1$ + a1$ + alt1$ + a1$ + alt1$
  33. alt$ = alt1$ + a1$ + alt1$ + a1$ + alt1$ + a1$ + alt1$ + a1$ + alt1$ + a1$
  34.  
  35. IF intro% THEN
  36.     SCREEN 0, 0, 1, 1
  37.     CALL qbideOrig
  38.  
  39.     SCREEN 0, 0, 2, 0
  40.     CALL qbide
  41.  
  42.     SCREEN 0, 0, 1, 1
  43.     _DELAY 2
  44.  
  45.     IF _FILEEXISTS("Thunder6.ogg") THEN
  46.         Rain& = _SNDOPEN("RainBk.ogg", "SYNC")
  47.         T1& = _SNDOPEN("Thunder1.ogg", "SYNC")
  48.         T2& = _SNDOPEN("Thunder2.ogg", "SYNC")
  49.         T3& = _SNDOPEN("Thunder3.ogg", "SYNC")
  50.         T4& = _SNDOPEN("Thunder4.ogg", "SYNC")
  51.         T5& = _SNDOPEN("Thunder5.ogg", "SYNC")
  52.         T6& = _SNDOPEN("Thunder6.ogg", "SYNC")
  53.         T7& = _SNDOPEN("Thunder7.ogg", "SYNC")
  54.         T8& = _SNDOPEN("Thunder8.ogg", "SYNC")
  55.  
  56.         _SNDPLAY T6&
  57.         _DELAY .1
  58.         _SNDPLAY T7&
  59.         _DELAY .1
  60.         _SNDPLAY T8&
  61.     ELSE
  62.         SOUND 1000, .3: SOUND 2400, .6:: SOUND 700, 2
  63.     END IF
  64.  
  65.     FOR i = 1 TO 15
  66.         _DELAY i / 150
  67.         IF i / 2 = i \ 2 THEN
  68.             SOUND 250, .1
  69.             SCREEN 0, 0, 1, 1
  70.         ELSE
  71.             SCREEN 0, 0, 2, 2
  72.             IF i < 13 THEN _DELAY i / 100: SCREEN 0, 0, 3, 3: COLOR 0, 7: CLS
  73.         END IF
  74.     NEXT
  75.  
  76.     PCOPY 2, 0
  77.     SCREEN 0, 0, 0, 0
  78.     _DELAY 1.5
  79.  
  80.     CALL TheBOB
  81.  
  82.     '_FREEFONT font&
  83.     'fontpath$ = ENVIRON$("SYSTEMROOT") + "\fonts\lucon.ttf" 'Find Windows Folder Path.
  84.     'font& = _LOADFONT(fontpath$, 25, "monospace")
  85.     '_FONT font&
  86.  
  87.     CALL qbide
  88.  
  89.     CALL qbide
  90.  
  91.  
  92. IF intro% = -1 THEN RESTORE first_play ELSE RESTORE replay
  93.  
  94. CALL instructions
  95.  
  96.     IF inextrnd = -1 THEN PCOPY 3, 0
  97.     tank$ = CHR$(218) + CHR$(127) + CHR$(191): icolor = 6
  98.     REDIM SHARED bullet%(5), bulletcol%(5), bulletdelay%(5), iltalien(imaxalienforce)
  99.     REDIM SHARED ia(imaxalienmissiles), iy(imaxalienmissiles), ix(imaxalienmissiles)
  100.     REDIM SHARED matrix(imaxalienforce) AS STRING * 10
  101.     alienforce% = imaxalienforce
  102.     level = .65
  103.     iround = iround + 1
  104.     level = level - iround / 15
  105.     inextrnd = -1
  106.     COLOR 6, ibk
  107.  
  108.     REM Set up aliens
  109.     ialiencol = ialiencolstat
  110.     LOCATE 2, ialiencol
  111.     FOR i = 1 TO imaxalienforce
  112.         IF i MOD 1 = 0 THEN PRINT
  113.         LOCATE , ialiencol
  114.         IF i = imaxalienforce THEN
  115.             ileadingrow = CSRLIN: ileadingmax = ileadingrow
  116.         END IF
  117.         IF i \ 2 = i / 2 THEN a(i) = a$ ELSE a(i) = alt$
  118.         PRINT a(i)
  119.     NEXT
  120.  
  121.     COLOR 0 + 16, 3
  122.     LOCATE 25, 68: PRINT "Score ";
  123.     COLOR 0, 3
  124.     PRINT score$;
  125.     COLOR 6, ibk
  126.  
  127.     REM Station
  128.     LOCATE 24, 40
  129.     tanky% = CSRLIN: tankx% = POS(0) + 1
  130.     PRINT tank$;: LOCATE , POS(0) - 2
  131.  
  132.     _DELAY 1
  133.  
  134.     DO
  135.         z1 = TIMER
  136.         DO
  137.             IF zbonus THEN
  138.                 IF ABS(zbonus - TIMER) > 1.5 THEN
  139.                     yy% = CSRLIN: xx% = POS(0)
  140.                     COLOR 6, 0: LOCATE topmargin%, lmargin%: PRINT SPACE$(screenwidth%);
  141.                     LOCATE yy%, xx%
  142.                     zbonus = 0
  143.                 END IF
  144.             END IF
  145.  
  146.             IF topmargin% + ileadingmax - (imaxalienforce * 2) >= topmargin% + 2 THEN
  147.                 IF imothership <> 0 THEN CALL mship(imothership)
  148.             END IF
  149.             IF ABS(TIMER - z1aliens) > level THEN
  150.                 CALL movealiens(ialiencol, ialiencolstat, iresults)
  151.                 z1aliens = TIMER
  152.             END IF
  153.             IF iresults < 0 THEN EXIT DO
  154.             IF ABS(TIMER - z1ia) > .3 THEN CALL alienmissile(iresults): z1ia = TIMER
  155.  
  156.             DEF SEG = 0
  157.             IF PEEK(1047) MOD 16 = 7 OR PEEK(1047) MOD 16 = 8 THEN
  158.                 key$ = CHR$(32) ' Alt
  159.             ELSE
  160.                 key$ = ""
  161.             END IF
  162.             DEF SEG
  163.  
  164.             SELECT CASE key$
  165.                 CASE CHR$(32)
  166.                     IF flag = 0 THEN switch = switch * -1 - 1: flag = -1
  167.                     SELECT CASE switch
  168.                         CASE 0
  169.                             IF ABS(z9 - TIMER) > .15 THEN
  170.                                 IF POS(0) < screenwidth% THEN COLOR icolor, ibk: LOCATE , POS(0) - 1: PRINT " " + tank$;: LOCATE , POS(0) - 2
  171.                                 tanky% = CSRLIN: tankx% = POS(0)
  172.                                 IF SCREEN(tanky%, tankx% - 2) = 25 OR SCREEN(tanky%, tankx% + 2) = 25 THEN result = -1: EXIT DO
  173.                                 z9 = TIMER
  174.                             END IF
  175.                         CASE -1
  176.                             IF ABS(z9 - TIMER) > .15 THEN
  177.                                 IF POS(0) > lmargin% + 1 THEN COLOR icolor, ibk: LOCATE , POS(0) - 2: PRINT tank$ + " ";: LOCATE , POS(0) - 3
  178.                                 tanky% = CSRLIN: tankx% = POS(0)
  179.                                 IF SCREEN(tanky%, tankx% - 2) = 25 OR SCREEN(tanky%, tankx% + 2) = 25 THEN result = -1: EXIT DO
  180.                                 z9 = TIMER
  181.                             END IF
  182.                     END SELECT
  183.                     IF icolor = 6 THEN
  184.                         FOR i2 = 1 TO 5
  185.                             IF bullet%(i2) = 0 THEN
  186.                                 icolor = 12: COLOR icolor, ibk: GOSUB redraw
  187.                                 bullet%(i2) = -1: reload = TIMER: EXIT FOR
  188.                             END IF
  189.                         NEXT
  190.                     END IF
  191.                 CASE ""
  192.                     IF flag THEN skip = 0: flag = 0
  193.                 CASE CHR$(27): SYSTEM
  194.             END SELECT
  195.  
  196.             IF ABS(z1 - reload) > .6 AND reload <> 0 THEN
  197.                 GOSUB redraw
  198.                 icolor = 6: reload = 0
  199.             END IF
  200.  
  201.             REM Fire
  202.             FOR i = 1 TO 5
  203.                 SELECT CASE bullet%(i)
  204.                     CASE -1: bullet%(i) = tanky% - 1: bulletcol%(i) = tankx%
  205.                     CASE IS > 0
  206.                         IF bulletdelay%(i) = -1 OR bullet%(i) = tanky% - 1 THEN
  207.                             CALL checkcollision(ihitaliens, ialiencol, i4, i)
  208.                             z2bullet = TIMER: bulletdelay%(i) = 0
  209.                             COLOR 6, ibk
  210.                             LOCATE bullet%(i), bulletcol%(i)
  211.                             IF bullet%(i) = topmargin% AND imothership <> 0 THEN ' Hit mother ship.
  212.                                 IF SCREEN(ABS(bullet%(i)), bulletcol%(i)) <> 32 THEN
  213.                                     SOUND 1000, .75
  214.                                     SELECT CASE iresults + 1
  215.                                         CASE 1: bonus = 1500
  216.                                         CASE 2: bonus = 2500
  217.                                         CASE 3: bonus = 5000
  218.                                     END SELECT
  219.                                     score$ = LTRIM$(STR$(VAL(score$) + bonus))
  220.                                     score$ = STRING$(6 - LEN(score$), "0") + score$
  221.                                     yy% = CSRLIN: xx% = POS(0)
  222.                                     SOUND 800, .5: SOUND 1600, .5: SOUND 2400, .5
  223.                                     LOCATE topmargin%, lmargin%: PRINT SPACE$(screenwidth%);
  224.                                     kbonus = bulletcol%(i) - 4
  225.                                     IF kbonus < lmargin% THEN kbonus = lmargin%
  226.                                     IF kbonus + 10 > screenwidth% THEN kbonus = screenwidth% - 11
  227.                                     zbonus = TIMER
  228.                                     LOCATE yy%, xx%
  229.                                     imothership = 0
  230.                                 END IF
  231.                             END IF
  232.                             PRINT CHR$(24) ' Tank missile.
  233.                             IF CSRLIN <> 24 THEN LOCATE , bulletcol%(i): PRINT " ";
  234.                             IF ihitaliens <> 0 THEN CALL reprintaliens(ialiencol, ihitaliens, iresults, i4, i, imothership)
  235.                             LOCATE tanky%, tankx%
  236.                             IF bullet%(i) > topmargin% THEN
  237.                                 bullet%(i) = bullet%(i) - 1
  238.                             ELSE
  239.                                 GOSUB erasebullet
  240.                             END IF
  241.  
  242.                             IF zbonus THEN
  243.                                 yy% = CSRLIN: xx% = POS(0)
  244.                                 LOCATE topmargin%, kbonus: COLOR 2 + 16: PRINT "BONUS " + LTRIM$(STR$(bonus));
  245.                                 LOCATE yy%, xx%
  246.                             END IF
  247.  
  248.                         END IF
  249.                 END SELECT
  250.             NEXT
  251.  
  252.             REM Bullet timer delay
  253.             IF z2bullet <> 0 THEN
  254.                 IF z1 < z2bullet THEN z2bullet = z2bullet - 86400
  255.                 IF z1 - z2bullet >= .06 THEN
  256.                     FOR i2 = 1 TO 5
  257.                         IF bullet%(i2) <> 0 THEN bulletdelay%(i2) = -1
  258.                     NEXT i2
  259.                 END IF
  260.                 EXIT DO
  261.             END IF
  262.         LOOP
  263.         IF iresults < 0 THEN EXIT DO
  264.         IF alienforce% = 0 OR iresults = iwin THEN
  265.             FOR i = 1 TO imaxalienmissiles
  266.                 IF ia(i) <> 0 THEN EXIT FOR
  267.             NEXT
  268.             IF i > imaxalienmissiles THEN iwait = -1
  269.             IF iwait = -1 THEN
  270.                 EXIT DO
  271.             END IF
  272.         ELSE
  273.             iwait = 1
  274.         END IF
  275.     LOOP
  276.  
  277.     IF iresults = iwin OR iresults < 0 THEN
  278.         REM end game
  279.         EXIT DO
  280.     END IF
  281.     inextrnd = -1
  282.  
  283. SELECT CASE iresults
  284.     CASE -1 ' Tank destroyed!
  285.         SOUND 800, .3: SOUND 250, 1
  286.  
  287.         FOR i = 1 TO 5
  288.             COLOR 14, 4
  289.             LOCATE tanky%, tankx% - 1: PRINT tank$;
  290.             _DELAY .1
  291.  
  292.             COLOR 8, ibk
  293.             LOCATE tanky%, tankx% - 1: PRINT tank$;
  294.             _DELAY .1
  295.         NEXT
  296.  
  297.         COLOR 6, ibk
  298.         LOCATE tanky% - 1, lmargin%
  299.         PRINT SPACE$(screenwidth%);
  300.         LOCATE tanky%, lmargin%
  301.         PRINT SPACE$(screenwidth%);
  302.  
  303.         _DELAY 2
  304.  
  305.         CALL qbide
  306.  
  307.     CASE -2 ' Aliens have landed!
  308.         SOUND 1000, .3: SOUND 2400, .6:: SOUND 700, 2
  309.  
  310.         COLOR 7, 0
  311.         FOR i = 0 TO 21 ' Blank out screen.
  312.             LOCATE topmargin% + i, lmargin%: PRINT SPACE$(screenwidth%);
  313.         NEXT
  314.  
  315.         COLOR 6, ibk
  316.         LOCATE tanky% - 1, lmargin%
  317.         PRINT SPACE$(screenwidth%);
  318.         LOCATE tanky%, lmargin%
  319.         PRINT SPACE$(screenwidth%);
  320.  
  321.         COLOR 8, ibk
  322.  
  323.         FOR j = imaxalienforce TO 1 STEP -1
  324.             IF a(j) <> "" THEN EXIT FOR
  325.         NEXT
  326.  
  327.         FOR i = j TO 1 STEP -1
  328.             LOCATE , ialiencol + INSTR(a(i), CHR$(79)) - 2
  329.             PRINT LTRIM$(RTRIM$(a(i)));
  330.             LOCATE CSRLIN - 2
  331.         NEXT
  332.  
  333.         _DELAY 2.5
  334.  
  335.     CASE ELSE ' Winner.
  336.  
  337.         l$ = "12"
  338.         n$ = "n29": PLAY "L" + l$ + n$: _DELAY .5
  339.         n$ = "n24": PLAY "L" + l$ + n$: _DELAY .5
  340.         n$ = "n33": PLAY "L" + l$ + n$: _DELAY .5
  341.         n$ = "n29": PLAY "L" + l$ + n$
  342.  
  343.         CALL qbide
  344.  
  345.         RESTORE winner
  346.  
  347.  
  348.  
  349. COLOR 0, 3
  350. LOCATE 25, 68: PRINT "Score "; score$;
  351.  
  352. CALL instructions
  353.  
  354. COLOR 6, 0
  355. LOCATE 5, 3: PRINT "Score "; score$
  356.  
  357. DEF SEG = 0
  358.     _LIMIT 30
  359.     b$ = INKEY$
  360.     IF b$ = CHR$(27) THEN SYSTEM
  361.     IF PEEK(1047) MOD 16 = 7 OR PEEK(1047) MOD 16 = 8 THEN EXIT DO
  362.  
  363. RUN skip_intro
  364.  
  365. erasebullet:
  366. LOCATE ABS(bullet%(i)), bulletcol%(i): PRINT " ";
  367. bullet%(i) = 0: bulletcol%(i) = 0: bulletdelay%(i) = 0
  368. LOCATE tanky%, tankx%
  369.  
  370. redraw:
  371. COLOR , ibk: LOCATE tanky%, tankx% - 1: PRINT tank$;: LOCATE tanky%, tankx%: COLOR 7, ibk
  372.  
  373. first_play:
  374. DATA "The Great Pumpkin has fired an EM pulse at your computer."
  375. DATA ""
  376. DATA "All that's left working is your Alt key."
  377. DATA ""
  378. replay:
  379. DATA "Loading..."
  380. DATA "EOF"
  381. DATA "Game Over. Press Alt to play again..."
  382. DATA "EOF2"
  383. winner:
  384. DATA "Congratulations, you saved the planet!"
  385. DATA "EOF3"
  386.  
  387.  
  388. SUB alienattack (ialiencol)
  389.     z2alienfire = TIMER
  390.  
  391.     i3 = INT(RND * 10)
  392.     FOR i = 1 TO imaxalienmissiles
  393.         IF ia(i) = 0 THEN
  394.             FOR i2 = imaxalienforce TO 1 STEP -1
  395.                 IF RTRIM$(a(i2)) <> "" THEN
  396.                     IF MID$(matrix(i2), i3 + 1, 1) <> "0" THEN
  397.                         i4 = INSTR(i3 * 7 + 1, a(i2), CHR$(79)) + ialiencol
  398.                         EXIT FOR
  399.                     END IF
  400.                 END IF
  401.             NEXT i2
  402.             IF i4 <> 0 THEN
  403.                 ia(i) = (ileadingmax - (imaxalienforce - i2) * 2) * 80 + i4
  404.                 EXIT FOR
  405.             END IF
  406.         END IF
  407.     NEXT i
  408.  
  409.  
  410. SUB alienmissile (iresults)
  411.     irow = CSRLIN: icol = POS(0)
  412.     FOR i = 1 TO imaxalienmissiles
  413.         IF ia(i) <> 0 THEN
  414.             IF iy(i) = 0 THEN
  415.                 iy(i) = ia(i) \ 80: ix(i) = ia(i) MOD 80
  416.                 IF ix(i) = 0 THEN ix(i) = screenwidth%
  417.             END IF
  418.             LOCATE iy(i) + 1, ix(i)
  419.             COLOR 6, ibk
  420.             IF CSRLIN <= 24 THEN
  421.                 IF CSRLIN = 24 THEN IF SCREEN(CSRLIN, ix(i)) <> 32 THEN iresults = -1
  422.                 PRINT CHR$(25);
  423.             ELSE
  424.                 ia(i) = 0
  425.                 LOCATE iy(i), ix(i)
  426.                 PRINT " ";: iy(i) = 0
  427.                 ia(i) = 0
  428.                 LOCATE irow, icol
  429.                 EXIT SUB
  430.             END IF
  431.             LOCATE iy(i), ix(i): PRINT " ";
  432.             iy(i) = iy(i) + 1
  433.         END IF
  434.     NEXT
  435.     LOCATE irow, icol
  436.  
  437.  
  438. SUB checkcollision (ihitaliens, ialiencol, i4, i)
  439.     ihitaliens = 0
  440.     IF ileadingmax MOD 2 = bullet%(i) MOD 2 THEN
  441.         i4 = imaxalienforce - (ileadingmax - bullet%(i)) \ 2
  442.         IF bullet%(i) <= ileadingrow AND i4 > 0 AND i4 <= imaxalienforce THEN
  443.             IF RTRIM$(a(i4)) <> "" THEN
  444.                 IF bulletcol%(i) >= iltalien(i4) AND bulletcol%(i) - ialiencol <= LEN(RTRIM$(a(i4))) THEN
  445.                     IF MID$(a(i4), bulletcol%(i) - ialiencol, 1) > CHR$(32) THEN
  446.                         ihitaliens = bulletcol%(i) - ialiencol + 1
  447.                         i3 = ihitaliens - 7 + 1
  448.                         IF i3 < 1 THEN i3 = 1: REM count from the "<" symbol.
  449.                         i2 = INSTR(i3 + 1, a(i4), "^" + CHR$(79)) - 1
  450.                         i2 = INSTR(i3 + 1, a(i4), CHR$(79)) - 2
  451.                         MID$(a(i4), i2, 7) = SPACE$(7)
  452.                         MID$(matrix(i4), (i2 + 1) \ 7 + 1, 1) = "0"
  453.                     END IF
  454.                 END IF
  455.             END IF
  456.         END IF
  457.     END IF
  458.  
  459.     FOR i2 = 1 TO imaxalienmissiles
  460.         IF ia(i2) <> 0 THEN
  461.             IF iy(i2) >= bullet%(i) AND ix(i2) = bulletcol%(i) THEN
  462.                 ihitaliens = -i2
  463.                 EXIT FOR
  464.             END IF
  465.         END IF
  466.     NEXT
  467.  
  468.  
  469. SUB instructions
  470.     IF in$ = "" THEN
  471.         LOCATE 3, 3, 1, 7, 0: COLOR 6, ibk
  472.         _DELAY 2
  473.         DO
  474.             READ in$
  475.             IF MID$(in$, 1, 3) = "EOF" THEN EXIT DO
  476.             FOR i = 1 TO LEN(in$)
  477.                 SOUND 400, .06
  478.                 LOCATE , 2 + i
  479.                 PRINT MID$(in$, i, 1);
  480.                 z = TIMER
  481.                 DO
  482.                     IF ABS(z - TIMER) > .06 THEN EXIT DO
  483.                 LOOP
  484.             NEXT
  485.             LOCATE , , 0, 7, 0
  486.             _DELAY 1
  487.             PRINT
  488.             LOCATE , 3
  489.         LOOP
  490.         _DELAY .75
  491.     END IF
  492.  
  493.     IF in$ = "EOF" THEN
  494.         COLOR 7, 0
  495.         FOR i = 0 TO 19 ' Blank out intro message space.
  496.             LOCATE topmargin% + i, lmargin%: PRINT SPACE$(screenwidth%);
  497.         NEXT
  498.         FOR i = 3 TO 24
  499.             LOCATE i, 80: PRINT CHR$(179);
  500.         NEXT
  501.         LOCATE 21, 2: PRINT STRING$(screenwidth%, " ");
  502.         LOCATE 22, 1: PRINT CHR$(179);
  503.         LOCATE 22, 80: PRINT CHR$(179);
  504.         LOCATE 22, 2: PRINT STRING$(screenwidth%, " ");
  505.     ELSE
  506.         COLOR 0, 3
  507.     END IF
  508.  
  509.     IF in$ <> "EOF2" AND iresults <> iwin THEN COLOR 0 + 16, 3 ELSE COLOR 0, 3
  510.     yy% = CSRLIN: xx% = POS(0)
  511.     LOCATE 25, 68: PRINT "Score ";
  512.     COLOR 0, 3
  513.     PRINT score$;
  514.     LOCATE yy%, xx%
  515.  
  516.     PCOPY 0, 3: REM save skin
  517.  
  518.  
  519. SUB marchdown (ialiencol, ialiencolstat, imotion, iresults)
  520.     COLOR 6, ibk
  521.     ileadingrow = ileadingrow + 1
  522.     ileadingmax = ileadingmax + 1
  523.     COLOR 6, ibk
  524.     FOR i = 1 TO imaxalienforce
  525.         REM SOUND 400, .2 ' Level down.
  526.         IF RTRIM$(a(i)) <> "" THEN
  527.             ialiencol = ialiencolstat + imotion
  528.             LOCATE ileadingmax - (imaxalienforce * 2) + i * 2 - 1, lmargin%
  529.             PRINT STRING$(screenwidth%, " ")
  530.             LOCATE , ialiencol + INSTR(a(i), CHR$(79)) - 2
  531.             iltalien(i) = POS(0)
  532.             PRINT LTRIM$(RTRIM$(a(i)))
  533.         END IF
  534.     NEXT
  535.     LOCATE irow, icol
  536.     level = level - .025
  537.     IF ileadingrow = 22 THEN iresults = -2 ' Aliens have landed!
  538.  
  539. SUB movealiens (ialiencol, ialiencolstat, iresults)
  540.     STATIC imotion, imarch, imotiondir
  541.  
  542.     SOUND 800, .1: SOUND 200, .33 ' Marching sound.
  543.  
  544.     IF inextrnd = -1 THEN inextrnd = 0: imotion = 0: imarch = 0: imotiondir = 0
  545.     irow = CSRLIN: icol = POS(0)
  546.     yy% = CSRLIN: xx% = POS(0)
  547.     PCOPY 0, 1: SCREEN 0, 0, 1, 0: LOCATE yy%, xx%, 0, 7, 0
  548.     IF imotiondir = 0 THEN imotion = imotion - 1 ELSE imotion = imotion + 1
  549.     COLOR 6, ibk
  550.  
  551.     FOR i = imaxalienforce TO 1 STEP -1
  552.         IF RTRIM$(a(i)) <> "" THEN
  553.             FOR k = 1 TO LEN(a(i))
  554.                 k$ = MID$(a(i), k, 1)
  555.                 IF k$ = "^" THEN
  556.                     MID$(a(i), k, 1) = "-"
  557.                 ELSEIF k$ = "-" THEN
  558.                     MID$(a(i), k, 1) = "^"
  559.                 END IF
  560.             NEXT
  561.             i2 = i2 + 2
  562.             ialiencol = ialiencolstat + imotion
  563.             LOCATE ileadingmax - (imaxalienforce - i) * 2, ialiencol + INSTR(a(i), CHR$(79)) - 2
  564.             IF POS(0) = lmargin% THEN imarch = 1
  565.             iltalien(i) = POS(0)
  566.             IF imotiondir = 0 THEN
  567.                 PRINT LTRIM$(RTRIM$(a(i))); " "
  568.             ELSE
  569.                 LOCATE , POS(0) - 1
  570.                 PRINT " "; LTRIM$(RTRIM$(a(i)))
  571.             END IF
  572.             IF ialiencol + LEN(RTRIM$(a(i))) = screenwidth% THEN imarch = -1
  573.         END IF
  574.     NEXT
  575.  
  576.     IF imarch = 1 THEN imotiondir = 1: CALL marchdown(ialiencol, ialiencolstat, imotion, iresults)
  577.     IF imarch = -1 THEN imotiondir = 0: CALL marchdown(ialiencol, ialiencolstat, imotion, iresults)
  578.     IF imarch = 0 THEN
  579.         IF ABS(TIMER - z2alienfire) > firerate THEN
  580.             firerate = (INT(RND * 10) + 1) / 20
  581.             IF iwait = 0 THEN CALL alienattack(ialiencol)
  582.         END IF
  583.     ELSE
  584.         imarch = 0
  585.     END IF
  586.     PCOPY 1, 0: SCREEN 0, 0, 0, 0
  587.     LOCATE irow, icol, 1, 7, 0
  588.  
  589. SUB mship (imothership)
  590.     STATIC x%, mov%, z4, mothership$
  591.  
  592.     yy% = CSRLIN: xx% = POS(0): COLOR 6, ibk
  593.     IF imothership = -1 THEN
  594.         imothership = 1
  595.         x% = lmargin%
  596.         mothership$ = "(" + CHR$(127) + CHR$(179) + CHR$(127) + ")" 'CHR$(254) + CHR$(254) + "O" + CHR$(254) + CHR$(254)
  597.         mov% = 1
  598.     END IF
  599.  
  600.     IF ABS(TIMER - z4) > .05 THEN GOSUB mothership: z4 = TIMER
  601.     LOCATE yy%, xx%
  602.     EXIT SUB
  603.  
  604.     mothership:
  605.     IF x% + LEN(mothership$) = screenwidth% + lmargin% THEN mov% = -1 ELSE IF x% = lmargin% THEN mov% = 1
  606.     x% = x% + mov%
  607.     LOCATE topmargin%, x%
  608.     COLOR 7, 6: PRINT MID$(mothership$, 1, 1);
  609.     COLOR 14, 6: PRINT MID$(mothership$, 2, 1);
  610.     COLOR 7, 6: PRINT MID$(mothership$, 3, 1);
  611.     COLOR 14, 6: PRINT MID$(mothership$, 4, 1);
  612.     COLOR 7, 6: PRINT MID$(mothership$, 5, 1);
  613.     COLOR 7, ibk
  614.     IF x% > 1 AND mov% = 1 THEN
  615.         LOCATE , POS(0) - LEN(mothership$) - 1: PRINT " ";
  616.     END IF
  617.     IF mov% = -1 THEN PRINT " ";
  618.     RETURN
  619.  
  620.  
  621. DEFINT A-H, J-Z
  622. SUB qbide
  623.     PALETTE 2, 59
  624.     COLOR 15, 0
  625.     CLS
  626.  
  627.     COLOR 0, 7
  628.     LOCATE 1, 1
  629.     PRINT SPACE$(80)
  630.     LOCATE 1, 1: PRINT "   File  Edit  View  Search  Run  Debug  Calls  Options                   Help"
  631.  
  632.     COLOR 7, 0 ' Black background.
  633.  
  634.     LOCATE 2, 1: PRINT CHR$(218)
  635.     LOCATE 2, 2: PRINT STRING$(78, CHR$(196))
  636.     LOCATE 2, 80: PRINT CHR$(191)
  637.  
  638.     LOCATE 2, 76: PRINT CHR$(180)
  639.     LOCATE 2, 78: PRINT CHR$(195)
  640.  
  641.     COLOR 0, 7
  642.     LOCATE 2, 77: PRINT CHR$(24)
  643.     LOCATE 2, 36: PRINT " Untitled "
  644.  
  645.     COLOR 7, 0
  646.     FOR Rows = 3 TO 24
  647.         LOCATE Rows, 1: PRINT CHR$(179);
  648.         LOCATE Rows, 80: PRINT CHR$(179);
  649.     NEXT Rows
  650.  
  651.     LOCATE 22, 1: PRINT CHR$(195)
  652.     LOCATE 22, 80: PRINT CHR$(180)
  653.     LOCATE 22, 2: PRINT STRING$(78, CHR$(196))
  654.     LOCATE 22, 35
  655.     PRINT " Immediate "
  656.  
  657.     COLOR 0, 7
  658.     LOCATE 21, 3: PRINT STRING$(76, CHR$(176))
  659.     LOCATE 21, 2: PRINT CHR$(27)
  660.     LOCATE 21, 3: PRINT CHR$(219)
  661.     LOCATE 21, 79: PRINT CHR$(26)
  662.     FOR Rows = 4 TO 19
  663.         LOCATE Rows, 80: PRINT CHR$(176)
  664.     NEXT Rows
  665.     LOCATE 3, 80: PRINT CHR$(24)
  666.     LOCATE 4, 80: PRINT CHR$(219)
  667.     LOCATE 20, 80: PRINT CHR$(25)
  668.  
  669.     COLOR 0, 3: LOCATE 25, 1: PRINT " <Shift+F1=Help> <F6=Window> <F2=Subs> <F5=Run> <F8=Step> ";
  670.     LOCATE 25, 59: PRINT SPACE$(4);
  671.     COLOR 0, 3
  672.     LOCATE 25, 63: PRINT CHR$(179);
  673.     LOCATE 25, 64: PRINT SPACE$(6);
  674.     LOCATE 25, 68: PRINT "C  00001:001 ";
  675.  
  676.  
  677. DEFSNG A-H, J-Z
  678. SUB reprintaliens (ialiencol, ihitaliens, iresults, i4, i, imothership)
  679.     IF ihitaliens > 0 THEN
  680.         ihits = ihits + 1
  681.  
  682.         SELECT CASE iresults + 1
  683.             CASE 1: score$ = LTRIM$(STR$(VAL(score$) + 150))
  684.             CASE 2: score$ = LTRIM$(STR$(VAL(score$) + 250))
  685.             CASE 3: score$ = LTRIM$(STR$(VAL(score$) + 350))
  686.         END SELECT
  687.  
  688.         score$ = STRING$(6 - LEN(score$), "0") + score$
  689.         IF (ihits + 15) MOD 20 = 0 AND imothership = 0 THEN imothership = -1
  690.         LOCATE bullet%(i), lmargin%: PRINT SPACE$(screenwidth%);
  691.         iltalien(i4) = POS(0)
  692.  
  693.         IF RTRIM$(a(i4)) = "" THEN
  694.             alienforce% = alienforce% - 1
  695.             IF alienforce% = 0 THEN iresults = iresults + 1 ' Level completed. Goto to next level.
  696.             IF bullet%(i) = ileadingrow THEN ileadingrow = ileadingrow - 2
  697.         ELSE
  698.             LOCATE bullet%(i), ialiencol + INSTR(a(i4), CHR$(79)) - 2
  699.             PRINT LTRIM$(RTRIM$(a(i4)))
  700.         END IF
  701.     ELSE
  702.         i2 = ABS(ihitaliens)
  703.         LOCATE iy(i2), ix(i2)
  704.         PRINT " ";: iy(i2) = 0
  705.         ia(i2) = 0
  706.         LOCATE irow, icol
  707.         SOUND 1000, .5
  708.     END IF
  709.  
  710.     ihitaliens = 0
  711.     bullet%(i) = -bullet%(i)
  712.  
  713.     COLOR 0, 3
  714.     yy% = CSRLIN: xx% = POS(0)
  715.     LOCATE 25, 74: PRINT score$;
  716.     LOCATE yy%, xx%
  717.     COLOR 6, ibk
  718.  
  719.  
  720. SUB qbideOrig
  721.     PALETTE 2, 59
  722.     COLOR 15, 1
  723.     CLS
  724.  
  725.     COLOR 0, 7
  726.     LOCATE 1, 1
  727.     PRINT SPACE$(80)
  728.     LOCATE 1, 1: PRINT "   File  Edit  View  Search  Run  Debug  Calls  Options                   Help"
  729.  
  730.     COLOR 7, 1
  731.  
  732.     LOCATE 2, 1: PRINT CHR$(218)
  733.     LOCATE 2, 2: PRINT STRING$(78, CHR$(196))
  734.     LOCATE 2, 80: PRINT CHR$(191)
  735.  
  736.     LOCATE 2, 76: PRINT CHR$(180)
  737.     LOCATE 2, 78: PRINT CHR$(195)
  738.  
  739.     COLOR 1, 7
  740.     LOCATE 2, 77: PRINT CHR$(24)
  741.     LOCATE 2, 36: PRINT " Untitled "
  742.  
  743.     COLOR 7, 1
  744.     FOR Rows = 3 TO 24
  745.         LOCATE Rows, 1: PRINT CHR$(179);
  746.         LOCATE Rows, 80: PRINT CHR$(179);
  747.     NEXT Rows
  748.  
  749.     LOCATE 22, 1: PRINT CHR$(195)
  750.     LOCATE 22, 80: PRINT CHR$(180)
  751.     LOCATE 22, 2: PRINT STRING$(78, CHR$(196))
  752.     LOCATE 22, 35
  753.     PRINT " Immediate "
  754.  
  755.     COLOR 0, 7
  756.     LOCATE 21, 3: PRINT STRING$(76, CHR$(176))
  757.     LOCATE 21, 2: PRINT CHR$(27)
  758.     LOCATE 21, 3: PRINT CHR$(219)
  759.     LOCATE 21, 79: PRINT CHR$(26)
  760.     FOR Rows = 4 TO 19
  761.         LOCATE Rows, 80: PRINT CHR$(176)
  762.     NEXT Rows
  763.     LOCATE 3, 80: PRINT CHR$(24)
  764.     LOCATE 4, 80: PRINT CHR$(219)
  765.     LOCATE 20, 80: PRINT CHR$(25)
  766.  
  767.     COLOR 0, 3: LOCATE 25, 1: PRINT " <Shift+F1=Help> <F6=Window> <F2=Subs> <F5=Run> <F8=Step> ";
  768.     LOCATE 25, 59: PRINT SPACE$(4);
  769.     COLOR 0, 3
  770.     LOCATE 25, 63: PRINT CHR$(179);
  771.     LOCATE 25, 64: PRINT SPACE$(6);
  772.     LOCATE 25, 68: PRINT "C  00001:001 ";
  773.  
  774.  
  775. SUB TheBOB
  776.     SCREEN _NEWIMAGE(800, 600, 256)
  777.     WIDTH 80, 25
  778.  
  779.     OUT &H3C8, 1: OUT &H3C9, 40: OUT &H3C9, 12: OUT &H3C9, 0
  780.     OUT &H3C8, 2: OUT &H3C9, 6: OUT &H3C9, 12: OUT &H3C9, 0
  781.     OUT &H3C8, 3: OUT &H3C9, 30: OUT &H3C9, 8: OUT &H3C9, 0
  782.     OUT &H3C8, 4: OUT &H3C9, 3: OUT &H3C9, 8: OUT &H3C9, 0
  783.     OUT &H3C8, 7: OUT &H3C9, 63: OUT &H3C9, 0: OUT &H3C9, 0
  784.     OUT &H3C8, 8: OUT &H3C9, 46: OUT &H3C9, 0: OUT &H3C9, 0
  785.     OUT &H3C8, 9: OUT &H3C9, 63: OUT &H3C9, 63: OUT &H3C9, 63
  786.     OUT &H3C8, 12: OUT &H3C9, 20: OUT &H3C9, 20: OUT &H3C9, 20
  787.     OUT &H3C8, 13: OUT &H3C9, 0: OUT &H3C9, 0: OUT &H3C9, 0
  788.     OUT &H3C8, 14: OUT &H3C9, 55: OUT &H3C9, 35: OUT &H3C9, 0
  789.  
  790.     CIRCLE (320, 240), 100, 3, , , .9
  791.     PAINT (320, 240), 3
  792.     CIRCLE (320, 230), 90, 1, , , .9
  793.     PAINT (320, 230), 1
  794.  
  795.     FOR Reps = 1 TO 4
  796.         SELECT CASE Reps
  797.             DATA 1,1.2,1.8,5
  798.             CASE 1: Elipse = 1
  799.             CASE 2: Elipse = 1.2
  800.             CASE 3: Elipse = 1.8
  801.             CASE 4: Elipse = 5
  802.         END SELECT
  803.         FOR E = Elipse TO Elipse + .1 STEP .01
  804.             CIRCLE (320, 240), 100, 3, , , E
  805.         NEXT E
  806.     NEXT Reps
  807.     FOR Radius = 38 TO 43
  808.         CIRCLE (320, 160), Radius, 3, , , .4
  809.     NEXT Radius
  810.     CIRCLE (320, 160), 40, 14, 3.3, 6, .4
  811.     CIRCLE (320, 240), 100, 5, , , .9
  812.     PAINT (0, 0), 5
  813.     CIRCLE (320, 240), 100, 0, , , .9
  814.     PAINT (0, 0), 0
  815.     FOR Radius = 12 TO 18
  816.         CIRCLE (320, 153), Radius, 2, , , .3
  817.     NEXT Radius
  818.  
  819.     CIRCLE (320, 150), 12, 2, , , .6
  820.     PAINT STEP(0, 0), 2
  821.     CIRCLE (300, 143), 32, 2, 6, 1.1
  822.     CIRCLE (276, 143), 32, 2, 6, .6
  823.     DRAW "BM302,125 C2 M+15,-10 BD10 P2,2"
  824.     PAINT (320, 145), 2
  825.     CIRCLE (282, 143), 32, 4, 6, .73
  826.     CIRCLE (266, 156), 60, 4, .1, .68
  827.     CIRCLE (320, 150), 12, 4, 3.14159, 0, .2
  828.     DRAW "BM302,125 C4 M+15,-10 BD10"
  829.     CIRCLE (276, 143), 32, 4, 6, .6
  830.     PAINT STEP(35, 0), 4
  831.     'Face begins
  832.     CIRCLE (303, 316), 100, 14, 1.5, 2
  833.     CIRCLE (337, 316), 100, 14, 1.1, 1.64
  834.     PSET (310, 215), 14
  835.     DRAW "H30 M-20,+40 M+12,-4 M+14,-29 BL2 P14,14 BF12 P15,14"
  836.     PSET (330, 215), 14
  837.     DRAW "E30 M+20,+40 M-12,-4 M-14,-29 BR2 P14,14 BG12 P15,14"
  838.     PSET (320, 246), 14
  839.     DRAW "R20 H20 G20 R20 U nL19 nR19 BU2 P15,14"
  840.     CIRCLE (320, 170), 100, 14, 3.8, 4.1
  841.     CIRCLE (320, 170), 100, 14, 4.42, 5.01
  842.     CIRCLE (320, 170), 100, 14, 5.33, 5.62
  843.     CIRCLE (320, 220), 80, 14, 3.29, 4.5
  844.     CIRCLE (320, 220), 80, 14, 4.66, 6.15
  845.     PSET (260, 250), 14
  846.     DRAW "D10 F8 U13 M+10,+5 D12 M+12,+6 U12 BR60"
  847.     DRAW "D12 M+12,-6 U12 M+10,-5 D13 E8 U10"
  848.     PSET (300, 297), 14
  849.     DRAW "U14 R16 D16"
  850.     CIRCLE (320, 212), 80, 14, 3.42, 4.5
  851.     CIRCLE (320, 212), 80, 14, 4.66, 6
  852.     LINE (300, 280)-(316, 283), 14, BF
  853.     PAINT (320, 296), 14
  854.     PAINT (290, 292), 14
  855.     PAINT (300, 278), 15, 14
  856.     CIRCLE (100, 240), 32, 13
  857.     PAINT STEP(0, 0), 13
  858.  
  859.     FOR x% = 58 TO 142
  860.         FOR y% = 198 TO 282
  861.             IF POINT(x%, y%) = 13 THEN
  862.                 IF POINT(x% + 220, y%) = 15 THEN PSET (x% + 220, y%), 9
  863.             END IF
  864.         NEXT y%
  865.     NEXT x%
  866.  
  867.     COLOR 13: LOCATE 1, 1: PRINT "HAPPY HALLOWEEN!"
  868.  
  869.     xx = 64: yy = 360 - 330
  870.     FOR x% = 0 TO 300
  871.         FOR y% = 0 TO 16
  872.             IF POINT(x%, y%) = 13 THEN
  873.                 IF y% > 6 THEN Colr = 8 ELSE Colr = 7
  874.                 LINE (x% * 4 + xx, y% * 4 + yy)-(x% * 4 + xx + 3, y% * 4 + yy + 3), Colr, BF
  875.             END IF
  876.         NEXT y%
  877.     NEXT x%
  878.     FOR x% = 0 TO 639
  879.         IF POINT(x%, 368) <> 0 THEN PSET (x%, 368), 14
  880.     NEXT x%
  881.  
  882.     z1 = TIMER
  883.     DO UNTIL ABS(TIMER - z1) > 4
  884.         FOR Reps = 1 TO 3
  885.             WAIT &H3DA, 8
  886.             WAIT &H3DA, 8, 8
  887.         NEXT Reps
  888.  
  889.         Flicker = FIX(RND * 20)
  890.         OUT &H3C8, 14
  891.         OUT &H3C9, 40 + Flicker
  892.         OUT &H3C9, 25 + Flicker
  893.         OUT &H3C9, 10 + Flicker
  894.  
  895.         OUT &H3C8, 15
  896.         OUT &H3C9, 43 + Flicker
  897.         OUT &H3C9, 38 + Flicker
  898.         OUT &H3C9, 20 + Flicker
  899.     LOOP
  900.     SCREEN 0, 0, 0, 0

  [ You are not allowed to view this attachment ]  

If @johnno56 likes it, I'll add save high score routine.

Pete
« Last Edit: October 13, 2021, 07:46:40 pm by Pete »
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline jack

  • Seasoned Forum Regular
  • Posts: 408
    • View Profile
Re: Competition
« Reply #92 on: October 13, 2021, 04:34:30 pm »
not bad Pete, actually quite good

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Competition
« Reply #93 on: October 13, 2021, 04:48:27 pm »
not bad Pete, actually quite good

Thanks! I just edited in a "Great Pumpkin" rendition of the mother ship. I think it's about as Halloweenie as it can get now. Maybe same time I can get a couple more screen flashes for a missile to missile collision, and a firing time-out if that collision is too close to the tank. I think it could also use a couple more sound effects, but that's not something I'm well versed at. It was great having TheBOB toss his pumpkin in the ring, along with his .oog files for the thunder effect. Oh, that reminds me, I should update the post to include the .oog file download...

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Competition
« Reply #94 on: October 13, 2021, 07:06:54 pm »
Nice one, Pete!  Plays great.

- Dav

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Competition
« Reply #95 on: October 13, 2021, 07:45:02 pm »
@Dav Thanks! I wish I had your abillty with sound effects. Any idea if SOUND can produce a "gloop" noise? I should probably start messing with PLAY and figure out some rendition for the Great Pumpkin mother ship while it's on the screen, too.

I just did another edit to make TheBOB's pumpkin animation more seamless. Maybe you guys have a better way, but it looks like by using...

    SCREEN _NEWIMAGE(800, 600, 256)
    WIDTH 80, 25

... for the graphics part, I can keep the screen from stretching, as it did when it was going from SCREEN 0 to SCREEN 12.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Competition
« Reply #96 on: October 13, 2021, 08:36:12 pm »
Hmm, I don't have a GLOOP code on hand, I'll look for something if you want.  I had a whole folder of SOUND effect codes on a drive somewhere.

Lol, that EM pulse knocked out all the bats.  They just froze all the sudden and I picked them off easy and moved around freely all alone for a while.

- Dav

  [ You are not allowed to view this attachment ]  

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Competition
« Reply #97 on: October 13, 2021, 08:52:50 pm »
What you just described I have not experienced. The bats are never supposed to freeze. The missiles still on the screen after the last bat is shot always happens. If I recall right, a missile heading for your tank, after all the bats are gone, can still blow your tank up. The next level begins when the missiles complete their flight.

I'll look up some stuff and see what I can come up with for a gloop sound.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Competition
« Reply #98 on: October 13, 2021, 08:59:24 pm »
It only happened once for me.  My bullets would just clear the characters off the screen when going up, not a whole bat, just pieces.  Happened towards near the end of a wave of bats. 

- Dav

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Competition
« Reply #99 on: October 13, 2021, 09:17:39 pm »
Hmmm, some glitch in the redraw part. I'll have a look, but this one looks like it will be hard to reproduce.

Thanks!

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Competition
« Reply #100 on: October 14, 2021, 11:50:06 am »
Very nice work Pete. Kind of surprised it's not pure Screen 0 from our Hero but always great to see TheBobs marvelous graphics!

Could you post code in it's own thread in Programs board for further updates if any, plus, comments and feedback  related to that code. This is to help Librarians track things. It's a huge help for code postings to have an anchor thread in Programs Board. I think the Discussion Boards threads eventually get Locked up for new comments or updates...

I like how you have the bats flapping their wings now. If you get the code up in Programs Board, I have a question about TheBob's code.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Competition
« Reply #101 on: October 14, 2021, 11:56:22 am »
Also: If code is posted in their own thread in Programs Board, we can use what non participating contest forum members say for help breaking ties.


Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Competition
« Reply #102 on: October 16, 2021, 10:53:41 pm »
This version saves the top 5 highest scores.

To Play:

Use the alt key to move and fire. When you release the alt key, your tank will stop. When you press alt again, your tank will ove in the opposite direction.

Shoot all invaders before they shoot you. Bonus points for shooting the mother ship.

If invaders get a couple rows above your tank, they land and you die.

To win, you must complete all 3 levels.

If you get a top 5 high score, you get to enter your initials. To do so, follow these instructions.

Tap the alt key to display initials A-Z. Stop tapping when your initial appears. Wait 2-seconds and it will be auto-input. If you goofed, hold down the alt key while waiting. It will allow you to redo input from start.

When you input your 3rd and last initial, all your initials will begin to flash for 2.5 seconds, and then they will be recorded. If you goofed, press the alt key within the 2.5 second time period, and you will be able to redo input from start.

WARNING: This routine makes and overwrites a file in your local folder named: ascii-invaders-high-score.dat

Code: QB64: [Select]
  1.  
  2. DIM SHARED intro%: intro% = -1
  3.  
  4. skip_intro:
  5. title$ = "ASCII Invaders / Halloween Edition"
  6. _TITLE title$
  7. DIM SHARED Overlay, font, soundfile%, t1&, t2&, t3&, t4&, t5&, t6&, t7&, t8&
  8. DIM SHARED lmargin%, rmargin%, topmargin%, screenwidth%, level, ibk, ileadingrow
  9. DIM SHARED irow, icol, inextrnd, imaxalienmissiles, alienforce%, ileadingmax, imaxalienforce, ihits, score$
  10.  
  11. SCREEN 0, 0, 0, 0
  12. swidth = _WIDTH
  13.  
  14. score$ = "000000"
  15. imaxalienforce = 6
  16. imaxalienmissiles = 3
  17. lmargin% = 2
  18. rmargin% = 79
  19. topmargin% = 3
  20. ialiencolstat = 6
  21. iwin = 3 ' 3 Levels.
  22. screenwidth% = rmargin% - lmargin% + 1
  23. ibk = 0 ' Background color
  24.  
  25. DIM SHARED a(imaxalienforce) AS STRING * 68
  26.  
  27. 'fontpath$ = ENVIRON$("SYSTEMROOT") + "\fonts\lucon.ttf" 'Find Windows Folder Path.
  28. 'font& = _LOADFONT(fontpath$, 25, "monospace")
  29. '_FONT font&
  30.  
  31. REM Make aliens
  32. a1$ = "^^" + CHR$(79) + "^^  "
  33. a$ = a1$ + a1$ + a1$ + a1$ + a1$ + a1$ + a1$ + a1$ + a1$ + a1$
  34. alt1$ = "--" + CHR$(79) + "--  "
  35. a$ = a1$ + alt1$ + a1$ + alt1$ + a1$ + alt1$ + a1$ + alt1$ + a1$ + alt1$
  36. alt$ = alt1$ + a1$ + alt1$ + a1$ + alt1$ + a1$ + alt1$ + a1$ + alt1$ + a1$
  37.  
  38. IF intro% THEN
  39.     SCREEN 0, 0, 1, 1
  40.     CALL qbideOrig
  41.  
  42.     SCREEN 0, 0, 2, 0
  43.     CALL qbide
  44.  
  45.     CALL thunder
  46.  
  47.     CALL TheBOB
  48.  
  49.     '_FREEFONT font&
  50.     'fontpath$ = ENVIRON$("SYSTEMROOT") + "\fonts\lucon.ttf" 'Find Windows Folder Path.
  51.     'font& = _LOADFONT(fontpath$, 25, "monospace")
  52.     '_FONT font&
  53.  
  54.     CALL qbide
  55.  
  56.     SCREEN 0, 0, 2, 0
  57.  
  58.     CALL qbide
  59.  
  60.     CALL thunder
  61.  
  62.  
  63. IF intro% = -1 THEN RESTORE first_play ELSE RESTORE replay
  64.  
  65. CALL instructions
  66.  
  67.     IF inextrnd = -1 THEN PCOPY 3, 0
  68.     tank$ = CHR$(218) + CHR$(127) + CHR$(191): icolor = 6
  69.     REDIM SHARED bullet%(5), bulletcol%(5), bulletdelay%(5), iltalien(imaxalienforce)
  70.     REDIM SHARED ia(imaxalienmissiles), iy(imaxalienmissiles), ix(imaxalienmissiles)
  71.     REDIM SHARED matrix(imaxalienforce) AS STRING * 10
  72.     alienforce% = imaxalienforce
  73.     level = .65
  74.     iround = iround + 1
  75.     level = level - iround / 15
  76.     inextrnd = -1
  77.     COLOR 6, ibk
  78.  
  79.     REM Set up aliens
  80.     ialiencol = ialiencolstat
  81.     LOCATE 2, ialiencol
  82.     FOR i = 1 TO imaxalienforce
  83.         IF i MOD 1 = 0 THEN PRINT
  84.         LOCATE , ialiencol
  85.         IF i = imaxalienforce THEN
  86.             ileadingrow = CSRLIN: ileadingmax = ileadingrow
  87.         END IF
  88.         IF i \ 2 = i / 2 THEN a(i) = a$ ELSE a(i) = alt$
  89.         PRINT a(i)
  90.     NEXT
  91.  
  92.     COLOR 0 + 16, 3
  93.     LOCATE 25, 68: PRINT "Score ";
  94.     COLOR 0, 3
  95.     PRINT score$;
  96.     COLOR 6, ibk
  97.  
  98.     REM Station
  99.     LOCATE 24, 40
  100.     tanky% = CSRLIN: tankx% = POS(0) + 1
  101.     PRINT tank$;: LOCATE , POS(0) - 2
  102.  
  103.     _DELAY 1
  104.  
  105.     DO
  106.         z1 = TIMER
  107.         DO
  108.             IF zbonus THEN
  109.                 IF ABS(zbonus - TIMER) > 1.5 THEN
  110.                     yy% = CSRLIN: xx% = POS(0)
  111.                     COLOR 6, 0: LOCATE topmargin%, lmargin%: PRINT SPACE$(screenwidth%);
  112.                     LOCATE yy%, xx%
  113.                     zbonus = 0
  114.                 END IF
  115.             END IF
  116.  
  117.             IF topmargin% + ileadingmax - (imaxalienforce * 2) >= topmargin% + 2 THEN
  118.                 IF imothership <> 0 THEN CALL mship(imothership)
  119.             END IF
  120.             IF ABS(TIMER - z1aliens) > level THEN
  121.                 CALL movealiens(ialiencol, ialiencolstat, iresults)
  122.                 z1aliens = TIMER
  123.             END IF
  124.             IF iresults < 0 THEN EXIT DO
  125.             IF ABS(TIMER - z1ia) > .3 THEN CALL alienmissile(iresults): z1ia = TIMER
  126.  
  127.             DEF SEG = 0
  128.             IF PEEK(1047) MOD 16 = 7 OR PEEK(1047) MOD 16 = 8 THEN
  129.                 key$ = CHR$(32) ' Alt
  130.             ELSE
  131.                 key$ = ""
  132.             END IF
  133.             DEF SEG
  134.  
  135.             SELECT CASE key$
  136.                 CASE CHR$(32)
  137.                     IF flag = 0 THEN switch = switch * -1 - 1: flag = -1
  138.                     SELECT CASE switch
  139.                         CASE 0
  140.                             IF ABS(z9 - TIMER) > .15 THEN
  141.                                 IF POS(0) < screenwidth% THEN COLOR icolor, ibk: LOCATE , POS(0) - 1: PRINT " " + tank$;: LOCATE , POS(0) - 2
  142.                                 tanky% = CSRLIN: tankx% = POS(0)
  143.                                 IF SCREEN(tanky%, tankx% - 2) = 25 OR SCREEN(tanky%, tankx% + 2) = 25 THEN result = -1: EXIT DO
  144.                                 z9 = TIMER
  145.                             END IF
  146.                         CASE -1
  147.                             IF ABS(z9 - TIMER) > .15 THEN
  148.                                 IF POS(0) > lmargin% + 1 THEN COLOR icolor, ibk: LOCATE , POS(0) - 2: PRINT tank$ + " ";: LOCATE , POS(0) - 3
  149.                                 tanky% = CSRLIN: tankx% = POS(0)
  150.                                 IF SCREEN(tanky%, tankx% - 2) = 25 OR SCREEN(tanky%, tankx% + 2) = 25 THEN result = -1: EXIT DO
  151.                                 z9 = TIMER
  152.                             END IF
  153.                     END SELECT
  154.                     IF icolor = 6 THEN
  155.                         FOR i2 = 1 TO 5
  156.                             IF bullet%(i2) = 0 THEN
  157.                                 icolor = 12: COLOR icolor, ibk: GOSUB redraw
  158.                                 bullet%(i2) = -1: reload = TIMER: EXIT FOR
  159.                             END IF
  160.                         NEXT
  161.                     END IF
  162.                 CASE ""
  163.                     IF flag THEN skip = 0: flag = 0
  164.                 CASE CHR$(27): SYSTEM
  165.             END SELECT
  166.  
  167.             IF ABS(z1 - reload) > .6 AND reload <> 0 THEN
  168.                 GOSUB redraw
  169.                 icolor = 6: reload = 0
  170.             END IF
  171.  
  172.             REM Fire
  173.             FOR i = 1 TO 5
  174.                 SELECT CASE bullet%(i)
  175.                     CASE -1: bullet%(i) = tanky% - 1: bulletcol%(i) = tankx%
  176.                     CASE IS > 0
  177.                         IF bulletdelay%(i) = -1 OR bullet%(i) = tanky% - 1 THEN
  178.                             CALL checkcollision(ihitaliens, ialiencol, i4, i)
  179.                             z2bullet = TIMER: bulletdelay%(i) = 0
  180.                             COLOR 6, ibk
  181.                             LOCATE bullet%(i), bulletcol%(i)
  182.                             IF bullet%(i) = topmargin% AND imothership <> 0 THEN ' Hit mother ship.
  183.                                 IF SCREEN(ABS(bullet%(i)), bulletcol%(i)) <> 32 THEN
  184.                                     SOUND 1000, .75
  185.                                     SELECT CASE iresults + 1
  186.                                         CASE 1: bonus = 1500
  187.                                         CASE 2: bonus = 2500
  188.                                         CASE 3: bonus = 5000
  189.                                     END SELECT
  190.                                     score$ = LTRIM$(STR$(VAL(score$) + bonus))
  191.                                     score$ = STRING$(6 - LEN(score$), "0") + score$
  192.                                     yy% = CSRLIN: xx% = POS(0)
  193.                                     SOUND 800, .5: SOUND 1600, .5: SOUND 2400, .5
  194.                                     LOCATE topmargin%, lmargin%: PRINT SPACE$(screenwidth%);
  195.                                     kbonus = bulletcol%(i) - 4
  196.                                     IF kbonus < lmargin% THEN kbonus = lmargin%
  197.                                     IF kbonus + 10 > screenwidth% THEN kbonus = screenwidth% - 11
  198.                                     zbonus = TIMER
  199.                                     LOCATE yy%, xx%
  200.                                     imothership = 0
  201.                                 END IF
  202.                             END IF
  203.                             PRINT CHR$(24) ' Tank missile.
  204.                             IF CSRLIN <> 24 THEN LOCATE , bulletcol%(i): PRINT " ";
  205.                             IF ihitaliens <> 0 THEN CALL reprintaliens(ialiencol, ihitaliens, iresults, i4, i, imothership)
  206.                             LOCATE tanky%, tankx%
  207.                             IF bullet%(i) > topmargin% THEN
  208.                                 bullet%(i) = bullet%(i) - 1
  209.                             ELSE
  210.                                 GOSUB erasebullet
  211.                             END IF
  212.  
  213.                             IF zbonus THEN
  214.                                 yy% = CSRLIN: xx% = POS(0)
  215.                                 LOCATE topmargin%, kbonus: COLOR 2 + 16: PRINT "BONUS " + LTRIM$(STR$(bonus));
  216.                                 LOCATE yy%, xx%
  217.                             END IF
  218.  
  219.                         END IF
  220.                 END SELECT
  221.             NEXT
  222.  
  223.             REM Bullet timer delay
  224.             IF z2bullet <> 0 THEN
  225.                 IF z1 < z2bullet THEN z2bullet = z2bullet - 86400
  226.                 IF z1 - z2bullet >= .06 THEN
  227.                     FOR i2 = 1 TO 5
  228.                         IF bullet%(i2) <> 0 THEN bulletdelay%(i2) = -1
  229.                     NEXT i2
  230.                 END IF
  231.                 EXIT DO
  232.             END IF
  233.         LOOP
  234.         IF iresults < 0 THEN EXIT DO
  235.         IF alienforce% = 0 OR iresults = iwin THEN
  236.             FOR i = 1 TO imaxalienmissiles
  237.                 IF ia(i) <> 0 THEN EXIT FOR
  238.             NEXT
  239.             IF i > imaxalienmissiles THEN iwait = -1
  240.             IF iwait = -1 THEN
  241.                 EXIT DO
  242.             END IF
  243.         ELSE
  244.             iwait = 1
  245.         END IF
  246.     LOOP
  247.  
  248.     IF iresults = iwin OR iresults < 0 THEN
  249.         REM end game
  250.         EXIT DO
  251.     END IF
  252.     inextrnd = -1
  253.  
  254. SELECT CASE iresults
  255.     CASE -1 ' Tank destroyed!
  256.         SOUND 800, .3: SOUND 250, 1
  257.  
  258.         FOR i = 1 TO 5
  259.             COLOR 14, 4
  260.             LOCATE tanky%, tankx% - 1: PRINT tank$;
  261.             _DELAY .1
  262.  
  263.             COLOR 8, ibk
  264.             LOCATE tanky%, tankx% - 1: PRINT tank$;
  265.             _DELAY .1
  266.         NEXT
  267.  
  268.         COLOR 6, ibk
  269.         LOCATE tanky% - 1, lmargin%
  270.         PRINT SPACE$(screenwidth%);
  271.         LOCATE tanky%, lmargin%
  272.         PRINT SPACE$(screenwidth%);
  273.  
  274.         _DELAY .5
  275.  
  276.         LOCATE 3, 3
  277.         COLOR 8, 0
  278.         FOR i = 1 TO 20
  279.             LOCATE i + 2, 2
  280.             FOR j = 1 TO _WIDTH - 2
  281.                 PRINT CHR$(SCREEN(CSRLIN, POS(0)));
  282.             NEXT
  283.         NEXT
  284.         COLOR 6, 0
  285.  
  286.         _DELAY 2
  287.  
  288.         CALL displayhighscores
  289.  
  290.         CALL qbide
  291.  
  292.     CASE -2 ' Aliens have landed!
  293.         SOUND 1000, .3: SOUND 2400, .6:: SOUND 700, 2
  294.  
  295.         COLOR 7, 0
  296.         FOR i = 0 TO 21 ' Blank out screen.
  297.             LOCATE topmargin% + i, lmargin%: PRINT SPACE$(screenwidth%);
  298.         NEXT
  299.  
  300.         COLOR 6, ibk
  301.         LOCATE tanky% - 1, lmargin%
  302.         PRINT SPACE$(screenwidth%);
  303.         LOCATE tanky%, lmargin%
  304.         PRINT SPACE$(screenwidth%);
  305.  
  306.         COLOR 8, ibk
  307.  
  308.         FOR j = imaxalienforce TO 1 STEP -1
  309.             IF a(j) <> "" THEN EXIT FOR
  310.         NEXT
  311.  
  312.         FOR i = j TO 1 STEP -1
  313.             IF INSTR(a(i), CHR$(79)) THEN
  314.                 LOCATE , ialiencol + INSTR(a(i), CHR$(79)) - 2
  315.                 PRINT LTRIM$(RTRIM$(a(i)));
  316.                 LOCATE CSRLIN - 2
  317.             END IF
  318.         NEXT
  319.  
  320.         _DELAY 2.5
  321.  
  322.         CALL displayhighscores
  323.  
  324.         CALL qbide
  325.  
  326.     CASE ELSE ' Winner.
  327.  
  328.         l$ = "4"
  329.         n$ = "n29": PLAY "L" + l$ + n$
  330.         n$ = "n24": PLAY "L" + l$ + n$
  331.         n$ = "n33": PLAY "L" + l$ + n$
  332.         n$ = "n29": PLAY "L" + l$ + n$
  333.         _DELAY .75
  334.         l$ = "7"
  335.         n$ = "n24": PLAY "L" + l$ + n$
  336.         n$ = "n28": PLAY "L" + l$ + n$
  337.         n$ = "n28": PLAY "L" + l$ + n$
  338.         l$ = "6"
  339.         n$ = "n31": PLAY "L" + l$ + n$
  340.         l$ = "8"
  341.         n$ = "n28": PLAY "L" + l$ + n$
  342.         l$ = "3"
  343.         _DELAY 1
  344.  
  345.         CALL displayhighscores
  346.  
  347.         CALL qbide
  348.  
  349.         RESTORE winner
  350.  
  351.  
  352. CALL instructions
  353.  
  354. DEF SEG = 0
  355.     _LIMIT 30
  356.     b$ = INKEY$
  357.     IF b$ = CHR$(27) THEN SYSTEM
  358.     IF PEEK(1047) MOD 16 = 7 OR PEEK(1047) MOD 16 = 8 THEN EXIT DO
  359.  
  360. RUN skip_intro
  361.  
  362. erasebullet:
  363. LOCATE ABS(bullet%(i)), bulletcol%(i): PRINT " ";
  364. bullet%(i) = 0: bulletcol%(i) = 0: bulletdelay%(i) = 0
  365. LOCATE tanky%, tankx%
  366.  
  367. redraw:
  368. COLOR , ibk: LOCATE tanky%, tankx% - 1: PRINT tank$;: LOCATE tanky%, tankx%: COLOR 7, ibk
  369.  
  370. first_play:
  371. DATA "The Great Pumpkin has fired an EM pulse at your computer."
  372. DATA ""
  373. DATA "All that's working is your Alt key."
  374. DATA ""
  375. replay:
  376. DATA "Loading..."
  377. DATA "EOF"
  378. DATA "Game Over. Press Alt to play again..."
  379. DATA "EOF2"
  380. winner:
  381. DATA "Congratulations, you saved the planet!"
  382. DATA ""
  383. DATA "Press Alt to play again..."
  384. DATA "EOF3"
  385.  
  386.  
  387. SUB alienattack (ialiencol)
  388.     z2alienfire = TIMER
  389.  
  390.     i3 = INT(RND * 10)
  391.     FOR i = 1 TO imaxalienmissiles
  392.         IF ia(i) = 0 THEN
  393.             FOR i2 = imaxalienforce TO 1 STEP -1
  394.                 IF RTRIM$(a(i2)) <> "" THEN
  395.                     IF MID$(matrix(i2), i3 + 1, 1) <> "0" THEN
  396.                         i4 = INSTR(i3 * 7 + 1, a(i2), CHR$(79)) + ialiencol
  397.                         EXIT FOR
  398.                     END IF
  399.                 END IF
  400.             NEXT i2
  401.             IF i4 <> 0 THEN
  402.                 ia(i) = (ileadingmax - (imaxalienforce - i2) * 2) * 80 + i4
  403.                 EXIT FOR
  404.             END IF
  405.         END IF
  406.     NEXT i
  407.  
  408.  
  409. SUB alienmissile (iresults)
  410.     irow = CSRLIN: icol = POS(0)
  411.     FOR i = 1 TO imaxalienmissiles
  412.         IF ia(i) <> 0 THEN
  413.             IF iy(i) = 0 THEN
  414.                 iy(i) = ia(i) \ 80: ix(i) = ia(i) MOD 80
  415.                 IF ix(i) = 0 THEN ix(i) = screenwidth%
  416.             END IF
  417.             LOCATE iy(i) + 1, ix(i)
  418.             COLOR 6, ibk
  419.             IF CSRLIN <= 24 THEN
  420.                 IF CSRLIN = 24 THEN IF SCREEN(CSRLIN, ix(i)) <> 32 THEN iresults = -1
  421.                 PRINT CHR$(25);
  422.             ELSE
  423.                 ia(i) = 0
  424.                 LOCATE iy(i), ix(i)
  425.                 PRINT " ";: iy(i) = 0
  426.                 ia(i) = 0
  427.                 LOCATE irow, icol
  428.                 EXIT SUB
  429.             END IF
  430.             LOCATE iy(i), ix(i): PRINT " ";
  431.             iy(i) = iy(i) + 1
  432.         END IF
  433.     NEXT
  434.     LOCATE irow, icol
  435.  
  436.  
  437. SUB checkcollision (ihitaliens, ialiencol, i4, i)
  438.     ihitaliens = 0
  439.     IF ileadingmax MOD 2 = bullet%(i) MOD 2 THEN
  440.         i4 = imaxalienforce - (ileadingmax - bullet%(i)) \ 2
  441.         IF bullet%(i) <= ileadingrow AND i4 > 0 AND i4 <= imaxalienforce THEN
  442.             IF RTRIM$(a(i4)) <> "" THEN
  443.                 IF bulletcol%(i) >= iltalien(i4) AND bulletcol%(i) - ialiencol <= LEN(RTRIM$(a(i4))) THEN
  444.                     IF MID$(a(i4), bulletcol%(i) - ialiencol, 1) > CHR$(32) THEN
  445.                         SOUND 1100, .2: SOUND 334, .1: SOUND 590, .4
  446.                         ihitaliens = bulletcol%(i) - ialiencol + 1
  447.                         i3 = ihitaliens - 7 + 1
  448.                         IF i3 < 1 THEN i3 = 1
  449.                         i2 = INSTR(i3 + 1, a(i4), "^" + CHR$(79)) - 1
  450.                         i2 = INSTR(i3 + 1, a(i4), CHR$(79)) - 2
  451.                         MID$(a(i4), i2, 7) = SPACE$(7)
  452.                         MID$(matrix(i4), (i2 + 1) \ 7 + 1, 1) = "0"
  453.                     END IF
  454.                 END IF
  455.             END IF
  456.         END IF
  457.     END IF
  458.  
  459.     FOR i2 = 1 TO imaxalienmissiles
  460.         IF ia(i2) <> 0 THEN
  461.             IF iy(i2) >= bullet%(i) AND ix(i2) = bulletcol%(i) THEN
  462.                 ihitaliens = -i2
  463.                 EXIT FOR
  464.             END IF
  465.         END IF
  466.     NEXT
  467.  
  468.  
  469. SUB instructions
  470.     IF in$ = "" THEN
  471.         LOCATE 3, 3, 1, 7, 0: COLOR 6, ibk
  472.         _DELAY 2
  473.         DO
  474.             READ in$
  475.             IF MID$(in$, 1, 3) = "EOF" THEN EXIT DO
  476.             FOR i = 1 TO LEN(in$)
  477.                 SOUND 400, .06
  478.                 LOCATE , 2 + i
  479.                 PRINT MID$(in$, i, 1);
  480.                 z = TIMER
  481.                 DO
  482.                     IF ABS(z - TIMER) > .06 THEN EXIT DO
  483.                 LOOP
  484.             NEXT
  485.             LOCATE , , 0, 7, 0
  486.             _DELAY 1
  487.             PRINT
  488.             LOCATE , 3
  489.         LOOP
  490.         _DELAY .75
  491.     END IF
  492.  
  493.     IF in$ = "EOF" THEN
  494.         COLOR 7, 0
  495.         FOR i = 0 TO 19 ' Blank out intro message space.
  496.             LOCATE topmargin% + i, lmargin%: PRINT SPACE$(screenwidth%);
  497.         NEXT
  498.         FOR i = 3 TO 24
  499.             LOCATE i, 80: PRINT CHR$(179);
  500.         NEXT
  501.         LOCATE 21, 2: PRINT STRING$(screenwidth%, " ");
  502.         LOCATE 22, 1: PRINT CHR$(179);
  503.         LOCATE 22, 80: PRINT CHR$(179);
  504.         LOCATE 22, 2: PRINT STRING$(screenwidth%, " ");
  505.     ELSE
  506.         COLOR 0, 3
  507.     END IF
  508.  
  509.     IF in$ <> "EOF2" AND iresults <> iwin THEN COLOR 0 + 16, 3 ELSE COLOR 0, 3
  510.     yy% = CSRLIN: xx% = POS(0)
  511.     LOCATE 25, 68: PRINT "Score ";
  512.     COLOR 0, 3
  513.     PRINT score$;
  514.     LOCATE yy%, xx%
  515.  
  516.     PCOPY 0, 3: REM save skin
  517.  
  518.  
  519. SUB marchdown (ialiencol, ialiencolstat, imotion, iresults)
  520.     COLOR 6, ibk
  521.     ileadingrow = ileadingrow + 1
  522.     ileadingmax = ileadingmax + 1
  523.     COLOR 6, ibk
  524.     FOR i = 1 TO imaxalienforce
  525.         REM SOUND 400, .2 ' Level down.
  526.         IF RTRIM$(a(i)) <> "" THEN
  527.             ialiencol = ialiencolstat + imotion
  528.             LOCATE ileadingmax - (imaxalienforce * 2) + i * 2 - 1, lmargin%
  529.             PRINT STRING$(screenwidth%, " ")
  530.             LOCATE , ialiencol + INSTR(a(i), CHR$(79)) - 2
  531.             iltalien(i) = POS(0)
  532.             PRINT LTRIM$(RTRIM$(a(i)))
  533.         END IF
  534.     NEXT
  535.     LOCATE irow, icol
  536.     level = level - .025
  537.     IF ileadingrow = 22 THEN iresults = -2 ' Aliens have landed!
  538.  
  539. SUB movealiens (ialiencol, ialiencolstat, iresults)
  540.     STATIC imotion, imarch, imotiondir
  541.  
  542.     SOUND 800, .1: SOUND 200, .33 ' Marching sound.
  543.  
  544.     IF inextrnd = -1 THEN inextrnd = 0: imotion = 0: imarch = 0: imotiondir = 0
  545.     irow = CSRLIN: icol = POS(0)
  546.     yy% = CSRLIN: xx% = POS(0)
  547.     PCOPY 0, 1: SCREEN 0, 0, 1, 0: LOCATE yy%, xx%, 0, 7, 0
  548.     IF imotiondir = 0 THEN imotion = imotion - 1 ELSE imotion = imotion + 1
  549.     COLOR 6, ibk
  550.  
  551.     FOR i = imaxalienforce TO 1 STEP -1
  552.         IF RTRIM$(a(i)) <> "" THEN
  553.             FOR k = 1 TO LEN(a(i))
  554.                 k$ = MID$(a(i), k, 1)
  555.                 IF k$ = "^" THEN
  556.                     MID$(a(i), k, 1) = "-"
  557.                 ELSEIF k$ = "-" THEN
  558.                     MID$(a(i), k, 1) = "^"
  559.                 END IF
  560.             NEXT
  561.             i2 = i2 + 2
  562.             ialiencol = ialiencolstat + imotion
  563.             LOCATE ileadingmax - (imaxalienforce - i) * 2, ialiencol + INSTR(a(i), CHR$(79)) - 2
  564.             IF POS(0) = lmargin% THEN imarch = 1
  565.             iltalien(i) = POS(0)
  566.             IF imotiondir = 0 THEN
  567.                 PRINT LTRIM$(RTRIM$(a(i))); " "
  568.             ELSE
  569.                 LOCATE , POS(0) - 1
  570.                 PRINT " "; LTRIM$(RTRIM$(a(i)))
  571.             END IF
  572.             IF ialiencol + LEN(RTRIM$(a(i))) = screenwidth% THEN imarch = -1
  573.         END IF
  574.     NEXT
  575.  
  576.     IF imarch = 1 THEN imotiondir = 1: CALL marchdown(ialiencol, ialiencolstat, imotion, iresults)
  577.     IF imarch = -1 THEN imotiondir = 0: CALL marchdown(ialiencol, ialiencolstat, imotion, iresults)
  578.     IF imarch = 0 THEN
  579.         IF ABS(TIMER - z2alienfire) > firerate THEN
  580.             firerate = (INT(RND * 10) + 1) / 20
  581.             IF iwait = 0 THEN CALL alienattack(ialiencol)
  582.         END IF
  583.     ELSE
  584.         imarch = 0
  585.     END IF
  586.     PCOPY 1, 0: SCREEN 0, 0, 0, 0
  587.     LOCATE irow, icol, 1, 7, 0
  588.  
  589. SUB mship (imothership)
  590.     STATIC x%, mov%, z4, mothership$
  591.  
  592.     yy% = CSRLIN: xx% = POS(0): COLOR 6, ibk
  593.     IF imothership = -1 THEN
  594.         imothership = 1
  595.         x% = lmargin%
  596.         mothership$ = "(" + CHR$(127) + CHR$(179) + CHR$(127) + ")" 'CHR$(254) + CHR$(254) + "O" + CHR$(254) + CHR$(254)
  597.         mov% = 1
  598.     END IF
  599.  
  600.     IF ABS(TIMER - z4) > .05 THEN GOSUB mothership: z4 = TIMER
  601.     LOCATE yy%, xx%
  602.     EXIT SUB
  603.  
  604.     mothership:
  605.     IF x% + LEN(mothership$) = screenwidth% + lmargin% THEN mov% = -1 ELSE IF x% = lmargin% THEN mov% = 1
  606.     x% = x% + mov%
  607.     LOCATE topmargin%, x%
  608.     COLOR 7, 6: PRINT MID$(mothership$, 1, 1);
  609.     COLOR 14, 6: PRINT MID$(mothership$, 2, 1);
  610.     COLOR 7, 6: PRINT MID$(mothership$, 3, 1);
  611.     COLOR 14, 6: PRINT MID$(mothership$, 4, 1);
  612.     COLOR 7, 6: PRINT MID$(mothership$, 5, 1);
  613.     COLOR 7, ibk
  614.     IF x% > 1 AND mov% = 1 THEN
  615.         LOCATE , POS(0) - LEN(mothership$) - 1: PRINT " ";
  616.     END IF
  617.     IF mov% = -1 THEN PRINT " ";
  618.     RETURN
  619.  
  620.  
  621. DEFINT A-H, J-Z
  622. SUB qbide
  623.     PALETTE 2, 59
  624.     COLOR 15, 0
  625.     CLS
  626.  
  627.     COLOR 0, 7
  628.     LOCATE 1, 1
  629.     PRINT SPACE$(80)
  630.     LOCATE 1, 1: PRINT "   File  Edit  View  Search  Run  Debug  Calls  Options                   Help"
  631.  
  632.     COLOR 7, 0 ' Black background.
  633.  
  634.     LOCATE 2, 1: PRINT CHR$(218)
  635.     LOCATE 2, 2: PRINT STRING$(78, CHR$(196))
  636.     LOCATE 2, 80: PRINT CHR$(191)
  637.  
  638.     LOCATE 2, 76: PRINT CHR$(180)
  639.     LOCATE 2, 78: PRINT CHR$(195)
  640.  
  641.     COLOR 0, 7
  642.     LOCATE 2, 77: PRINT CHR$(24)
  643.     LOCATE 2, 36: PRINT " Untitled "
  644.  
  645.     COLOR 7, 0
  646.     FOR Rows = 3 TO 24
  647.         LOCATE Rows, 1: PRINT CHR$(179);
  648.         LOCATE Rows, 80: PRINT CHR$(179);
  649.     NEXT Rows
  650.  
  651.     LOCATE 22, 1: PRINT CHR$(195)
  652.     LOCATE 22, 80: PRINT CHR$(180)
  653.     LOCATE 22, 2: PRINT STRING$(78, CHR$(196))
  654.     LOCATE 22, 35
  655.     PRINT " Immediate "
  656.  
  657.     COLOR 0, 7
  658.     LOCATE 21, 3: PRINT STRING$(76, CHR$(176))
  659.     LOCATE 21, 2: PRINT CHR$(27)
  660.     LOCATE 21, 3: PRINT CHR$(219)
  661.     LOCATE 21, 79: PRINT CHR$(26)
  662.     FOR Rows = 4 TO 19
  663.         LOCATE Rows, 80: PRINT CHR$(176)
  664.     NEXT Rows
  665.     LOCATE 3, 80: PRINT CHR$(24)
  666.     LOCATE 4, 80: PRINT CHR$(219)
  667.     LOCATE 20, 80: PRINT CHR$(25)
  668.  
  669.     COLOR 0, 3: LOCATE 25, 1: PRINT " <Shift+F1=Help> <F6=Window> <F2=Subs> <F5=Run> <F8=Step> ";
  670.     LOCATE 25, 59: PRINT SPACE$(4);
  671.     COLOR 0, 3
  672.     LOCATE 25, 63: PRINT CHR$(179);
  673.     LOCATE 25, 64: PRINT SPACE$(6);
  674.     LOCATE 25, 68: PRINT "C  00001:001 ";
  675.  
  676.  
  677. DEFSNG A-H, J-Z
  678. SUB reprintaliens (ialiencol, ihitaliens, iresults, i4, i, imothership)
  679.     IF ihitaliens > 0 THEN
  680.         ihits = ihits + 1
  681.  
  682.         SELECT CASE iresults + 1
  683.             CASE 1: score$ = LTRIM$(STR$(VAL(score$) + 150))
  684.             CASE 2: score$ = LTRIM$(STR$(VAL(score$) + 250))
  685.             CASE 3: score$ = LTRIM$(STR$(VAL(score$) + 350))
  686.         END SELECT
  687.  
  688.         score$ = STRING$(6 - LEN(score$), "0") + score$
  689.         IF (ihits + 15) MOD 20 = 0 AND imothership = 0 THEN imothership = -1
  690.         LOCATE bullet%(i), lmargin%: PRINT SPACE$(screenwidth%);
  691.         iltalien(i4) = POS(0)
  692.  
  693.         IF RTRIM$(a(i4)) = "" THEN
  694.             alienforce% = alienforce% - 1
  695.             IF alienforce% = 0 THEN iresults = iresults + 1 ' Level completed. Goto to next level.
  696.             IF bullet%(i) = ileadingrow THEN ileadingrow = ileadingrow - 2
  697.         ELSE
  698.             LOCATE bullet%(i), ialiencol + INSTR(a(i4), CHR$(79)) - 2
  699.             PRINT LTRIM$(RTRIM$(a(i4)))
  700.         END IF
  701.     ELSE
  702.         i2 = ABS(ihitaliens)
  703.         LOCATE iy(i2), ix(i2)
  704.         PRINT " ";: iy(i2) = 0
  705.         ia(i2) = 0
  706.         LOCATE irow, icol
  707.         IF soundfile% = 0 THEN
  708.             SOUND 1000, .5
  709.         ELSE
  710.             z4 = TIMER
  711.             DO
  712.                 IF eflag THEN
  713.                     IF ABS(z4 - TIMER) > .1 THEN
  714.                         eflag = 0
  715.  
  716.                         PALETTE 0, 0
  717.  
  718.                         EXIT DO
  719.                     ELSE
  720.                         j = -j * -1
  721.                         IF j = 0 THEN
  722.                             PALETTE 0, 63
  723.                             _DELAY .05
  724.                         ELSE
  725.                             PALETTE 0, 0
  726.                             _DELAY .05
  727.                         END IF
  728.                     END IF
  729.                 END IF
  730.                 IF eflag = 0 THEN
  731.                     PALETTE 0, 36
  732.                     IF soundfile% THEN
  733.                         _SNDPLAY t1&
  734.                         _DELAY .05
  735.                         _SNDPLAY t7&
  736.                     ELSE
  737.                         _DELAY .075
  738.                     END IF
  739.  
  740.                     eflag = -1
  741.                     z4 = TIMER
  742.                 END IF
  743.             LOOP
  744.             SELECT CASE iresults + 1
  745.                 CASE 1: bonus = 500
  746.                 CASE 2: bonus = 1500
  747.                 CASE 3: bonus = 2500
  748.             END SELECT
  749.             score$ = LTRIM$(STR$(VAL(score$) + bonus))
  750.             score$ = STRING$(6 - LEN(score$), "0") + score$
  751.         END IF
  752.     END IF
  753.  
  754.     ihitaliens = 0
  755.     bullet%(i) = -bullet%(i)
  756.  
  757.     COLOR 0, 3
  758.     yy% = CSRLIN: xx% = POS(0)
  759.     LOCATE 25, 74: PRINT score$;
  760.     LOCATE yy%, xx%
  761.     COLOR 6, ibk
  762.  
  763.  
  764. SUB qbideOrig
  765.     PALETTE 2, 59
  766.     COLOR 15, 1
  767.     CLS
  768.  
  769.     COLOR 0, 7
  770.     LOCATE 1, 1
  771.     PRINT SPACE$(80)
  772.     LOCATE 1, 1: PRINT "   File  Edit  View  Search  Run  Debug  Calls  Options                   Help"
  773.  
  774.     COLOR 7, 1
  775.  
  776.     LOCATE 2, 1: PRINT CHR$(218)
  777.     LOCATE 2, 2: PRINT STRING$(78, CHR$(196))
  778.     LOCATE 2, 80: PRINT CHR$(191)
  779.  
  780.     LOCATE 2, 76: PRINT CHR$(180)
  781.     LOCATE 2, 78: PRINT CHR$(195)
  782.  
  783.     COLOR 1, 7
  784.     LOCATE 2, 77: PRINT CHR$(24)
  785.     LOCATE 2, 36: PRINT " Untitled "
  786.  
  787.     COLOR 7, 1
  788.     FOR Rows = 3 TO 24
  789.         LOCATE Rows, 1: PRINT CHR$(179);
  790.         LOCATE Rows, 80: PRINT CHR$(179);
  791.     NEXT Rows
  792.  
  793.     LOCATE 22, 1: PRINT CHR$(195)
  794.     LOCATE 22, 80: PRINT CHR$(180)
  795.     LOCATE 22, 2: PRINT STRING$(78, CHR$(196))
  796.     LOCATE 22, 35
  797.     PRINT " Immediate "
  798.  
  799.     COLOR 0, 7
  800.     LOCATE 21, 3: PRINT STRING$(76, CHR$(176))
  801.     LOCATE 21, 2: PRINT CHR$(27)
  802.     LOCATE 21, 3: PRINT CHR$(219)
  803.     LOCATE 21, 79: PRINT CHR$(26)
  804.     FOR Rows = 4 TO 19
  805.         LOCATE Rows, 80: PRINT CHR$(176)
  806.     NEXT Rows
  807.     LOCATE 3, 80: PRINT CHR$(24)
  808.     LOCATE 4, 80: PRINT CHR$(219)
  809.     LOCATE 20, 80: PRINT CHR$(25)
  810.  
  811.     COLOR 0, 3: LOCATE 25, 1: PRINT " <Shift+F1=Help> <F6=Window> <F2=Subs> <F5=Run> <F8=Step> ";
  812.     LOCATE 25, 59: PRINT SPACE$(4);
  813.     COLOR 0, 3
  814.     LOCATE 25, 63: PRINT CHR$(179);
  815.     LOCATE 25, 64: PRINT SPACE$(6);
  816.     LOCATE 25, 68: PRINT "C  00001:001 ";
  817.  
  818.  
  819. SUB TheBOB
  820.     SCREEN _NEWIMAGE(800, 600, 256)
  821.     WIDTH 80, 25
  822.  
  823.     OUT &H3C8, 1: OUT &H3C9, 40: OUT &H3C9, 12: OUT &H3C9, 0
  824.     OUT &H3C8, 2: OUT &H3C9, 6: OUT &H3C9, 12: OUT &H3C9, 0
  825.     OUT &H3C8, 3: OUT &H3C9, 30: OUT &H3C9, 8: OUT &H3C9, 0
  826.     OUT &H3C8, 4: OUT &H3C9, 3: OUT &H3C9, 8: OUT &H3C9, 0
  827.     OUT &H3C8, 7: OUT &H3C9, 63: OUT &H3C9, 0: OUT &H3C9, 0
  828.     OUT &H3C8, 8: OUT &H3C9, 46: OUT &H3C9, 0: OUT &H3C9, 0
  829.     OUT &H3C8, 9: OUT &H3C9, 63: OUT &H3C9, 63: OUT &H3C9, 63
  830.     OUT &H3C8, 12: OUT &H3C9, 20: OUT &H3C9, 20: OUT &H3C9, 20
  831.     OUT &H3C8, 13: OUT &H3C9, 0: OUT &H3C9, 0: OUT &H3C9, 0
  832.     OUT &H3C8, 14: OUT &H3C9, 55: OUT &H3C9, 35: OUT &H3C9, 0
  833.  
  834.     CIRCLE (320, 240), 100, 3, , , .9
  835.     PAINT (320, 240), 3
  836.     CIRCLE (320, 230), 90, 1, , , .9
  837.     PAINT (320, 230), 1
  838.  
  839.     FOR Reps = 1 TO 4
  840.         SELECT CASE Reps
  841.             DATA 1,1.2,1.8,5
  842.             CASE 1: Elipse = 1
  843.             CASE 2: Elipse = 1.2
  844.             CASE 3: Elipse = 1.8
  845.             CASE 4: Elipse = 5
  846.         END SELECT
  847.         FOR E = Elipse TO Elipse + .1 STEP .01
  848.             CIRCLE (320, 240), 100, 3, , , E
  849.         NEXT E
  850.     NEXT Reps
  851.     FOR Radius = 38 TO 43
  852.         CIRCLE (320, 160), Radius, 3, , , .4
  853.     NEXT Radius
  854.     CIRCLE (320, 160), 40, 14, 3.3, 6, .4
  855.     CIRCLE (320, 240), 100, 5, , , .9
  856.     PAINT (0, 0), 5
  857.     CIRCLE (320, 240), 100, 0, , , .9
  858.     PAINT (0, 0), 0
  859.     FOR Radius = 12 TO 18
  860.         CIRCLE (320, 153), Radius, 2, , , .3
  861.     NEXT Radius
  862.  
  863.     CIRCLE (320, 150), 12, 2, , , .6
  864.     PAINT STEP(0, 0), 2
  865.     CIRCLE (300, 143), 32, 2, 6, 1.1
  866.     CIRCLE (276, 143), 32, 2, 6, .6
  867.     DRAW "BM302,125 C2 M+15,-10 BD10 P2,2"
  868.     PAINT (320, 145), 2
  869.     CIRCLE (282, 143), 32, 4, 6, .73
  870.     CIRCLE (266, 156), 60, 4, .1, .68
  871.     CIRCLE (320, 150), 12, 4, 3.14159, 0, .2
  872.     DRAW "BM302,125 C4 M+15,-10 BD10"
  873.     CIRCLE (276, 143), 32, 4, 6, .6
  874.     PAINT STEP(35, 0), 4
  875.     'Face begins
  876.     CIRCLE (303, 316), 100, 14, 1.5, 2
  877.     CIRCLE (337, 316), 100, 14, 1.1, 1.64
  878.     PSET (310, 215), 14
  879.     DRAW "H30 M-20,+40 M+12,-4 M+14,-29 BL2 P14,14 BF12 P15,14"
  880.     PSET (330, 215), 14
  881.     DRAW "E30 M+20,+40 M-12,-4 M-14,-29 BR2 P14,14 BG12 P15,14"
  882.     PSET (320, 246), 14
  883.     DRAW "R20 H20 G20 R20 U nL19 nR19 BU2 P15,14"
  884.     CIRCLE (320, 170), 100, 14, 3.8, 4.1
  885.     CIRCLE (320, 170), 100, 14, 4.42, 5.01
  886.     CIRCLE (320, 170), 100, 14, 5.33, 5.62
  887.     CIRCLE (320, 220), 80, 14, 3.29, 4.5
  888.     CIRCLE (320, 220), 80, 14, 4.66, 6.15
  889.     PSET (260, 250), 14
  890.     DRAW "D10 F8 U13 M+10,+5 D12 M+12,+6 U12 BR60"
  891.     DRAW "D12 M+12,-6 U12 M+10,-5 D13 E8 U10"
  892.     PSET (300, 297), 14
  893.     DRAW "U14 R16 D16"
  894.     CIRCLE (320, 212), 80, 14, 3.42, 4.5
  895.     CIRCLE (320, 212), 80, 14, 4.66, 6
  896.     LINE (300, 280)-(316, 283), 14, BF
  897.     PAINT (320, 296), 14
  898.     PAINT (290, 292), 14
  899.     PAINT (300, 278), 15, 14
  900.     CIRCLE (100, 240), 32, 13
  901.     PAINT STEP(0, 0), 13
  902.  
  903.     FOR x% = 58 TO 142
  904.         FOR y% = 198 TO 282
  905.             IF POINT(x%, y%) = 13 THEN
  906.                 IF POINT(x% + 220, y%) = 15 THEN PSET (x% + 220, y%), 9
  907.             END IF
  908.         NEXT y%
  909.     NEXT x%
  910.  
  911.     COLOR 13: LOCATE 1, 1: PRINT "HAPPY HALLOWEEN!"
  912.  
  913.     xx = 64: yy = 360 - 330
  914.     FOR x% = 0 TO 300
  915.         FOR y% = 0 TO 16
  916.             IF POINT(x%, y%) = 13 THEN
  917.                 IF y% > 6 THEN Colr = 8 ELSE Colr = 7
  918.                 LINE (x% * 4 + xx, y% * 4 + yy)-(x% * 4 + xx + 3, y% * 4 + yy + 3), Colr, BF
  919.             END IF
  920.         NEXT y%
  921.     NEXT x%
  922.     FOR x% = 0 TO 639
  923.         IF POINT(x%, 368) <> 0 THEN PSET (x%, 368), 14
  924.     NEXT x%
  925.  
  926.     z1 = TIMER
  927.     DO UNTIL ABS(TIMER - z1) > 4
  928.         FOR Reps = 1 TO 3
  929.             WAIT &H3DA, 8
  930.             WAIT &H3DA, 8, 8
  931.         NEXT Reps
  932.  
  933.         Flicker = FIX(RND * 20)
  934.         OUT &H3C8, 14
  935.         OUT &H3C9, 40 + Flicker
  936.         OUT &H3C9, 25 + Flicker
  937.         OUT &H3C9, 10 + Flicker
  938.  
  939.         OUT &H3C8, 15
  940.         OUT &H3C9, 43 + Flicker
  941.         OUT &H3C9, 38 + Flicker
  942.         OUT &H3C9, 20 + Flicker
  943.     LOOP
  944.     SCREEN 0, 0, 0, 0
  945.  
  946. SUB displayhighscores
  947.  
  948.     COLOR 0, 3
  949.     LOCATE 25, 68: PRINT "Score "; score$;
  950.  
  951.     DIM hs AS STRING * 25
  952.     REDIM highscore$(6), hsdata$(6)
  953.     DO
  954.         IF _FILEEXISTS("ascii-invaders-high-score.dat") THEN
  955.             OPEN "ascii-invaders-high-score.dat" FOR RANDOM AS #1 LEN = 25
  956.             FOR i = 1 TO 5
  957.                 GET #1, i, hs
  958.                 highscore$(i) = MID$(hs, 10, 6): hsdata$(i) = hs
  959.             NEXT
  960.             CLOSE #1
  961.         ELSE
  962.             FOR i = 1 TO 5
  963.                 hsdata$(i) = SPACE$(25)
  964.             NEXT
  965.         END IF
  966.  
  967.         IF VAL(score$) > VAL(highscore$(5)) THEN
  968.  
  969.             IF VAL(score$) > VAL(highscore$(1)) THEN
  970.                 msg$ = " HIGH SCORE / Enter Your Initials! "
  971.             ELSE
  972.                 msg$ = " Top 5 Score. Enter Your Initials! "
  973.             END IF
  974.  
  975.             GOSUB hiscore
  976.  
  977.             a = 14
  978.             OUT &H3C8, 0
  979.             OUT &H3C9, 20 - a
  980.             OUT &H3C9, 20 - a
  981.             OUT &H3C9, 20 - a
  982.  
  983.             OUT &H3C8, 8
  984.             OUT &H3C9, 30 - a
  985.             OUT &H3C9, 30 - a
  986.             OUT &H3C9, 30 - a
  987.  
  988.             OUT &H3C8, 7
  989.             OUT &H3C9, 30 - a
  990.             OUT &H3C9, 30 - a
  991.             OUT &H3C9, 30 - a
  992.  
  993.             OUT &H3C8, 3
  994.             OUT &H3C9, 30 - a
  995.             OUT &H3C9, 30 - a
  996.             OUT &H3C9, 30 - a
  997.  
  998.             GOSUB hardware_overlay
  999.  
  1000.             _FONT 16
  1001.  
  1002.             COLOR White, 0
  1003.             t$ = msg$
  1004.             PSLC 4.6, 41 - LEN(msg$) \ 2, t$
  1005.  
  1006.             font = _LOADFONT("lucon.ttf", 20, "monospace")
  1007.             IF font <= 0 THEN font = 16
  1008.             _FONT font
  1009.  
  1010.             DEF SEG = 0
  1011.             delay = .4
  1012.             lscr = 19
  1013.             z3 = TIMER
  1014.             DO
  1015.                 initials$ = "": i = 0: nxt = 0
  1016.                 COLOR , _RGB(24, 24, 24): t$ = "   " ' Blank initials for redo. Okay to blank at start.
  1017.                 PSL 5 + rank * 2, lscr, t$
  1018.                 _DISPLAY
  1019.                 DO
  1020.                     _LIMIT 60
  1021.                     IF ABS(z3 - TIMER) > .3 AND kflag > -2 THEN
  1022.                         underline 5 + rank * 2, lscr + nxt, 0
  1023.                         _DISPLAY
  1024.                         z3 = TIMER
  1025.                     END IF
  1026.  
  1027.                     SELECT CASE kflag
  1028.                         CASE 0
  1029.                             IF ABS(z1 - TIMER) > 1.5 AND i AND nxt < 3 THEN
  1030.                                 SOUND 1500, 1
  1031.                                 underline 5 + rank * 2, lscr + nxt, -1: uflag = 0
  1032.                                 _DISPLAY
  1033.                                 initials$ = initials$ + CHR$(64 + i)
  1034.                                 nxt = nxt + 1 ' Next initial
  1035.                                 i = 0 ' Reset alphabet.
  1036.                                 z1 = TIMER
  1037.                                 IF nxt = 3 THEN
  1038.                                     kflag = -2 ' All 3 initials have been input.
  1039.                                     underline 5 + rank * 2, lscr + nxt, -1: uflag = 0
  1040.                                     _DISPLAY
  1041.                                 END IF
  1042.                             END IF
  1043.  
  1044.                             IF PEEK(1047) MOD 16 = 7 OR PEEK(1047) MOD 16 = 8 THEN
  1045.                                 kflag = -1 ' Alt key pressed.
  1046.                                 z1 = TIMER: z2 = TIMER
  1047.                                 i = i + 1: IF i > 26 THEN i = 1
  1048.                                 COLOR , _RGB(24, 24, 24): t$ = " "
  1049.                                 PSL 5 + rank * 2, lscr + nxt, t$
  1050.                                 COLOR DarkOrange: t$ = CHR$(64 + i)
  1051.                                 SOUND 1000, .1
  1052.                                 PSL 5 + rank * 2, lscr + nxt, t$
  1053.                                 underline 5 + rank * 2, lscr + nxt, 0
  1054.                                 _DISPLAY
  1055.                             END IF
  1056.                         CASE -1
  1057.                             IF ABS(z2 - TIMER) > 2 THEN ' Key down long enough to indicate redo input.
  1058.                                 IF nxt > 0 THEN ' Redo last initial input.
  1059.                                     SOUND 300, .5
  1060.                                     FOR nxt = 0 TO 3
  1061.                                         underline 5 + rank * 2, lscr + nxt, -1: uflag = 0
  1062.                                     NEXT
  1063.                                     nxt = 0: i = 0
  1064.                                     initials$ = ""
  1065.                                     COLOR , _RGB(24, 24, 24): t$ = "   "
  1066.                                     PSL 5 + rank * 2, lscr, t$
  1067.                                     _DISPLAY
  1068.                                     z1 = TIMER ' Reset enter timer.
  1069.                                 ELSE
  1070.                                     SOUND 300, .5
  1071.                                     i = 0
  1072.                                     COLOR , _RGB(24, 24, 24): t$ = " "
  1073.                                     PSL 5 + rank * 2, lscr, t$
  1074.                                     _DISPLAY
  1075.                                     z1 = TIMER ' Reset enter timer.
  1076.                                 END IF
  1077.                                 z2 = TIMER
  1078.                             END IF
  1079.  
  1080.                             IF PEEK(1047) MOD 16 <> 7 AND PEEK(1047) MOD 16 <> 8 THEN ' Alt key was released.
  1081.                                 kflag = 0 ' Alt key up
  1082.                                 z1 = TIMER
  1083.                             END IF
  1084.                         CASE -2 ' Finished. Initials will flash until confirmed by 2-second timer.
  1085.                             z1 = TIMER: z2 = TIMER
  1086.                             j = 0
  1087.                             DO
  1088.                                 IF ABS(z1 - TIMER) > .3 THEN j = -j - 1: z1 = TIMER
  1089.                                 IF j THEN
  1090.                                     COLOR DarkOrange: t$ = initials$
  1091.                                     PSL 5 + rank * 2, lscr, t$
  1092.                                     _DISPLAY
  1093.                                 ELSE
  1094.                                     COLOR _RGB(24, 24, 24): t$ = initials$
  1095.                                     PSL 5 + rank * 2, lscr, t$
  1096.                                     _DISPLAY
  1097.                                 END IF
  1098.  
  1099.                                 IF ABS(z2 - TIMER) > 2.5 AND j THEN
  1100.                                     kflag = -3
  1101.                                     EXIT DO
  1102.                                 END IF
  1103.  
  1104.                                 IF PEEK(1047) MOD 16 = 7 OR PEEK(1047) MOD 16 = 8 THEN
  1105.                                     BEEP
  1106.                                     kflag = -4
  1107.                                     EXIT DO
  1108.                                 END IF
  1109.                             LOOP
  1110.                         CASE -3
  1111.                             _DELAY 1
  1112.                             l$ = "8"
  1113.                             n$ = "n24": PLAY "L" + l$ + n$
  1114.                             n$ = "n28": PLAY "L" + l$ + n$
  1115.                             n$ = "n28": PLAY "L" + l$ + n$
  1116.                             l$ = "7"
  1117.                             n$ = "n31": PLAY "L" + l$ + n$
  1118.                             l$ = "9"
  1119.                             n$ = "n28": PLAY "L" + l$ + n$
  1120.                             l$ = "3"
  1121.                             n$ = "n31": PLAY "L" + l$ + n$
  1122.                             kflag = 1
  1123.                             _DELAY 1: EXIT DO
  1124.                         CASE -4
  1125.                             kflag = 0 ' Repeat enter initials
  1126.                             nxt = 0
  1127.                             i = 0
  1128.                             EXIT DO
  1129.                     END SELECT
  1130.                 LOOP
  1131.                 IF kflag > 0 THEN kflag = 0: EXIT DO ' Exit routine.
  1132.             LOOP
  1133.             DEF SEG
  1134.  
  1135.             hsname$ = initials$
  1136.  
  1137.             MID$(hsdata$(rank), 5, 3) = hsname$ + SPACE$(3 - LEN(hsname$))
  1138.             OPEN "ascii-invaders-high-score.dat" FOR RANDOM AS #1 LEN = 25
  1139.             FOR i = 1 TO 5
  1140.                 hs = hsdata$(i)
  1141.                 IF LEFT$(hs, 1) = "" THEN MID$(hs, 1, 2) = "0" + LTRIM$(STR$(i))
  1142.                 PUT #1, i, hs
  1143.             NEXT
  1144.             CLOSE #1
  1145.  
  1146.             _DELAY 1
  1147.             _DISPLAY ' Remove scoreboard.
  1148.             _DELAY 1
  1149.             _FREEIMAGE Overlay
  1150.             _FONT 16 'select inbuilt 8x16 default font
  1151.             _FREEFONT font
  1152.  
  1153.             _DEST 0 'Reset dest back to the normal screen 0.
  1154.  
  1155.             _AUTODISPLAY
  1156.             COLOR 6, 0
  1157.             msg$ = SPACE$(40)
  1158.             LOCATE 4, 41 - LEN(msg$) \ 2
  1159.             PRINT msg$;
  1160.             PALETTE
  1161.             _DELAY 1
  1162.  
  1163.             EXIT DO
  1164.         ELSE
  1165.             EXIT DO ' Not in the top 5 highest scores so exit sub.
  1166.         END IF
  1167.     LOOP
  1168.     EXIT SUB
  1169.  
  1170.     hardware_overlay:
  1171.     Overlay = _NEWIMAGE(_WIDTH * _FONTWIDTH, _HEIGHT * _FONTHEIGHT, 32)
  1172.  
  1173.     _DEST Overlay
  1174.     _DISPLAY ' Turn autodisplay off.
  1175.  
  1176.     font = _LOADFONT("lucon.ttf", 20, "monospace")
  1177.     IF font <= 0 THEN font = 16
  1178.     _FONT font
  1179.  
  1180.     bxy% = 3
  1181.     bxx% = 13
  1182.     COLOR DarkOrange, 0
  1183.     t$ = " " + CHR$(218) + STRING$(27, CHR$(196)) + CHR$(191) + " "
  1184.     PSL bxy%, bxx% - 1, t$
  1185.     FOR i = 1 TO 12
  1186.         t$ = " " + CHR$(179) + STRING$(27, CHR$(32)) + CHR$(179) + " "
  1187.         PSL bxy% + i, bxx% - 1, t$
  1188.     NEXT
  1189.     t$ = " " + CHR$(192) + STRING$(27, CHR$(196)) + CHR$(217) + " "
  1190.     PSL bxy% + i, bxx% - 1, t$
  1191.  
  1192.     bxy% = 4
  1193.     COLOR Black, DarkOrange
  1194.     t$ = "    NAME   SCORE    DATE   "
  1195.     PSL bxy% + 1, bxx% + 1, t$
  1196.  
  1197.     COLOR DarkOrange, 0
  1198.     FOR i = 1 TO 5
  1199.         t$ = hsdata$(i)
  1200.         PSL bxy% + 1 + i * 2, bxx% + 2, t$
  1201.     NEXT
  1202.  
  1203.     _DISPLAY
  1204.  
  1205.     RETURN
  1206.  
  1207.     hiscore:
  1208.     FOR i = 1 TO 5
  1209.         IF VAL(score$) > VAL(highscore$(i)) THEN rank = i: EXIT FOR
  1210.     NEXT
  1211.  
  1212.     hsdata$(6) = SPACE$(25)
  1213.     MID$(hsdata$(6), 10, 6) = score$
  1214.     MID$(hsdata$(6), 18, 8) = MID$(DATE$, 1, 6) + MID$(DATE$, 9, 2)
  1215.     highscore$(6) = score$
  1216.     FOR i = 1 TO 6
  1217.         FOR j = 1 TO 6
  1218.             IF i <> j THEN
  1219.                 IF VAL(highscore$(i)) > VAL(highscore$(j)) THEN
  1220.                     SWAP highscore$(i), highscore$(j)
  1221.                     SWAP hsdata$(i), hsdata$(j)
  1222.                 END IF
  1223.             END IF
  1224.         NEXT
  1225.     NEXT
  1226.     FOR i = 1 TO 5
  1227.         MID$(hsdata$(i), 1, 2) = "0" + LTRIM$(STR$(i))
  1228.     NEXT
  1229.  
  1230.     RETURN
  1231.  
  1232.  
  1233. SUB PSLC (y, x, t$)
  1234.     _PRINTSTRING ((x - 1) * 8, (y - 1) * 16), t$
  1235.  
  1236. SUB PSL (y, x, t$)
  1237.     _PRINTSTRING ((x - 1) * _FONTWIDTH, (y - 1) * _FONTHEIGHT), t$
  1238.     Overlay_Hardware = _COPYIMAGE(Overlay, 33)
  1239.     _PUTIMAGE (0, 0), Overlay_Hardware
  1240.  
  1241. SUB underline (y, x, uflag)
  1242.     STATIC ucnt
  1243.     ucnt = -ucnt - 1
  1244.     IF ucnt OR uflag THEN
  1245.         LINE ((x - 1) * _FONTWIDTH, y * _FONTHEIGHT)-((x - 1) * _FONTWIDTH + 12, y * _FONTHEIGHT), _RGB(24, 24, 24), BF
  1246.     ELSE
  1247.         LINE ((x - 1) * _FONTWIDTH, y * _FONTHEIGHT)-((x - 1) * _FONTWIDTH + 12, y * _FONTHEIGHT), DarkOrange, BF
  1248.     END IF
  1249.  
  1250.     Overlay_Hardware = _COPYIMAGE(Overlay, 33)
  1251.     _PUTIMAGE (0, 0), Overlay_Hardware
  1252.  
  1253. SUB thunder
  1254.     SCREEN 0, 0, 1, 1
  1255.     _DELAY 2
  1256.  
  1257.     IF _FILEEXISTS("Thunder6.ogg") AND _FILEEXISTS("Thunder6.ogg") AND _FILEEXISTS("Thunder6.ogg") THEN
  1258.         soundfile% = -1
  1259.     END IF
  1260.  
  1261.     IF soundfile% THEN
  1262.         t1& = _SNDOPEN("Thunder1.ogg", "SYNC")
  1263.         t2& = _SNDOPEN("Thunder2.ogg", "SYNC")
  1264.         t3& = _SNDOPEN("Thunder3.ogg", "SYNC")
  1265.         t4& = _SNDOPEN("Thunder4.ogg", "SYNC")
  1266.         t5& = _SNDOPEN("Thunder5.ogg", "SYNC")
  1267.         t6& = _SNDOPEN("Thunder6.ogg", "SYNC")
  1268.         t7& = _SNDOPEN("Thunder7.ogg", "SYNC")
  1269.         t8& = _SNDOPEN("Thunder8.ogg", "SYNC")
  1270.  
  1271.         _SNDPLAY t6&
  1272.         _DELAY .1
  1273.         _SNDPLAY t7&
  1274.         _DELAY .1
  1275.         _SNDPLAY t8&
  1276.     ELSE
  1277.         SOUND 1000, .3: SOUND 2400, .6:: SOUND 700, 2
  1278.     END IF
  1279.  
  1280.     FOR i = 1 TO 15
  1281.         _DELAY i / 150
  1282.         IF i / 2 = i \ 2 THEN
  1283.             SOUND 250, .1
  1284.             SCREEN 0, 0, 1, 1
  1285.         ELSE
  1286.             SCREEN 0, 0, 2, 2
  1287.             IF i < 13 THEN _DELAY i / 100: SCREEN 0, 0, 3, 3: COLOR 0, 7: CLS
  1288.         END IF
  1289.     NEXT
  1290.  
  1291.     PCOPY 2, 0
  1292.     SCREEN 0, 0, 0, 0
  1293.     _DELAY 1.5

  [ You are not allowed to view this attachment ]  

I still have to look into a couple more effects before I'm ready to open a "programs" thread. I've also been puttering around adding a spell check function to my WP, and I need to spend some time looking over what Steve posted for me on some new screen 0 hardware rendering effects.

Pete

Edit: Completed the switch to hardware rendering overlay for high score board. Also fixed a bug Jack found.

Edit: New improved system to enter high score initials. See post revisons on how to play, at top of post.

Edit: Added a title and a new explosion effect plus point scoring when your tank's missile blows up an enemy's missile.
« Last Edit: October 21, 2021, 11:28:01 pm by Pete »
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Competition
« Reply #103 on: October 16, 2021, 11:30:19 pm »
Oh yeah! way to stay with one key requirement for High Scores.

I read that request for an effect with screen 0, wondered if the command to print without back ground would work in screen 0 and basically take care of what you wanted???

Cobalt showed us the word, unfortunately it didn't stick in my memory, maybe it was two keywords.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Competition
« Reply #104 on: October 17, 2021, 12:10:35 am »
I read that request for an effect with screen 0, wondered if the command to print without back ground would work in screen 0 and basically take care of what you wanted???

You guys need to study up on SCREEN 0 and how it’s stored in memory...

Every point in SCREEN 0 is represented by 2 bytes -- character and color.


COLOR 15,4
LOCATE 1, 1: PRINT “A”

Now the above stores 2 bytes in memory for that position.  65 (for A) and 15 * 16 + 4 for the color. (15 foreground + 4 background...  Gives us a max value of 255 with blinking off so a single byte holds both values.)

So CHR$(65) + CHR$(244) represents that bright white “A” on a red background.

Now, how can you merge *ANYTHING* onto that spot, without overwriting those 2 bytes of info?

LOCATE 1, 1: PRINT “/”

Now if if we magically make the background of that slash have X alpha with _PALETTECOLOR, how the heck do we blend that color with the COLOR 4 background?

And how does that slash print over the A?  There’s no ASCII character representing a slashed-A symbol, so which of our 256 ASCII values do we store for that combination A + /?

SCREEN 0 is a very simple WYSIWYG interface.  You can LOOK at the screen and basically decode how it's represented in memory byte-by-byte.   It doesn’t allow for color blends, alpha levels, character merging or overlapping...

It just stores 2 bytes for each location:  ASCII character to display, color to display it.



Of course, this layout also has ADVANTAGES over other modes.

SCREEN 0 is the *only* screen that can tell the difference in a CHR$(32) and a CHR$(255) printed on.  Both are basically spaces, but SCREEN 0 can still tell the difference in them by the way it stores screen information.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!