Author Topic: why am i getting subscript out of range?!! #$%@#! The code looks good.  (Read 3484 times)

0 Members and 1 Guest are viewing this topic.

This topic contains a post which is marked as Best Answer. Press here if you would like to see it.

Offline Jaze

  • Newbie
  • Posts: 86
    • View Profile
Code: QB64: [Select]
  1.  
  2. WIDTH 80, 50
  3.  
  4. CONST shotDelay = 0.03
  5. CONST fireBeep = "L64O3CEGAA"
  6. CONST shipHitBeep = "L64O1EEEEEL16CC"
  7.  
  8. DIM SHARED battleScreen(1 TO 80, 1 TO 45, 1 TO 2)
  9.  
  10.  
  11. FOR fillY = 1 TO 45
  12.     FOR fillX = 1 TO 80
  13.         battleScreen(fillX, fillY, 1) = 32
  14.         battleScreen(fillX, fillY, 2) = 0
  15.     NEXT fillX
  16. NEXT fillY
  17.  
  18.  
  19. COLOR 0, 0
  20. LOCATE 1, 1
  21.  
  22.  
  23.  
  24. CALL Battle
  25.  
  26. FUNCTION locateToBegin () STATIC
  27.     starting = starting + 1
  28.     locateToBegin = starting
  29.  
  30.  
  31. SUB PrintBattleScreen ()
  32.     CLS: LOCATE 1, 1
  33.     FOR printY = 1 TO 45
  34.         FOR printX = 1 TO 80
  35.             IF printX <> 80 THEN
  36.                 COLOR battleScreen(printX, printY, 2), 0
  37.                 PRINT CHR$(battleScreen(printX, printY, 1));
  38.             ELSE
  39.                 COLOR battleScreen(printX, printY, 2), 0
  40.                 PRINT CHR$(battleScreen(printX, printY, 1))
  41.             END IF
  42.         NEXT printX
  43.     NEXT printY
  44.  
  45. SUB RelocateSarien
  46.     espializerLeft = 80
  47.     espializerRight = 1
  48.     espializerTop = 45
  49.     espializerBottomn = 1
  50.     'there's gotta be an easier way to find the square radius of the espializer
  51.     'all i can thing of is many different FOR-NEXT loops
  52.     'any way is better than no way. so be it
  53.     'find the top
  54.     FOR scanningX = 1 TO 80
  55.         FOR scanningY = 1 TO 45
  56.             IF battleScreen(scanningX, scanningY, 2) = 15 OR battleScreen(scanningX, scanningY, 2) = 9 THEN
  57.                 espializerTop = scanningY
  58.                 EXIT FOR
  59.             END IF
  60.         NEXT scanningY
  61.     NEXT scanningX
  62.     'find the bottom
  63.     FOR scanningX = 1 TO 80
  64.         FOR scanningY = 45 TO 1 STEP -1
  65.             IF battleScreen(scanningX, scanningY, 2) = 15 OR battleScreen(scanningX, scanningY, 2) = 9 THEN
  66.                 espializerBottom = scanningY
  67.                 EXIT FOR
  68.             END IF
  69.         NEXT scanningY
  70.     NEXT scanningX
  71.     'find left
  72.     FOR scanningX = 1 TO 80
  73.         FOR scanningY = 1 TO 45
  74.             IF battleScreen(scanningX, scanningY, 2) = 15 OR battleScreen(scanningX, scanningY, 2) = 9 THEN
  75.                 espializerLeft = scanningX
  76.                 EXIT FOR
  77.             END IF
  78.         NEXT scanningY
  79.     NEXT scanningX
  80.     'find right
  81.     FOR scanningX = 80 TO 1 STEP -1
  82.         FOR scanningY = 1 TO 45
  83.             IF battleScreen(scanningX, scanningY, 2) = 15 OR battleScreen(scanningX, scanningY, 2) = 9 THEN
  84.                 espializerRight = scanningX
  85.                 EXIT FOR
  86.             END IF
  87.         NEXT scanningY
  88.     NEXT scanningX
  89.     'ok, now that i have the square radius, make sure the new coordinates won't be inside a 15 square radius
  90.     ' but they also need to be in the line of fire
  91.     getNewSarienPlace:
  92.     rndX = INT(RND * 76) + 2
  93.     rndY = INT(RND * 42) + 2
  94.     rndOrient = INT(RND * 4) + 1
  95.     IF rndOrient = 1 THEN sarienOrientation$ = "N"
  96.     IF rndOrient = 2 THEN sarienOrientation$ = "S"
  97.     IF rndOrient = 3 THEN sarienOrientation$ = "W"
  98.     IF rndOrient = 4 THEN sarienOrientation$ = "E"
  99.     ' don't let the Sarien's be within 15 squares of the Espializer. --maybe leter i'll build in the possibility for the star generator to explode but that might be too sq1
  100.     IF espializerLeft - 15 < rndX AND rndX < espializerRight + 15 AND espializerTop - 15 < rndY AND rndY < espializerBottom + 15 THEN
  101.         'need new coordinates
  102.         GOTO getNewSarienPlace
  103.     END IF
  104.  
  105.  
  106.     CALL DrawSarien(rndX, rndY, "S") 'sarienOrientation$) '   may not need "CALL" but like my game, i'm old school like that
  107.  
  108. SUB Battle
  109.     'randNum% = INT(RND * (max% - min% + 1)) + min%
  110.     xPos = INT(RND * 71) + 5
  111.     yPos = INT(RND * 41) + 5
  112.     intFacing = INT(RND * 4) + 1:
  113.     IF intFacing = 1 THEN
  114.         facing$ = "N"
  115.     ELSEIF intFacing = 2 THEN
  116.         facing$ = "S"
  117.     ELSEIF intFacing = 3 THEN
  118.         facing$ = "W"
  119.     ELSEIF intFacing = 4 THEN
  120.         facing$ = "E"
  121.     END IF
  122.     '    CALL DrawEspializer(xPos, yPos, facing$)
  123.     '    xPos2 = INT(RND * 71) + 5
  124.     '    yPos2 = INT(RND * 41) + 5
  125.     '    intFacing2 = INT(RND * 4) + 1: IF intFacing2 = 1 THEN facing$ = "N": IF intFacing2 = 2 THEN facing$ = "S": IF intFacing2 = 3 THEN facing$ = "W": IF intFacing2 = 4 THEN facing$ = "E"
  126.     CALL RelocateSarien
  127.     CALL PrintBattleScreen
  128.     CALL DrawSarien(xPos2, yPos2, "N")
  129.  
  130.     DO
  131.         whichMove$ = INKEY$
  132.         limX = 0: limY = 0
  133.         '        CALL PrintBattleScreen
  134.         SELECT CASE whichMove$
  135.             CASE CHR$(0) + "H" ' up
  136.                 IF yPos > 5 THEN
  137.                     IF yPos < 16 THEN
  138.                         limY = 1
  139.                     ELSE
  140.                         limY = yPos - 15
  141.                     END IF
  142.                     moveFlag = 1
  143.                     FOR testingX = xPos - 3 TO xPos + 3
  144.                         IF battleScreen(testingX, limY, 1) <> 32 THEN moveFlag = 0
  145.                     NEXT testingX
  146.                     IF moveFlag = 1 THEN '      needs xPos + / - 3
  147.                         CALL EraseEspializer(xPos, yPos, facing$)
  148.                         yPos = yPos - 1: facing$ = "N"
  149.                         CALL DrawEspializer(xPos, yPos, facing$)
  150.                         CALL PrintBattleScreen
  151.                     END IF
  152.                 END IF
  153.             CASE CHR$(0) + "K" ' left
  154.                 IF xPos > 5 THEN
  155.                     IF xPos < 16 THEN
  156.                         limX = 1
  157.                     ELSE
  158.                         limX = xPos - 15
  159.                     END IF
  160.                     moveFlag = 1
  161.                     FOR testingY = yPos - 3 TO yPos + 3
  162.                         IF battleScreen(limX, testingY, 1) <> 32 THEN moveFlag = 0
  163.                     NEXT testingY
  164.                     IF moveFlag = 1 THEN
  165.                         CALL EraseEspializer(xPos, yPos, facing$)
  166.                         xPos = xPos - 1: facing$ = "W"
  167.                         CALL DrawEspializer(xPos, yPos, facing$)
  168.                         CALL PrintBattleScreen
  169.                     END IF
  170.                 END IF
  171.             CASE CHR$(0) + "P" ' down
  172.                 IF yPos < 40 THEN
  173.                     IF yPos > 30 THEN
  174.                         limY = 45
  175.                     ELSE
  176.                         limY = yPos + 15
  177.                     END IF
  178.                     moveFlag = 1
  179.                     FOR testingX = xPos - 3 TO xPos + 3
  180.                         IF battleScreen(testingX, limY, 1) <> 32 THEN moveFlag = 0
  181.                     NEXT testingX
  182.                     IF moveFlag = 1 THEN
  183.                         CALL EraseEspializer(xPos, yPos, facing$)
  184.                         yPos = yPos + 1: facing$ = "S"
  185.                         CALL DrawEspializer(xPos, yPos, facing$)
  186.                         CALL PrintBattleScreen
  187.                     END IF
  188.                 END IF
  189.             CASE CHR$(0) + "M" ' right
  190.                 IF xPos < 75 THEN
  191.                     IF xPos > 65 THEN
  192.                         limX = 80
  193.                     ELSE
  194.                         limX = xPos + 15
  195.                     END IF
  196.                     moveFlag = 1
  197.                     FOR testingY = yPos - 3 TO yPos + 3
  198.                         IF battleScreen(limX, testingY, 1) <> 32 THEN moveFlag = 0
  199.                     NEXT testingY
  200.                     IF battleScreen(limX, yPos, 1) = 32 THEN
  201.                         CALL EraseEspializer(xPos, yPos, facing$)
  202.                         xPos = xPos + 1: facing$ = "E"
  203.                         CALL DrawEspializer(xPos, yPos, facing$)
  204.                         CALL PrintBattleScreen
  205.                     END IF
  206.                 END IF
  207.             CASE CHR$(27)
  208.                 END
  209.         END SELECT
  210.     LOOP UNTIL whichMove$ = CHR$(27)
  211.  
  212. SUB DrawSarien (centerX, centerY, orientation$)
  213.  
  214.     COLOR 10, 0
  215.     SELECT CASE orientation$
  216.         CASE "N"
  217.             IF locateToBegin = 1 THEN
  218.                 LOCATE centerY + 0, centerX - 1: PRINT CHR$(219)
  219.                 LOCATE centerY + 0, centerX + 1: PRINT CHR$(219)
  220.                 LOCATE centerY - 1, centerX + 0: PRINT CHR$(219)
  221.             END IF
  222.             battleScreen(centerX - 1, centerY + 0, 1) = 219: battleScreen(centerX - 1, centerY + 0, 2) = 10
  223.             battleScreen(centerX + 1, centerY + 0, 1) = 219: battleScreen(centerX + 1, centerY + 0, 2) = 10
  224.             battleScreen(centerX + 0, centerY - 1, 1) = 219: battleScreen(centerX + 0, centerY - 1, 2) = 10
  225.         CASE "S"
  226.             IF locateToBegin = 1 THEN
  227.                 LOCATE centerY + 0, centerX - 1: PRINT CHR$(219)
  228.                 LOCATE centerY + 0, centerX + 1: PRINT CHR$(219)
  229.                 LOCATE centerY + 1, centerX + 0: PRINT CHR$(219)
  230.             END IF
  231.             battleScreen(centerX + 0, centerY + 1, 1) = 219: battleScreen(centerX + 0, centerY + 1, 2) = 10
  232.             battleScreen(centerX - 1, centerY + 0, 1) = 219: battleScreen(centerX - 1, centerY + 0, 2) = 10
  233.             battleScreen(centerX + 1, centerY + 0, 1) = 219: battleScreen(centerX + 1, centerY + 0, 2) = 10
  234.         CASE "W"
  235.             IF locateToBegin = 1 THEN
  236.                 LOCATE centerY + 0, centerX - 1: PRINT CHR$(219)
  237.                 LOCATE centerY - 1, centerX + 0: PRINT CHR$(219)
  238.                 LOCATE centerY + 1, centerX + 0: PRINT CHR$(219)
  239.             END IF
  240.             battleScreen(centerX - 1, centerY + 0, 1) = 219: battleScreen(centerX - 1, centerY + 0, 2) = 10
  241.             battleScreen(centerX + 0, centerY - 1, 1) = 219: battleScreen(centerX + 0, centerY - 1, 2) = 10
  242.             battleScreen(centerX + 0, centerY + 1, 1) = 219: battleScreen(centerX + 0, centerY + 1, 2) = 10
  243.         CASE "E"
  244.             IF locateToBegin = 1 THEN
  245.                 LOCATE centerY + 0, centerX + 1: PRINT CHR$(219)
  246.                 LOCATE centerY - 1, centerX - 1: PRINT CHR$(219)
  247.                 LOCATE centerY + 1, centerX - 1: PRINT CHR$(219)
  248.             END IF
  249.             battleScreen(centerX + 1, centerY + 0, 1) = 219: battleScreen(centerX + 1, centerY + 0, 2) = 10
  250.             battleScreen(centerX + 0, centerY - 1, 1) = 219: battleScreen(centerX + 0, centerY - 1, 2) = 10
  251.             battleScreen(centerX + 0, centerY + 1, 1) = 219: battleScreen(centerX + 0, centerY + 1, 2) = 10
  252.     END SELECT
  253.  
  254. SUB EraseSerian (centerx, centery, orientation$)
  255.     SELECT CASE orientation$
  256.         CASE "N"
  257.             battleScreen(centerx - 1, centery + 0, 1) = 32: battleScreen(centerx - 1, centery + 0, 2) = 0
  258.             battleScreen(centerx + 1, centery + 0, 1) = 32: battleScreen(centerx + 1, centery + 0, 2) = 0
  259.             battleScreen(centerx + 0, centery - 1, 1) = 32: battleScreen(centerx + 0, centery - 1, 2) = 0
  260.         CASE "S"
  261.             battleScreen(centerx - 1, centery + 0, 1) = 32: battleScreen(centerx - 1, centery + 0, 2) = 0
  262.             battleScreen(centerx + 1, centery + 0, 1) = 32: battleScreen(centerx + 1, centery + 0, 2) = 0
  263.             battleScreen(centerx + 0, centery + 1, 1) = 32: battleScreen(centerx + 0, centery + 1, 2) = 0
  264.         CASE "W"
  265.             battleScreen(centerx - 1, centery + 0, 1) = 32: battleScreen(centerx - 1, centery + 0, 2) = 0
  266.             battleScreen(centerx + 1, centery - 1, 1) = 32: battleScreen(centerx + 1, centery - 1, 2) = 0
  267.             battleScreen(centerx + 1, centery + 1, 1) = 32: battleScreen(centerx + 1, centery + 1, 2) = 0
  268.         CASE "E"
  269.             battleScreen(centerx + 1, centery + 0, 1) = 32: battleScreen(centerx + 1, centery + 0, 2) = 0
  270.             battleScreen(centerx - 1, centery - 1, 1) = 32: battleScreen(centerx - 1, centery - 1, 2) = 0
  271.             battleScreen(centerx - 1, centery + 1, 1) = 32: battleScreen(centerx - 1, centery + 1, 2) = 0
  272.     END SELECT
  273.  
  274.  
  275. SUB DrawEspializer (centerX, centerY, orientation$)
  276.     SELECT CASE orientation$
  277.         CASE "E"
  278.             battleScreen(centerX - 4, centerY - 3, 1) = 219: battleScreen(centerX - 4, centerY - 3, 2) = 9
  279.             battleScreen(centerX - 3, centerY - 3, 1) = 219: battleScreen(centerX - 3, centerY - 3, 2) = 9
  280.             battleScreen(centerX - 2, centerY - 3, 1) = 219: battleScreen(centerX - 2, centerY - 3, 2) = 9
  281.             battleScreen(centerX - 1, centerY - 3, 1) = 219: battleScreen(centerX - 1, centerY - 3, 2) = 9
  282.             battleScreen(centerX - 0, centerY - 3, 1) = 219: battleScreen(centerX - 0, centerY - 3, 2) = 9
  283.             battleScreen(centerX - 4, centerY + 3, 1) = 219: battleScreen(centerX - 4, centerY + 3, 2) = 9
  284.             battleScreen(centerX - 3, centerY + 3, 1) = 219: battleScreen(centerX - 3, centerY + 3, 2) = 9
  285.             battleScreen(centerX - 2, centerY + 3, 1) = 219: battleScreen(centerX - 2, centerY + 3, 2) = 9
  286.             battleScreen(centerX - 1, centerY + 3, 1) = 219: battleScreen(centerX - 1, centerY + 3, 2) = 9
  287.             battleScreen(centerX - 0, centerY + 3, 1) = 219: battleScreen(centerX - 0, centerY + 3, 2) = 9
  288.             battleScreen(centerX + 0, centerY - 2, 1) = 219: battleScreen(centerX + 0, centerY - 2, 2) = 15
  289.             battleScreen(centerX + 1, centerY - 2, 1) = 219: battleScreen(centerX + 1, centerY - 2, 2) = 15
  290.             battleScreen(centerX + 2, centerY - 2, 1) = 219: battleScreen(centerX + 2, centerY - 2, 2) = 15
  291.             battleScreen(centerX + 1, centerY - 1, 1) = 219: battleScreen(centerX + 1, centerY - 1, 2) = 15
  292.             battleScreen(centerX + 2, centerY - 1, 1) = 219: battleScreen(centerX + 2, centerY - 1, 2) = 15
  293.             battleScreen(centerX + 3, centerY - 1, 1) = 219: battleScreen(centerX + 3, centerY - 1, 2) = 15
  294.             battleScreen(centerX + 1, centerY + 0, 1) = 219: battleScreen(centerX + 1, centerY + 0, 2) = 15
  295.             battleScreen(centerX + 2, centerY + 0, 1) = 219: battleScreen(centerX + 2, centerY + 0, 2) = 15
  296.             battleScreen(centerX + 3, centerY + 0, 1) = 219: battleScreen(centerX + 3, centerY + 0, 2) = 15
  297.             battleScreen(centerX + 4, centerY + 0, 1) = 219: battleScreen(centerX + 4, centerY + 0, 2) = 15
  298.             battleScreen(centerX + 1, centerY + 1, 1) = 219: battleScreen(centerX + 1, centerY + 1, 2) = 15
  299.             battleScreen(centerX + 2, centerY + 1, 1) = 219: battleScreen(centerX + 2, centerY + 1, 2) = 15
  300.             battleScreen(centerX + 3, centerY + 1, 1) = 219: battleScreen(centerX + 3, centerY + 1, 2) = 15
  301.             battleScreen(centerX + 0, centerY + 2, 1) = 219: battleScreen(centerX + 0, centerY + 2, 2) = 15
  302.             battleScreen(centerX + 1, centerY + 2, 1) = 219: battleScreen(centerX + 1, centerY + 2, 2) = 15
  303.             battleScreen(centerX + 2, centerY + 2, 1) = 219: battleScreen(centerX + 2, centerY + 2, 2) = 15
  304.         CASE "W"
  305.             battleScreen(centerX + 0, centerY - 3, 1) = 219: battleScreen(centerX + 0, centerY - 3, 2) = 9
  306.             battleScreen(centerX + 1, centerY - 3, 1) = 219: battleScreen(centerX + 1, centerY - 3, 2) = 9
  307.             battleScreen(centerX + 2, centerY - 3, 1) = 219: battleScreen(centerX + 2, centerY - 3, 2) = 9
  308.             battleScreen(centerX + 3, centerY - 3, 1) = 219: battleScreen(centerX + 3, centerY - 3, 2) = 9
  309.             battleScreen(centerX + 4, centerY - 3, 1) = 219: battleScreen(centerX + 4, centerY - 3, 2) = 9
  310.             battleScreen(centerX + 0, centerY + 3, 1) = 219: battleScreen(centerX + 0, centerY + 3, 2) = 9
  311.             battleScreen(centerX + 1, centerY + 3, 1) = 219: battleScreen(centerX + 1, centerY + 3, 2) = 9
  312.             battleScreen(centerX + 2, centerY + 3, 1) = 219: battleScreen(centerX + 2, centerY + 3, 2) = 9
  313.             battleScreen(centerX + 3, centerY + 3, 1) = 219: battleScreen(centerX + 3, centerY + 3, 2) = 9
  314.             battleScreen(centerX + 4, centerY + 3, 1) = 219: battleScreen(centerX + 4, centerY + 3, 2) = 9
  315.             battleScreen(centerX - 2, centerY - 2, 1) = 219: battleScreen(centerX - 2, centerY - 2, 2) = 15
  316.             battleScreen(centerX - 1, centerY - 2, 1) = 219: battleScreen(centerX - 1, centerY - 2, 2) = 15
  317.             battleScreen(centerX - 0, centerY - 2, 1) = 219: battleScreen(centerX - 0, centerY - 2, 2) = 15
  318.             battleScreen(centerX - 2, centerY + 2, 1) = 219: battleScreen(centerX - 2, centerY + 2, 2) = 15
  319.             battleScreen(centerX - 1, centerY + 2, 1) = 219: battleScreen(centerX - 1, centerY + 2, 2) = 15
  320.             battleScreen(centerX - 0, centerY + 2, 1) = 219: battleScreen(centerX - 0, centerY + 2, 2) = 15
  321.             battleScreen(centerX - 3, centerY - 1, 1) = 219: battleScreen(centerX - 3, centerY - 1, 2) = 15
  322.             battleScreen(centerX - 2, centerY - 1, 1) = 219: battleScreen(centerX - 2, centerY - 1, 2) = 15
  323.             battleScreen(centerX - 1, centerY - 1, 1) = 219: battleScreen(centerX - 1, centerY - 1, 2) = 15
  324.             battleScreen(centerX - 3, centerY + 1, 1) = 219: battleScreen(centerX - 3, centerY + 1, 2) = 15
  325.             battleScreen(centerX - 2, centerY + 1, 1) = 219: battleScreen(centerX - 2, centerY + 1, 2) = 15
  326.             battleScreen(centerX - 1, centerY + 1, 1) = 219: battleScreen(centerX - 1, centerY + 1, 2) = 15
  327.             battleScreen(centerX - 4, centerY + 0, 1) = 219: battleScreen(centerX - 4, centerY + 0, 2) = 15
  328.             battleScreen(centerX - 3, centerY + 0, 1) = 219: battleScreen(centerX - 3, centerY + 0, 2) = 15
  329.             battleScreen(centerX - 2, centerY + 0, 1) = 219: battleScreen(centerX - 2, centerY + 0, 2) = 15
  330.             battleScreen(centerX - 1, centerY + 0, 1) = 219: battleScreen(centerX - 1, centerY + 0, 2) = 15
  331.         CASE "S"
  332.             battleScreen(centerX - 3, centerY - 4, 1) = 219: battleScreen(centerX - 3, centerY - 4, 2) = 9
  333.             battleScreen(centerX - 3, centerY - 3, 1) = 219: battleScreen(centerX - 3, centerY - 3, 2) = 9
  334.             battleScreen(centerX - 3, centerY - 2, 1) = 219: battleScreen(centerX - 3, centerY - 2, 2) = 9
  335.             battleScreen(centerX - 3, centerY - 1, 1) = 219: battleScreen(centerX - 3, centerY - 1, 2) = 9
  336.             battleScreen(centerX - 3, centerY - 0, 1) = 219: battleScreen(centerX - 3, centerY - 0, 2) = 9
  337.             battleScreen(centerX + 3, centerY - 4, 1) = 219: battleScreen(centerX + 3, centerY - 4, 2) = 9
  338.             battleScreen(centerX + 3, centerY - 3, 1) = 219: battleScreen(centerX + 3, centerY - 3, 2) = 9
  339.             battleScreen(centerX + 3, centerY - 2, 1) = 219: battleScreen(centerX + 3, centerY - 2, 2) = 9
  340.             battleScreen(centerX + 3, centerY - 1, 1) = 219: battleScreen(centerX + 3, centerY - 1, 2) = 9
  341.             battleScreen(centerX + 3, centerY - 0, 1) = 219: battleScreen(centerX + 3, centerY - 0, 2) = 9
  342.             battleScreen(centerX - 2, centerY + 0, 1) = 219: battleScreen(centerX - 2, centerY + 0, 2) = 15
  343.             battleScreen(centerX - 2, centerY + 1, 1) = 219: battleScreen(centerX - 2, centerY + 1, 2) = 15
  344.             battleScreen(centerX - 2, centerY + 2, 1) = 219: battleScreen(centerX - 2, centerY + 2, 2) = 15
  345.             battleScreen(centerX + 2, centerY + 0, 1) = 219: battleScreen(centerX + 2, centerY + 0, 2) = 15
  346.             battleScreen(centerX + 2, centerY + 1, 1) = 219: battleScreen(centerX + 2, centerY + 1, 2) = 15
  347.             battleScreen(centerX + 2, centerY + 2, 1) = 219: battleScreen(centerX + 2, centerY + 2, 2) = 15
  348.             battleScreen(centerX - 1, centerY + 1, 1) = 219: battleScreen(centerX - 1, centerY + 1, 2) = 15
  349.             battleScreen(centerX - 1, centerY + 2, 1) = 219: battleScreen(centerX - 1, centerY + 2, 2) = 15
  350.             battleScreen(centerX - 1, centerY + 3, 1) = 219: battleScreen(centerX - 1, centerY + 3, 2) = 15
  351.             battleScreen(centerX + 1, centerY + 1, 1) = 219: battleScreen(centerX + 1, centerY + 1, 2) = 15
  352.             battleScreen(centerX + 1, centerY + 2, 1) = 219: battleScreen(centerX + 1, centerY + 2, 2) = 15
  353.             battleScreen(centerX + 1, centerY + 3, 1) = 219: battleScreen(centerX + 1, centerY + 3, 2) = 15
  354.             battleScreen(centerX + 0, centerY + 1, 1) = 219: battleScreen(centerX + 0, centerY + 1, 2) = 15
  355.             battleScreen(centerX + 0, centerY + 2, 1) = 219: battleScreen(centerX + 0, centerY + 2, 2) = 15
  356.             battleScreen(centerX + 0, centerY + 3, 1) = 219: battleScreen(centerX + 0, centerY + 3, 2) = 15
  357.             battleScreen(centerX + 0, centerY + 4, 1) = 219: battleScreen(centerX + 0, centerY + 4, 2) = 15
  358.         CASE "N"
  359.             battleScreen(centerX - 3, centerY + 0, 1) = 219: battleScreen(centerX - 3, centerY + 0, 2) = 9
  360.             battleScreen(centerX - 3, centerY + 1, 1) = 219: battleScreen(centerX - 3, centerY + 1, 2) = 9
  361.             battleScreen(centerX - 3, centerY + 2, 1) = 219: battleScreen(centerX - 3, centerY + 2, 2) = 9
  362.             battleScreen(centerX - 3, centerY + 3, 1) = 219: battleScreen(centerX - 3, centerY + 3, 2) = 9
  363.             battleScreen(centerX - 3, centerY + 4, 1) = 219: battleScreen(centerX - 3, centerY + 4, 2) = 9
  364.             battleScreen(centerX + 3, centerY + 0, 1) = 219: battleScreen(centerX + 3, centerY + 0, 2) = 9
  365.             battleScreen(centerX + 3, centerY + 1, 1) = 219: battleScreen(centerX + 3, centerY + 1, 2) = 9
  366.             battleScreen(centerX + 3, centerY + 2, 1) = 219: battleScreen(centerX + 3, centerY + 2, 2) = 9
  367.             battleScreen(centerX + 3, centerY + 3, 1) = 219: battleScreen(centerX + 3, centerY + 3, 2) = 9
  368.             battleScreen(centerX + 3, centerY + 4, 1) = 219: battleScreen(centerX + 3, centerY + 4, 2) = 9
  369.             battleScreen(centerX - 2, centerY - 2, 1) = 219: battleScreen(centerX - 2, centerY - 2, 2) = 15
  370.             battleScreen(centerX - 2, centerY - 1, 1) = 219: battleScreen(centerX - 2, centerY - 1, 2) = 15
  371.             battleScreen(centerX - 2, centerY - 0, 1) = 219: battleScreen(centerX - 2, centerY - 0, 2) = 15
  372.             battleScreen(centerX + 2, centerY - 2, 1) = 219: battleScreen(centerX + 2, centerY - 2, 2) = 15
  373.             battleScreen(centerX + 2, centerY - 1, 1) = 219: battleScreen(centerX + 2, centerY - 1, 2) = 15
  374.             battleScreen(centerX + 2, centerY - 0, 1) = 219: battleScreen(centerX + 2, centerY - 0, 2) = 15
  375.             battleScreen(centerX - 1, centerY - 3, 1) = 219: battleScreen(centerX - 1, centerY - 3, 2) = 15
  376.             battleScreen(centerX - 1, centerY - 2, 1) = 219: battleScreen(centerX - 1, centerY - 2, 2) = 15
  377.             battleScreen(centerX - 1, centerY - 1, 1) = 219: battleScreen(centerX - 1, centerY - 1, 2) = 15
  378.             battleScreen(centerX + 1, centerY - 3, 1) = 219: battleScreen(centerX + 1, centerY - 3, 2) = 15
  379.             battleScreen(centerX + 1, centerY - 2, 1) = 219: battleScreen(centerX + 1, centerY - 2, 2) = 15
  380.             battleScreen(centerX + 1, centerY - 1, 1) = 219: battleScreen(centerX + 1, centerY - 1, 2) = 15
  381.             battleScreen(centerX + 0, centerY - 4, 1) = 219: battleScreen(centerX + 0, centerY - 4, 2) = 15
  382.             battleScreen(centerX + 0, centerY - 3, 1) = 219: battleScreen(centerX + 0, centerY - 3, 2) = 15
  383.             battleScreen(centerX + 0, centerY - 2, 1) = 219: battleScreen(centerX + 0, centerY - 2, 2) = 15
  384.             battleScreen(centerX + 0, centerY - 1, 1) = 219: battleScreen(centerX + 0, centerY - 1, 2) = 15
  385.     END SELECT
  386.  
  387. SUB EraseEspializer (centerX, centerY, orientation$)
  388.     SELECT CASE orientation$
  389.         CASE "E"
  390.             battleScreen(centerX - 4, centerY - 3, 1) = 32: battleScreen(centerX - 4, centerY - 3, 2) = 0
  391.             battleScreen(centerX - 3, centerY - 3, 1) = 32: battleScreen(centerX - 3, centerY - 3, 2) = 0
  392.             battleScreen(centerX - 2, centerY - 3, 1) = 32: battleScreen(centerX - 2, centerY - 3, 2) = 0
  393.             battleScreen(centerX - 1, centerY - 3, 1) = 32: battleScreen(centerX - 1, centerY - 3, 2) = 0
  394.             battleScreen(centerX - 0, centerY - 3, 1) = 32: battleScreen(centerX - 0, centerY - 3, 2) = 0
  395.             battleScreen(centerX - 4, centerY + 3, 1) = 32: battleScreen(centerX - 4, centerY + 3, 2) = 0
  396.             battleScreen(centerX - 3, centerY + 3, 1) = 32: battleScreen(centerX - 3, centerY + 3, 2) = 0
  397.             battleScreen(centerX - 2, centerY + 3, 1) = 32: battleScreen(centerX - 2, centerY + 3, 2) = 0
  398.             battleScreen(centerX - 1, centerY + 3, 1) = 32: battleScreen(centerX - 1, centerY + 3, 2) = 0
  399.             battleScreen(centerX - 0, centerY + 3, 1) = 32: battleScreen(centerX - 0, centerY + 3, 2) = 0
  400.             battleScreen(centerX + 0, centerY - 2, 1) = 32: battleScreen(centerX + 0, centerY - 2, 2) = 0
  401.             battleScreen(centerX + 1, centerY - 2, 1) = 32: battleScreen(centerX + 1, centerY - 2, 2) = 0
  402.             battleScreen(centerX + 2, centerY - 2, 1) = 32: battleScreen(centerX + 2, centerY - 2, 2) = 0
  403.             battleScreen(centerX + 1, centerY - 1, 1) = 32: battleScreen(centerX + 1, centerY - 1, 2) = 0
  404.             battleScreen(centerX + 2, centerY - 1, 1) = 32: battleScreen(centerX + 2, centerY - 1, 2) = 0
  405.             battleScreen(centerX + 3, centerY - 1, 1) = 32: battleScreen(centerX + 3, centerY - 1, 2) = 0
  406.             battleScreen(centerX + 1, centerY + 0, 1) = 32: battleScreen(centerX + 1, centerY + 0, 2) = 0
  407.             battleScreen(centerX + 2, centerY + 0, 1) = 32: battleScreen(centerX + 2, centerY + 0, 2) = 0
  408.             battleScreen(centerX + 3, centerY + 0, 1) = 32: battleScreen(centerX + 3, centerY + 0, 2) = 0
  409.             battleScreen(centerX + 4, centerY + 0, 1) = 32: battleScreen(centerX + 4, centerY + 0, 2) = 0
  410.             battleScreen(centerX + 1, centerY + 1, 1) = 32: battleScreen(centerX + 1, centerY + 1, 2) = 0
  411.             battleScreen(centerX + 2, centerY + 1, 1) = 32: battleScreen(centerX + 2, centerY + 1, 2) = 0
  412.             battleScreen(centerX + 3, centerY + 1, 1) = 32: battleScreen(centerX + 3, centerY + 1, 2) = 0
  413.             battleScreen(centerX + 0, centerY + 2, 1) = 32: battleScreen(centerX + 0, centerY + 2, 2) = 0
  414.             battleScreen(centerX + 1, centerY + 2, 1) = 32: battleScreen(centerX + 1, centerY + 2, 2) = 0
  415.             battleScreen(centerX + 2, centerY + 2, 1) = 32: battleScreen(centerX + 2, centerY + 2, 2) = 0
  416.         CASE "W"
  417.             battleScreen(centerX + 0, centerY - 3, 1) = 32: battleScreen(centerX + 0, centerY - 3, 2) = 0
  418.             battleScreen(centerX + 1, centerY - 3, 1) = 32: battleScreen(centerX + 1, centerY - 3, 2) = 0
  419.             battleScreen(centerX + 2, centerY - 3, 1) = 32: battleScreen(centerX + 2, centerY - 3, 2) = 0
  420.             battleScreen(centerX + 3, centerY - 3, 1) = 32: battleScreen(centerX + 3, centerY - 3, 2) = 0
  421.             battleScreen(centerX + 4, centerY - 3, 1) = 32: battleScreen(centerX + 4, centerY - 3, 2) = 0
  422.             battleScreen(centerX + 0, centerY + 3, 1) = 32: battleScreen(centerX + 0, centerY + 3, 2) = 0
  423.             battleScreen(centerX + 1, centerY + 3, 1) = 32: battleScreen(centerX + 1, centerY + 3, 2) = 0
  424.             battleScreen(centerX + 2, centerY + 3, 1) = 32: battleScreen(centerX + 2, centerY + 3, 2) = 0
  425.             battleScreen(centerX + 3, centerY + 3, 1) = 32: battleScreen(centerX + 3, centerY + 3, 2) = 0
  426.             battleScreen(centerX + 4, centerY + 3, 1) = 32: battleScreen(centerX + 4, centerY + 3, 2) = 0
  427.             battleScreen(centerX - 2, centerY - 2, 1) = 32: battleScreen(centerX - 2, centerY - 2, 2) = 0
  428.             battleScreen(centerX - 1, centerY - 2, 1) = 32: battleScreen(centerX - 1, centerY - 2, 2) = 0
  429.             battleScreen(centerX - 0, centerY - 2, 1) = 32: battleScreen(centerX - 0, centerY - 2, 2) = 0
  430.             battleScreen(centerX - 2, centerY + 2, 1) = 32: battleScreen(centerX - 2, centerY + 2, 2) = 0
  431.             battleScreen(centerX - 1, centerY + 2, 1) = 32: battleScreen(centerX - 1, centerY + 2, 2) = 0
  432.             battleScreen(centerX - 0, centerY + 2, 1) = 32: battleScreen(centerX - 0, centerY + 2, 2) = 0
  433.             battleScreen(centerX - 3, centerY - 1, 1) = 32: battleScreen(centerX - 3, centerY - 1, 2) = 0
  434.             battleScreen(centerX - 2, centerY - 1, 1) = 32: battleScreen(centerX - 2, centerY - 1, 2) = 0
  435.             battleScreen(centerX - 1, centerY - 1, 1) = 32: battleScreen(centerX - 1, centerY - 1, 2) = 0
  436.             battleScreen(centerX - 3, centerY + 1, 1) = 32: battleScreen(centerX - 3, centerY + 1, 2) = 0
  437.             battleScreen(centerX - 2, centerY + 1, 1) = 32: battleScreen(centerX - 2, centerY + 1, 2) = 0
  438.             battleScreen(centerX - 1, centerY + 1, 1) = 32: battleScreen(centerX - 1, centerY + 1, 2) = 0
  439.             battleScreen(centerX - 4, centerY + 0, 1) = 32: battleScreen(centerX - 4, centerY + 0, 2) = 0
  440.             battleScreen(centerX - 3, centerY + 0, 1) = 32: battleScreen(centerX - 3, centerY + 0, 2) = 0
  441.             battleScreen(centerX - 2, centerY + 0, 1) = 32: battleScreen(centerX - 2, centerY + 0, 2) = 0
  442.             battleScreen(centerX - 1, centerY + 0, 1) = 32: battleScreen(centerX - 1, centerY + 0, 2) = 0
  443.         CASE "S"
  444.             battleScreen(centerX - 3, centerY - 4, 1) = 32: battleScreen(centerX - 3, centerY - 4, 2) = 0
  445.             battleScreen(centerX - 3, centerY - 3, 1) = 32: battleScreen(centerX - 3, centerY - 3, 2) = 0
  446.             battleScreen(centerX - 3, centerY - 2, 1) = 32: battleScreen(centerX - 3, centerY - 2, 2) = 0
  447.             battleScreen(centerX - 3, centerY - 1, 1) = 32: battleScreen(centerX - 3, centerY - 1, 2) = 0
  448.             battleScreen(centerX - 3, centerY - 0, 1) = 32: battleScreen(centerX - 3, centerY - 0, 2) = 0
  449.             battleScreen(centerX + 3, centerY - 4, 1) = 32: battleScreen(centerX + 3, centerY - 4, 2) = 0
  450.             battleScreen(centerX + 3, centerY - 3, 1) = 32: battleScreen(centerX + 3, centerY - 3, 2) = 0
  451.             battleScreen(centerX + 3, centerY - 2, 1) = 32: battleScreen(centerX + 3, centerY - 2, 2) = 0
  452.             battleScreen(centerX + 3, centerY - 1, 1) = 32: battleScreen(centerX + 3, centerY - 1, 2) = 0
  453.             battleScreen(centerX + 3, centerY - 0, 1) = 32: battleScreen(centerX + 3, centerY - 0, 2) = 0
  454.             battleScreen(centerX - 2, centerY + 0, 1) = 32: battleScreen(centerX - 2, centerY + 0, 2) = 0
  455.             battleScreen(centerX - 2, centerY + 1, 1) = 32: battleScreen(centerX - 2, centerY + 1, 2) = 0
  456.             battleScreen(centerX - 2, centerY + 2, 1) = 32: battleScreen(centerX - 2, centerY + 2, 2) = 0
  457.             battleScreen(centerX + 2, centerY + 0, 1) = 32: battleScreen(centerX + 2, centerY + 0, 2) = 0
  458.             battleScreen(centerX + 2, centerY + 1, 1) = 32: battleScreen(centerX + 2, centerY + 1, 2) = 0
  459.             battleScreen(centerX + 2, centerY + 2, 1) = 32: battleScreen(centerX + 2, centerY + 2, 2) = 0
  460.             battleScreen(centerX - 1, centerY + 1, 1) = 32: battleScreen(centerX - 1, centerY + 1, 2) = 0
  461.             battleScreen(centerX - 1, centerY + 2, 1) = 32: battleScreen(centerX - 1, centerY + 2, 2) = 0
  462.             battleScreen(centerX - 1, centerY + 3, 1) = 32: battleScreen(centerX - 1, centerY + 3, 2) = 0
  463.             battleScreen(centerX + 1, centerY + 1, 1) = 32: battleScreen(centerX + 1, centerY + 1, 2) = 0
  464.             battleScreen(centerX + 1, centerY + 2, 1) = 32: battleScreen(centerX + 1, centerY + 2, 2) = 0
  465.             battleScreen(centerX + 1, centerY + 3, 1) = 32: battleScreen(centerX + 1, centerY + 3, 2) = 0
  466.             battleScreen(centerX + 0, centerY + 1, 1) = 32: battleScreen(centerX + 0, centerY + 1, 2) = 0
  467.             battleScreen(centerX + 0, centerY + 2, 1) = 32: battleScreen(centerX + 0, centerY + 2, 2) = 0
  468.             battleScreen(centerX + 0, centerY + 3, 1) = 32: battleScreen(centerX + 0, centerY + 3, 2) = 0
  469.             battleScreen(centerX + 0, centerY + 4, 1) = 32: battleScreen(centerX + 0, centerY + 4, 2) = 0
  470.         CASE "N"
  471.             battleScreen(centerX - 3, centerY + 0, 1) = 32: battleScreen(centerX - 3, centerY + 0, 2) = 0
  472.             battleScreen(centerX - 3, centerY + 1, 1) = 32: battleScreen(centerX - 3, centerY + 1, 2) = 0
  473.             battleScreen(centerX - 3, centerY + 2, 1) = 32: battleScreen(centerX - 3, centerY + 2, 2) = 0
  474.             battleScreen(centerX - 3, centerY + 3, 1) = 32: battleScreen(centerX - 3, centerY + 3, 2) = 0
  475.             battleScreen(centerX - 3, centerY + 4, 1) = 32: battleScreen(centerX - 3, centerY + 4, 2) = 0
  476.             battleScreen(centerX + 3, centerY + 0, 1) = 32: battleScreen(centerX + 3, centerY + 0, 2) = 0
  477.             battleScreen(centerX + 3, centerY + 1, 1) = 32: battleScreen(centerX + 3, centerY + 1, 2) = 0
  478.             battleScreen(centerX + 3, centerY + 2, 1) = 32: battleScreen(centerX + 3, centerY + 2, 2) = 0
  479.             battleScreen(centerX + 3, centerY + 3, 1) = 32: battleScreen(centerX + 3, centerY + 3, 2) = 0
  480.             battleScreen(centerX + 3, centerY + 4, 1) = 32: battleScreen(centerX + 3, centerY + 4, 2) = 0
  481.             battleScreen(centerX - 2, centerY - 2, 1) = 32: battleScreen(centerX - 2, centerY - 2, 2) = 0
  482.             battleScreen(centerX - 2, centerY - 1, 1) = 32: battleScreen(centerX - 2, centerY - 1, 2) = 0
  483.             battleScreen(centerX - 2, centerY - 0, 1) = 32: battleScreen(centerX - 2, centerY - 0, 2) = 0
  484.             battleScreen(centerX + 2, centerY - 2, 1) = 32: battleScreen(centerX + 2, centerY - 2, 2) = 0
  485.             battleScreen(centerX + 2, centerY - 1, 1) = 32: battleScreen(centerX + 2, centerY - 1, 2) = 0
  486.             battleScreen(centerX + 2, centerY - 0, 1) = 32: battleScreen(centerX + 2, centerY - 0, 2) = 0
  487.             battleScreen(centerX - 1, centerY - 3, 1) = 32: battleScreen(centerX - 1, centerY - 3, 2) = 0
  488.             battleScreen(centerX - 1, centerY - 2, 1) = 32: battleScreen(centerX - 1, centerY - 2, 2) = 0
  489.             battleScreen(centerX - 1, centerY - 1, 1) = 32: battleScreen(centerX - 1, centerY - 1, 2) = 0
  490.             battleScreen(centerX + 1, centerY - 3, 1) = 32: battleScreen(centerX + 1, centerY - 3, 2) = 0
  491.             battleScreen(centerX + 1, centerY - 2, 1) = 32: battleScreen(centerX + 1, centerY - 2, 2) = 0
  492.             battleScreen(centerX + 1, centerY - 1, 1) = 32: battleScreen(centerX + 1, centerY - 1, 2) = 0
  493.             battleScreen(centerX + 0, centerY - 4, 1) = 32: battleScreen(centerX + 0, centerY - 4, 2) = 0
  494.             battleScreen(centerX + 0, centerY - 3, 1) = 32: battleScreen(centerX + 0, centerY - 3, 2) = 0
  495.             battleScreen(centerX + 0, centerY - 2, 1) = 32: battleScreen(centerX + 0, centerY - 2, 2) = 0
  496.             battleScreen(centerX + 0, centerY - 1, 1) = 32: battleScreen(centerX + 0, centerY - 1, 2) = 0
  497.     END SELECT
  498.     CALL PrintBattleScreen

line 230 is the first line of the DrawSarien SUB that uses "battleScreen" I hate asking help to debug but the code looks fine to me.  I already eliminated For-Next loops i used in drawing the espializer. It worked but the Espializer woildn't shop up until an arrowkey was pressed. i had the same trouble with the Sarien ship so I stuffed it on the screen with a locate command. I initially used locate for all the graphics but I had just as much trouble with the code then as I am now. I made a version where the sarien is in one place and the espializer approaches it but you can't move it with the arrowkeys. anyway, please let me know if you can find an error i'm missing

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: why am i getting subscript out of range?!! #$%@#! The code looks good.
« Reply #1 on: December 08, 2020, 10:07:29 pm »
Because CenterX is 0 when you run the program, and your array is only dimmed for a low value of 1. 

Code: [Select]
WIDTH 80, 50
_FULLSCREEN

CONST shotDelay = 0.03
CONST fireBeep = "L64O3CEGAA"
CONST shipHitBeep = "L64O1EEEEEL16CC"

DIM SHARED battleScreen(1 TO 80, 1 TO 45, 1 TO 2)


FOR fillY = 1 TO 45
    FOR fillX = 1 TO 80
        battleScreen(fillX, fillY, 1) = 32
        battleScreen(fillX, fillY, 2) = 0
    NEXT fillX
NEXT fillY


RANDOMIZE TIMER
COLOR 0, 0
CLS
LOCATE 1, 1



CALL Battle

FUNCTION locateToBegin () STATIC
    starting = starting + 1
    locateToBegin = starting
END FUNCTION


SUB PrintBattleScreen ()
    CLS: LOCATE 1, 1
    FOR printY = 1 TO 45
        FOR printX = 1 TO 80
            IF printX <> 80 THEN
                COLOR battleScreen(printX, printY, 2), 0
                PRINT CHR$(battleScreen(printX, printY, 1));
            ELSE
                COLOR battleScreen(printX, printY, 2), 0
                PRINT CHR$(battleScreen(printX, printY, 1))
            END IF
        NEXT printX
    NEXT printY
END SUB

SUB RelocateSarien
    espializerLeft = 80
    espializerRight = 1
    espializerTop = 45
    espializerBottomn = 1
    'there's gotta be an easier way to find the square radius of the espializer
    'all i can thing of is many different FOR-NEXT loops
    'any way is better than no way. so be it
    'find the top
    FOR scanningX = 1 TO 80
        FOR scanningY = 1 TO 45
            IF battleScreen(scanningX, scanningY, 2) = 15 OR battleScreen(scanningX, scanningY, 2) = 9 THEN
                espializerTop = scanningY
                EXIT FOR
            END IF
        NEXT scanningY
    NEXT scanningX
    'find the bottom
    FOR scanningX = 1 TO 80
        FOR scanningY = 45 TO 1 STEP -1
            IF battleScreen(scanningX, scanningY, 2) = 15 OR battleScreen(scanningX, scanningY, 2) = 9 THEN
                espializerBottom = scanningY
                EXIT FOR
            END IF
        NEXT scanningY
    NEXT scanningX
    'find left
    FOR scanningX = 1 TO 80
        FOR scanningY = 1 TO 45
            IF battleScreen(scanningX, scanningY, 2) = 15 OR battleScreen(scanningX, scanningY, 2) = 9 THEN
                espializerLeft = scanningX
                EXIT FOR
            END IF
        NEXT scanningY
    NEXT scanningX
    'find right
    FOR scanningX = 80 TO 1 STEP -1
        FOR scanningY = 1 TO 45
            IF battleScreen(scanningX, scanningY, 2) = 15 OR battleScreen(scanningX, scanningY, 2) = 9 THEN
                espializerRight = scanningX
                EXIT FOR
            END IF
        NEXT scanningY
    NEXT scanningX
    'ok, now that i have the square radius, make sure the new coordinates won't be inside a 15 square radius
    ' but they also need to be in the line of fire
    getNewSarienPlace:
    rndX = INT(RND * 76) + 2
    rndY = INT(RND * 42) + 2
    rndOrient = INT(RND * 4) + 1
    IF rndOrient = 1 THEN sarienOrientation$ = "N"
    IF rndOrient = 2 THEN sarienOrientation$ = "S"
    IF rndOrient = 3 THEN sarienOrientation$ = "W"
    IF rndOrient = 4 THEN sarienOrientation$ = "E"
    ' don't let the Sarien's be within 15 squares of the Espializer. --maybe leter i'll build in the possibility for the star generator to explode but that might be too sq1
    IF espializerLeft - 15 < rndX AND rndX < espializerRight + 15 AND espializerTop - 15 < rndY AND rndY < espializerBottom + 15 THEN
        'need new coordinates
        GOTO getNewSarienPlace
    END IF


    CALL DrawSarien(rndX, rndY, "S") 'sarienOrientation$) '   may not need "CALL" but like my game, i'm old school like that
END SUB

SUB Battle
    'randNum% = INT(RND * (max% - min% + 1)) + min%
    xPos = INT(RND * 71) + 5
    yPos = INT(RND * 41) + 5
    intFacing = INT(RND * 4) + 1:
    IF intFacing = 1 THEN
        facing$ = "N"
    ELSEIF intFacing = 2 THEN
        facing$ = "S"
    ELSEIF intFacing = 3 THEN
        facing$ = "W"
    ELSEIF intFacing = 4 THEN
        facing$ = "E"
    END IF
    '    CALL DrawEspializer(xPos, yPos, facing$)
    '    xPos2 = INT(RND * 71) + 5
    '    yPos2 = INT(RND * 41) + 5
    '    intFacing2 = INT(RND * 4) + 1: IF intFacing2 = 1 THEN facing$ = "N": IF intFacing2 = 2 THEN facing$ = "S": IF intFacing2 = 3 THEN facing$ = "W": IF intFacing2 = 4 THEN facing$ = "E"
    CALL RelocateSarien
    CALL PrintBattleScreen
    CALL DrawSarien(xPos2, yPos2, "N")

    DO
        whichMove$ = INKEY$
        limX = 0: limY = 0
        '        CALL PrintBattleScreen
        SELECT CASE whichMove$
            CASE CHR$(0) + "H" ' up
                IF yPos > 5 THEN
                    IF yPos < 16 THEN
                        limY = 1
                    ELSE
                        limY = yPos - 15
                    END IF
                    moveFlag = 1
                    FOR testingX = xPos - 3 TO xPos + 3
                        IF battleScreen(testingX, limY, 1) <> 32 THEN moveFlag = 0
                    NEXT testingX
                    IF moveFlag = 1 THEN '      needs xPos + / - 3
                        CALL EraseEspializer(xPos, yPos, facing$)
                        yPos = yPos - 1: facing$ = "N"
                        CALL DrawEspializer(xPos, yPos, facing$)
                        CALL PrintBattleScreen
                    END IF
                END IF
            CASE CHR$(0) + "K" ' left
                IF xPos > 5 THEN
                    IF xPos < 16 THEN
                        limX = 1
                    ELSE
                        limX = xPos - 15
                    END IF
                    moveFlag = 1
                    FOR testingY = yPos - 3 TO yPos + 3
                        IF battleScreen(limX, testingY, 1) <> 32 THEN moveFlag = 0
                    NEXT testingY
                    IF moveFlag = 1 THEN
                        CALL EraseEspializer(xPos, yPos, facing$)
                        xPos = xPos - 1: facing$ = "W"
                        CALL DrawEspializer(xPos, yPos, facing$)
                        CALL PrintBattleScreen
                    END IF
                END IF
            CASE CHR$(0) + "P" ' down
                IF yPos < 40 THEN
                    IF yPos > 30 THEN
                        limY = 45
                    ELSE
                        limY = yPos + 15
                    END IF
                    moveFlag = 1
                    FOR testingX = xPos - 3 TO xPos + 3
                        IF battleScreen(testingX, limY, 1) <> 32 THEN moveFlag = 0
                    NEXT testingX
                    IF moveFlag = 1 THEN
                        CALL EraseEspializer(xPos, yPos, facing$)
                        yPos = yPos + 1: facing$ = "S"
                        CALL DrawEspializer(xPos, yPos, facing$)
                        CALL PrintBattleScreen
                    END IF
                END IF
            CASE CHR$(0) + "M" ' right
                IF xPos < 75 THEN
                    IF xPos > 65 THEN
                        limX = 80
                    ELSE
                        limX = xPos + 15
                    END IF
                    moveFlag = 1
                    FOR testingY = yPos - 3 TO yPos + 3
                        IF battleScreen(limX, testingY, 1) <> 32 THEN moveFlag = 0
                    NEXT testingY
                    IF battleScreen(limX, yPos, 1) = 32 THEN
                        CALL EraseEspializer(xPos, yPos, facing$)
                        xPos = xPos + 1: facing$ = "E"
                        CALL DrawEspializer(xPos, yPos, facing$)
                        CALL PrintBattleScreen
                    END IF
                END IF
            CASE CHR$(27)
                END
        END SELECT
    LOOP UNTIL whichMove$ = CHR$(27)
END SUB

SUB DrawSarien (centerX, centerY, orientation$)

    COLOR 10, 0
    SELECT CASE orientation$
        CASE "N"
            IF locateToBegin = 1 THEN
                LOCATE centerY + 0, centerX - 1: PRINT CHR$(219)
                LOCATE centerY + 0, centerX + 1: PRINT CHR$(219)
                LOCATE centerY - 1, centerX + 0: PRINT CHR$(219)
            END IF
            PRINT centerX - 1
            _DISPLAY
            battleScreen(centerX - 1, centerY + 0, 1) = 219: battleScreen(centerX - 1, centerY + 0, 2) = 10
            battleScreen(centerX + 1, centerY + 0, 1) = 219: battleScreen(centerX + 1, centerY + 0, 2) = 10
            battleScreen(centerX + 0, centerY - 1, 1) = 219: battleScreen(centerX + 0, centerY - 1, 2) = 10
        CASE "S"
            IF locateToBegin = 1 THEN
                LOCATE centerY + 0, centerX - 1: PRINT CHR$(219)
                LOCATE centerY + 0, centerX + 1: PRINT CHR$(219)
                LOCATE centerY + 1, centerX + 0: PRINT CHR$(219)
            END IF
            battleScreen(centerX + 0, centerY + 1, 1) = 219: battleScreen(centerX + 0, centerY + 1, 2) = 10
            battleScreen(centerX - 1, centerY + 0, 1) = 219: battleScreen(centerX - 1, centerY + 0, 2) = 10
            battleScreen(centerX + 1, centerY + 0, 1) = 219: battleScreen(centerX + 1, centerY + 0, 2) = 10
        CASE "W"
            IF locateToBegin = 1 THEN
                LOCATE centerY + 0, centerX - 1: PRINT CHR$(219)
                LOCATE centerY - 1, centerX + 0: PRINT CHR$(219)
                LOCATE centerY + 1, centerX + 0: PRINT CHR$(219)
            END IF
            battleScreen(centerX - 1, centerY + 0, 1) = 219: battleScreen(centerX - 1, centerY + 0, 2) = 10
            battleScreen(centerX + 0, centerY - 1, 1) = 219: battleScreen(centerX + 0, centerY - 1, 2) = 10
            battleScreen(centerX + 0, centerY + 1, 1) = 219: battleScreen(centerX + 0, centerY + 1, 2) = 10
        CASE "E"
            IF locateToBegin = 1 THEN
                LOCATE centerY + 0, centerX + 1: PRINT CHR$(219)
                LOCATE centerY - 1, centerX - 1: PRINT CHR$(219)
                LOCATE centerY + 1, centerX - 1: PRINT CHR$(219)
            END IF
            battleScreen(centerX + 1, centerY + 0, 1) = 219: battleScreen(centerX + 1, centerY + 0, 2) = 10
            battleScreen(centerX + 0, centerY - 1, 1) = 219: battleScreen(centerX + 0, centerY - 1, 2) = 10
            battleScreen(centerX + 0, centerY + 1, 1) = 219: battleScreen(centerX + 0, centerY + 1, 2) = 10
    END SELECT
END SUB

SUB EraseSerian (centerx, centery, orientation$)
    SELECT CASE orientation$
        CASE "N"
            battleScreen(centerx - 1, centery + 0, 1) = 32: battleScreen(centerx - 1, centery + 0, 2) = 0
            battleScreen(centerx + 1, centery + 0, 1) = 32: battleScreen(centerx + 1, centery + 0, 2) = 0
            battleScreen(centerx + 0, centery - 1, 1) = 32: battleScreen(centerx + 0, centery - 1, 2) = 0
        CASE "S"
            battleScreen(centerx - 1, centery + 0, 1) = 32: battleScreen(centerx - 1, centery + 0, 2) = 0
            battleScreen(centerx + 1, centery + 0, 1) = 32: battleScreen(centerx + 1, centery + 0, 2) = 0
            battleScreen(centerx + 0, centery + 1, 1) = 32: battleScreen(centerx + 0, centery + 1, 2) = 0
        CASE "W"
            battleScreen(centerx - 1, centery + 0, 1) = 32: battleScreen(centerx - 1, centery + 0, 2) = 0
            battleScreen(centerx + 1, centery - 1, 1) = 32: battleScreen(centerx + 1, centery - 1, 2) = 0
            battleScreen(centerx + 1, centery + 1, 1) = 32: battleScreen(centerx + 1, centery + 1, 2) = 0
        CASE "E"
            battleScreen(centerx + 1, centery + 0, 1) = 32: battleScreen(centerx + 1, centery + 0, 2) = 0
            battleScreen(centerx - 1, centery - 1, 1) = 32: battleScreen(centerx - 1, centery - 1, 2) = 0
            battleScreen(centerx - 1, centery + 1, 1) = 32: battleScreen(centerx - 1, centery + 1, 2) = 0
    END SELECT

END SUB

SUB DrawEspializer (centerX, centerY, orientation$)
    SELECT CASE orientation$
        CASE "E"
            battleScreen(centerX - 4, centerY - 3, 1) = 219: battleScreen(centerX - 4, centerY - 3, 2) = 9
            battleScreen(centerX - 3, centerY - 3, 1) = 219: battleScreen(centerX - 3, centerY - 3, 2) = 9
            battleScreen(centerX - 2, centerY - 3, 1) = 219: battleScreen(centerX - 2, centerY - 3, 2) = 9
            battleScreen(centerX - 1, centerY - 3, 1) = 219: battleScreen(centerX - 1, centerY - 3, 2) = 9
            battleScreen(centerX - 0, centerY - 3, 1) = 219: battleScreen(centerX - 0, centerY - 3, 2) = 9
            battleScreen(centerX - 4, centerY + 3, 1) = 219: battleScreen(centerX - 4, centerY + 3, 2) = 9
            battleScreen(centerX - 3, centerY + 3, 1) = 219: battleScreen(centerX - 3, centerY + 3, 2) = 9
            battleScreen(centerX - 2, centerY + 3, 1) = 219: battleScreen(centerX - 2, centerY + 3, 2) = 9
            battleScreen(centerX - 1, centerY + 3, 1) = 219: battleScreen(centerX - 1, centerY + 3, 2) = 9
            battleScreen(centerX - 0, centerY + 3, 1) = 219: battleScreen(centerX - 0, centerY + 3, 2) = 9
            battleScreen(centerX + 0, centerY - 2, 1) = 219: battleScreen(centerX + 0, centerY - 2, 2) = 15
            battleScreen(centerX + 1, centerY - 2, 1) = 219: battleScreen(centerX + 1, centerY - 2, 2) = 15
            battleScreen(centerX + 2, centerY - 2, 1) = 219: battleScreen(centerX + 2, centerY - 2, 2) = 15
            battleScreen(centerX + 1, centerY - 1, 1) = 219: battleScreen(centerX + 1, centerY - 1, 2) = 15
            battleScreen(centerX + 2, centerY - 1, 1) = 219: battleScreen(centerX + 2, centerY - 1, 2) = 15
            battleScreen(centerX + 3, centerY - 1, 1) = 219: battleScreen(centerX + 3, centerY - 1, 2) = 15
            battleScreen(centerX + 1, centerY + 0, 1) = 219: battleScreen(centerX + 1, centerY + 0, 2) = 15
            battleScreen(centerX + 2, centerY + 0, 1) = 219: battleScreen(centerX + 2, centerY + 0, 2) = 15
            battleScreen(centerX + 3, centerY + 0, 1) = 219: battleScreen(centerX + 3, centerY + 0, 2) = 15
            battleScreen(centerX + 4, centerY + 0, 1) = 219: battleScreen(centerX + 4, centerY + 0, 2) = 15
            battleScreen(centerX + 1, centerY + 1, 1) = 219: battleScreen(centerX + 1, centerY + 1, 2) = 15
            battleScreen(centerX + 2, centerY + 1, 1) = 219: battleScreen(centerX + 2, centerY + 1, 2) = 15
            battleScreen(centerX + 3, centerY + 1, 1) = 219: battleScreen(centerX + 3, centerY + 1, 2) = 15
            battleScreen(centerX + 0, centerY + 2, 1) = 219: battleScreen(centerX + 0, centerY + 2, 2) = 15
            battleScreen(centerX + 1, centerY + 2, 1) = 219: battleScreen(centerX + 1, centerY + 2, 2) = 15
            battleScreen(centerX + 2, centerY + 2, 1) = 219: battleScreen(centerX + 2, centerY + 2, 2) = 15
        CASE "W"
            battleScreen(centerX + 0, centerY - 3, 1) = 219: battleScreen(centerX + 0, centerY - 3, 2) = 9
            battleScreen(centerX + 1, centerY - 3, 1) = 219: battleScreen(centerX + 1, centerY - 3, 2) = 9
            battleScreen(centerX + 2, centerY - 3, 1) = 219: battleScreen(centerX + 2, centerY - 3, 2) = 9
            battleScreen(centerX + 3, centerY - 3, 1) = 219: battleScreen(centerX + 3, centerY - 3, 2) = 9
            battleScreen(centerX + 4, centerY - 3, 1) = 219: battleScreen(centerX + 4, centerY - 3, 2) = 9
            battleScreen(centerX + 0, centerY + 3, 1) = 219: battleScreen(centerX + 0, centerY + 3, 2) = 9
            battleScreen(centerX + 1, centerY + 3, 1) = 219: battleScreen(centerX + 1, centerY + 3, 2) = 9
            battleScreen(centerX + 2, centerY + 3, 1) = 219: battleScreen(centerX + 2, centerY + 3, 2) = 9
            battleScreen(centerX + 3, centerY + 3, 1) = 219: battleScreen(centerX + 3, centerY + 3, 2) = 9
            battleScreen(centerX + 4, centerY + 3, 1) = 219: battleScreen(centerX + 4, centerY + 3, 2) = 9
            battleScreen(centerX - 2, centerY - 2, 1) = 219: battleScreen(centerX - 2, centerY - 2, 2) = 15
            battleScreen(centerX - 1, centerY - 2, 1) = 219: battleScreen(centerX - 1, centerY - 2, 2) = 15
            battleScreen(centerX - 0, centerY - 2, 1) = 219: battleScreen(centerX - 0, centerY - 2, 2) = 15
            battleScreen(centerX - 2, centerY + 2, 1) = 219: battleScreen(centerX - 2, centerY + 2, 2) = 15
            battleScreen(centerX - 1, centerY + 2, 1) = 219: battleScreen(centerX - 1, centerY + 2, 2) = 15
            battleScreen(centerX - 0, centerY + 2, 1) = 219: battleScreen(centerX - 0, centerY + 2, 2) = 15
            battleScreen(centerX - 3, centerY - 1, 1) = 219: battleScreen(centerX - 3, centerY - 1, 2) = 15
            battleScreen(centerX - 2, centerY - 1, 1) = 219: battleScreen(centerX - 2, centerY - 1, 2) = 15
            battleScreen(centerX - 1, centerY - 1, 1) = 219: battleScreen(centerX - 1, centerY - 1, 2) = 15
            battleScreen(centerX - 3, centerY + 1, 1) = 219: battleScreen(centerX - 3, centerY + 1, 2) = 15
            battleScreen(centerX - 2, centerY + 1, 1) = 219: battleScreen(centerX - 2, centerY + 1, 2) = 15
            battleScreen(centerX - 1, centerY + 1, 1) = 219: battleScreen(centerX - 1, centerY + 1, 2) = 15
            battleScreen(centerX - 4, centerY + 0, 1) = 219: battleScreen(centerX - 4, centerY + 0, 2) = 15
            battleScreen(centerX - 3, centerY + 0, 1) = 219: battleScreen(centerX - 3, centerY + 0, 2) = 15
            battleScreen(centerX - 2, centerY + 0, 1) = 219: battleScreen(centerX - 2, centerY + 0, 2) = 15
            battleScreen(centerX - 1, centerY + 0, 1) = 219: battleScreen(centerX - 1, centerY + 0, 2) = 15
        CASE "S"
            battleScreen(centerX - 3, centerY - 4, 1) = 219: battleScreen(centerX - 3, centerY - 4, 2) = 9
            battleScreen(centerX - 3, centerY - 3, 1) = 219: battleScreen(centerX - 3, centerY - 3, 2) = 9
            battleScreen(centerX - 3, centerY - 2, 1) = 219: battleScreen(centerX - 3, centerY - 2, 2) = 9
            battleScreen(centerX - 3, centerY - 1, 1) = 219: battleScreen(centerX - 3, centerY - 1, 2) = 9
            battleScreen(centerX - 3, centerY - 0, 1) = 219: battleScreen(centerX - 3, centerY - 0, 2) = 9
            battleScreen(centerX + 3, centerY - 4, 1) = 219: battleScreen(centerX + 3, centerY - 4, 2) = 9
            battleScreen(centerX + 3, centerY - 3, 1) = 219: battleScreen(centerX + 3, centerY - 3, 2) = 9
            battleScreen(centerX + 3, centerY - 2, 1) = 219: battleScreen(centerX + 3, centerY - 2, 2) = 9
            battleScreen(centerX + 3, centerY - 1, 1) = 219: battleScreen(centerX + 3, centerY - 1, 2) = 9
            battleScreen(centerX + 3, centerY - 0, 1) = 219: battleScreen(centerX + 3, centerY - 0, 2) = 9
            battleScreen(centerX - 2, centerY + 0, 1) = 219: battleScreen(centerX - 2, centerY + 0, 2) = 15
            battleScreen(centerX - 2, centerY + 1, 1) = 219: battleScreen(centerX - 2, centerY + 1, 2) = 15
            battleScreen(centerX - 2, centerY + 2, 1) = 219: battleScreen(centerX - 2, centerY + 2, 2) = 15
            battleScreen(centerX + 2, centerY + 0, 1) = 219: battleScreen(centerX + 2, centerY + 0, 2) = 15
            battleScreen(centerX + 2, centerY + 1, 1) = 219: battleScreen(centerX + 2, centerY + 1, 2) = 15
            battleScreen(centerX + 2, centerY + 2, 1) = 219: battleScreen(centerX + 2, centerY + 2, 2) = 15
            battleScreen(centerX - 1, centerY + 1, 1) = 219: battleScreen(centerX - 1, centerY + 1, 2) = 15
            battleScreen(centerX - 1, centerY + 2, 1) = 219: battleScreen(centerX - 1, centerY + 2, 2) = 15
            battleScreen(centerX - 1, centerY + 3, 1) = 219: battleScreen(centerX - 1, centerY + 3, 2) = 15
            battleScreen(centerX + 1, centerY + 1, 1) = 219: battleScreen(centerX + 1, centerY + 1, 2) = 15
            battleScreen(centerX + 1, centerY + 2, 1) = 219: battleScreen(centerX + 1, centerY + 2, 2) = 15
            battleScreen(centerX + 1, centerY + 3, 1) = 219: battleScreen(centerX + 1, centerY + 3, 2) = 15
            battleScreen(centerX + 0, centerY + 1, 1) = 219: battleScreen(centerX + 0, centerY + 1, 2) = 15
            battleScreen(centerX + 0, centerY + 2, 1) = 219: battleScreen(centerX + 0, centerY + 2, 2) = 15
            battleScreen(centerX + 0, centerY + 3, 1) = 219: battleScreen(centerX + 0, centerY + 3, 2) = 15
            battleScreen(centerX + 0, centerY + 4, 1) = 219: battleScreen(centerX + 0, centerY + 4, 2) = 15
        CASE "N"
            battleScreen(centerX - 3, centerY + 0, 1) = 219: battleScreen(centerX - 3, centerY + 0, 2) = 9
            battleScreen(centerX - 3, centerY + 1, 1) = 219: battleScreen(centerX - 3, centerY + 1, 2) = 9
            battleScreen(centerX - 3, centerY + 2, 1) = 219: battleScreen(centerX - 3, centerY + 2, 2) = 9
            battleScreen(centerX - 3, centerY + 3, 1) = 219: battleScreen(centerX - 3, centerY + 3, 2) = 9
            battleScreen(centerX - 3, centerY + 4, 1) = 219: battleScreen(centerX - 3, centerY + 4, 2) = 9
            battleScreen(centerX + 3, centerY + 0, 1) = 219: battleScreen(centerX + 3, centerY + 0, 2) = 9
            battleScreen(centerX + 3, centerY + 1, 1) = 219: battleScreen(centerX + 3, centerY + 1, 2) = 9
            battleScreen(centerX + 3, centerY + 2, 1) = 219: battleScreen(centerX + 3, centerY + 2, 2) = 9
            battleScreen(centerX + 3, centerY + 3, 1) = 219: battleScreen(centerX + 3, centerY + 3, 2) = 9
            battleScreen(centerX + 3, centerY + 4, 1) = 219: battleScreen(centerX + 3, centerY + 4, 2) = 9
            battleScreen(centerX - 2, centerY - 2, 1) = 219: battleScreen(centerX - 2, centerY - 2, 2) = 15
            battleScreen(centerX - 2, centerY - 1, 1) = 219: battleScreen(centerX - 2, centerY - 1, 2) = 15
            battleScreen(centerX - 2, centerY - 0, 1) = 219: battleScreen(centerX - 2, centerY - 0, 2) = 15
            battleScreen(centerX + 2, centerY - 2, 1) = 219: battleScreen(centerX + 2, centerY - 2, 2) = 15
            battleScreen(centerX + 2, centerY - 1, 1) = 219: battleScreen(centerX + 2, centerY - 1, 2) = 15
            battleScreen(centerX + 2, centerY - 0, 1) = 219: battleScreen(centerX + 2, centerY - 0, 2) = 15
            battleScreen(centerX - 1, centerY - 3, 1) = 219: battleScreen(centerX - 1, centerY - 3, 2) = 15
            battleScreen(centerX - 1, centerY - 2, 1) = 219: battleScreen(centerX - 1, centerY - 2, 2) = 15
            battleScreen(centerX - 1, centerY - 1, 1) = 219: battleScreen(centerX - 1, centerY - 1, 2) = 15
            battleScreen(centerX + 1, centerY - 3, 1) = 219: battleScreen(centerX + 1, centerY - 3, 2) = 15
            battleScreen(centerX + 1, centerY - 2, 1) = 219: battleScreen(centerX + 1, centerY - 2, 2) = 15
            battleScreen(centerX + 1, centerY - 1, 1) = 219: battleScreen(centerX + 1, centerY - 1, 2) = 15
            battleScreen(centerX + 0, centerY - 4, 1) = 219: battleScreen(centerX + 0, centerY - 4, 2) = 15
            battleScreen(centerX + 0, centerY - 3, 1) = 219: battleScreen(centerX + 0, centerY - 3, 2) = 15
            battleScreen(centerX + 0, centerY - 2, 1) = 219: battleScreen(centerX + 0, centerY - 2, 2) = 15
            battleScreen(centerX + 0, centerY - 1, 1) = 219: battleScreen(centerX + 0, centerY - 1, 2) = 15
    END SELECT
END SUB

SUB EraseEspializer (centerX, centerY, orientation$)
    SELECT CASE orientation$
        CASE "E"
            battleScreen(centerX - 4, centerY - 3, 1) = 32: battleScreen(centerX - 4, centerY - 3, 2) = 0
            battleScreen(centerX - 3, centerY - 3, 1) = 32: battleScreen(centerX - 3, centerY - 3, 2) = 0
            battleScreen(centerX - 2, centerY - 3, 1) = 32: battleScreen(centerX - 2, centerY - 3, 2) = 0
            battleScreen(centerX - 1, centerY - 3, 1) = 32: battleScreen(centerX - 1, centerY - 3, 2) = 0
            battleScreen(centerX - 0, centerY - 3, 1) = 32: battleScreen(centerX - 0, centerY - 3, 2) = 0
            battleScreen(centerX - 4, centerY + 3, 1) = 32: battleScreen(centerX - 4, centerY + 3, 2) = 0
            battleScreen(centerX - 3, centerY + 3, 1) = 32: battleScreen(centerX - 3, centerY + 3, 2) = 0
            battleScreen(centerX - 2, centerY + 3, 1) = 32: battleScreen(centerX - 2, centerY + 3, 2) = 0
            battleScreen(centerX - 1, centerY + 3, 1) = 32: battleScreen(centerX - 1, centerY + 3, 2) = 0
            battleScreen(centerX - 0, centerY + 3, 1) = 32: battleScreen(centerX - 0, centerY + 3, 2) = 0
            battleScreen(centerX + 0, centerY - 2, 1) = 32: battleScreen(centerX + 0, centerY - 2, 2) = 0
            battleScreen(centerX + 1, centerY - 2, 1) = 32: battleScreen(centerX + 1, centerY - 2, 2) = 0
            battleScreen(centerX + 2, centerY - 2, 1) = 32: battleScreen(centerX + 2, centerY - 2, 2) = 0
            battleScreen(centerX + 1, centerY - 1, 1) = 32: battleScreen(centerX + 1, centerY - 1, 2) = 0
            battleScreen(centerX + 2, centerY - 1, 1) = 32: battleScreen(centerX + 2, centerY - 1, 2) = 0
            battleScreen(centerX + 3, centerY - 1, 1) = 32: battleScreen(centerX + 3, centerY - 1, 2) = 0
            battleScreen(centerX + 1, centerY + 0, 1) = 32: battleScreen(centerX + 1, centerY + 0, 2) = 0
            battleScreen(centerX + 2, centerY + 0, 1) = 32: battleScreen(centerX + 2, centerY + 0, 2) = 0
            battleScreen(centerX + 3, centerY + 0, 1) = 32: battleScreen(centerX + 3, centerY + 0, 2) = 0
            battleScreen(centerX + 4, centerY + 0, 1) = 32: battleScreen(centerX + 4, centerY + 0, 2) = 0
            battleScreen(centerX + 1, centerY + 1, 1) = 32: battleScreen(centerX + 1, centerY + 1, 2) = 0
            battleScreen(centerX + 2, centerY + 1, 1) = 32: battleScreen(centerX + 2, centerY + 1, 2) = 0
            battleScreen(centerX + 3, centerY + 1, 1) = 32: battleScreen(centerX + 3, centerY + 1, 2) = 0
            battleScreen(centerX + 0, centerY + 2, 1) = 32: battleScreen(centerX + 0, centerY + 2, 2) = 0
            battleScreen(centerX + 1, centerY + 2, 1) = 32: battleScreen(centerX + 1, centerY + 2, 2) = 0
            battleScreen(centerX + 2, centerY + 2, 1) = 32: battleScreen(centerX + 2, centerY + 2, 2) = 0
        CASE "W"
            battleScreen(centerX + 0, centerY - 3, 1) = 32: battleScreen(centerX + 0, centerY - 3, 2) = 0
            battleScreen(centerX + 1, centerY - 3, 1) = 32: battleScreen(centerX + 1, centerY - 3, 2) = 0
            battleScreen(centerX + 2, centerY - 3, 1) = 32: battleScreen(centerX + 2, centerY - 3, 2) = 0
            battleScreen(centerX + 3, centerY - 3, 1) = 32: battleScreen(centerX + 3, centerY - 3, 2) = 0
            battleScreen(centerX + 4, centerY - 3, 1) = 32: battleScreen(centerX + 4, centerY - 3, 2) = 0
            battleScreen(centerX + 0, centerY + 3, 1) = 32: battleScreen(centerX + 0, centerY + 3, 2) = 0
            battleScreen(centerX + 1, centerY + 3, 1) = 32: battleScreen(centerX + 1, centerY + 3, 2) = 0
            battleScreen(centerX + 2, centerY + 3, 1) = 32: battleScreen(centerX + 2, centerY + 3, 2) = 0
            battleScreen(centerX + 3, centerY + 3, 1) = 32: battleScreen(centerX + 3, centerY + 3, 2) = 0
            battleScreen(centerX + 4, centerY + 3, 1) = 32: battleScreen(centerX + 4, centerY + 3, 2) = 0
            battleScreen(centerX - 2, centerY - 2, 1) = 32: battleScreen(centerX - 2, centerY - 2, 2) = 0
            battleScreen(centerX - 1, centerY - 2, 1) = 32: battleScreen(centerX - 1, centerY - 2, 2) = 0
            battleScreen(centerX - 0, centerY - 2, 1) = 32: battleScreen(centerX - 0, centerY - 2, 2) = 0
            battleScreen(centerX - 2, centerY + 2, 1) = 32: battleScreen(centerX - 2, centerY + 2, 2) = 0
            battleScreen(centerX - 1, centerY + 2, 1) = 32: battleScreen(centerX - 1, centerY + 2, 2) = 0
            battleScreen(centerX - 0, centerY + 2, 1) = 32: battleScreen(centerX - 0, centerY + 2, 2) = 0
            battleScreen(centerX - 3, centerY - 1, 1) = 32: battleScreen(centerX - 3, centerY - 1, 2) = 0
            battleScreen(centerX - 2, centerY - 1, 1) = 32: battleScreen(centerX - 2, centerY - 1, 2) = 0
            battleScreen(centerX - 1, centerY - 1, 1) = 32: battleScreen(centerX - 1, centerY - 1, 2) = 0
            battleScreen(centerX - 3, centerY + 1, 1) = 32: battleScreen(centerX - 3, centerY + 1, 2) = 0
            battleScreen(centerX - 2, centerY + 1, 1) = 32: battleScreen(centerX - 2, centerY + 1, 2) = 0
            battleScreen(centerX - 1, centerY + 1, 1) = 32: battleScreen(centerX - 1, centerY + 1, 2) = 0
            battleScreen(centerX - 4, centerY + 0, 1) = 32: battleScreen(centerX - 4, centerY + 0, 2) = 0
            battleScreen(centerX - 3, centerY + 0, 1) = 32: battleScreen(centerX - 3, centerY + 0, 2) = 0
            battleScreen(centerX - 2, centerY + 0, 1) = 32: battleScreen(centerX - 2, centerY + 0, 2) = 0
            battleScreen(centerX - 1, centerY + 0, 1) = 32: battleScreen(centerX - 1, centerY + 0, 2) = 0
        CASE "S"
            battleScreen(centerX - 3, centerY - 4, 1) = 32: battleScreen(centerX - 3, centerY - 4, 2) = 0
            battleScreen(centerX - 3, centerY - 3, 1) = 32: battleScreen(centerX - 3, centerY - 3, 2) = 0
            battleScreen(centerX - 3, centerY - 2, 1) = 32: battleScreen(centerX - 3, centerY - 2, 2) = 0
            battleScreen(centerX - 3, centerY - 1, 1) = 32: battleScreen(centerX - 3, centerY - 1, 2) = 0
            battleScreen(centerX - 3, centerY - 0, 1) = 32: battleScreen(centerX - 3, centerY - 0, 2) = 0
            battleScreen(centerX + 3, centerY - 4, 1) = 32: battleScreen(centerX + 3, centerY - 4, 2) = 0
            battleScreen(centerX + 3, centerY - 3, 1) = 32: battleScreen(centerX + 3, centerY - 3, 2) = 0
            battleScreen(centerX + 3, centerY - 2, 1) = 32: battleScreen(centerX + 3, centerY - 2, 2) = 0
            battleScreen(centerX + 3, centerY - 1, 1) = 32: battleScreen(centerX + 3, centerY - 1, 2) = 0
            battleScreen(centerX + 3, centerY - 0, 1) = 32: battleScreen(centerX + 3, centerY - 0, 2) = 0
            battleScreen(centerX - 2, centerY + 0, 1) = 32: battleScreen(centerX - 2, centerY + 0, 2) = 0
            battleScreen(centerX - 2, centerY + 1, 1) = 32: battleScreen(centerX - 2, centerY + 1, 2) = 0
            battleScreen(centerX - 2, centerY + 2, 1) = 32: battleScreen(centerX - 2, centerY + 2, 2) = 0
            battleScreen(centerX + 2, centerY + 0, 1) = 32: battleScreen(centerX + 2, centerY + 0, 2) = 0
            battleScreen(centerX + 2, centerY + 1, 1) = 32: battleScreen(centerX + 2, centerY + 1, 2) = 0
            battleScreen(centerX + 2, centerY + 2, 1) = 32: battleScreen(centerX + 2, centerY + 2, 2) = 0
            battleScreen(centerX - 1, centerY + 1, 1) = 32: battleScreen(centerX - 1, centerY + 1, 2) = 0
            battleScreen(centerX - 1, centerY + 2, 1) = 32: battleScreen(centerX - 1, centerY + 2, 2) = 0
            battleScreen(centerX - 1, centerY + 3, 1) = 32: battleScreen(centerX - 1, centerY + 3, 2) = 0
            battleScreen(centerX + 1, centerY + 1, 1) = 32: battleScreen(centerX + 1, centerY + 1, 2) = 0
            battleScreen(centerX + 1, centerY + 2, 1) = 32: battleScreen(centerX + 1, centerY + 2, 2) = 0
            battleScreen(centerX + 1, centerY + 3, 1) = 32: battleScreen(centerX + 1, centerY + 3, 2) = 0
            battleScreen(centerX + 0, centerY + 1, 1) = 32: battleScreen(centerX + 0, centerY + 1, 2) = 0
            battleScreen(centerX + 0, centerY + 2, 1) = 32: battleScreen(centerX + 0, centerY + 2, 2) = 0
            battleScreen(centerX + 0, centerY + 3, 1) = 32: battleScreen(centerX + 0, centerY + 3, 2) = 0
            battleScreen(centerX + 0, centerY + 4, 1) = 32: battleScreen(centerX + 0, centerY + 4, 2) = 0
        CASE "N"
            battleScreen(centerX - 3, centerY + 0, 1) = 32: battleScreen(centerX - 3, centerY + 0, 2) = 0
            battleScreen(centerX - 3, centerY + 1, 1) = 32: battleScreen(centerX - 3, centerY + 1, 2) = 0
            battleScreen(centerX - 3, centerY + 2, 1) = 32: battleScreen(centerX - 3, centerY + 2, 2) = 0
            battleScreen(centerX - 3, centerY + 3, 1) = 32: battleScreen(centerX - 3, centerY + 3, 2) = 0
            battleScreen(centerX - 3, centerY + 4, 1) = 32: battleScreen(centerX - 3, centerY + 4, 2) = 0
            battleScreen(centerX + 3, centerY + 0, 1) = 32: battleScreen(centerX + 3, centerY + 0, 2) = 0
            battleScreen(centerX + 3, centerY + 1, 1) = 32: battleScreen(centerX + 3, centerY + 1, 2) = 0
            battleScreen(centerX + 3, centerY + 2, 1) = 32: battleScreen(centerX + 3, centerY + 2, 2) = 0
            battleScreen(centerX + 3, centerY + 3, 1) = 32: battleScreen(centerX + 3, centerY + 3, 2) = 0
            battleScreen(centerX + 3, centerY + 4, 1) = 32: battleScreen(centerX + 3, centerY + 4, 2) = 0
            battleScreen(centerX - 2, centerY - 2, 1) = 32: battleScreen(centerX - 2, centerY - 2, 2) = 0
            battleScreen(centerX - 2, centerY - 1, 1) = 32: battleScreen(centerX - 2, centerY - 1, 2) = 0
            battleScreen(centerX - 2, centerY - 0, 1) = 32: battleScreen(centerX - 2, centerY - 0, 2) = 0
            battleScreen(centerX + 2, centerY - 2, 1) = 32: battleScreen(centerX + 2, centerY - 2, 2) = 0
            battleScreen(centerX + 2, centerY - 1, 1) = 32: battleScreen(centerX + 2, centerY - 1, 2) = 0
            battleScreen(centerX + 2, centerY - 0, 1) = 32: battleScreen(centerX + 2, centerY - 0, 2) = 0
            battleScreen(centerX - 1, centerY - 3, 1) = 32: battleScreen(centerX - 1, centerY - 3, 2) = 0
            battleScreen(centerX - 1, centerY - 2, 1) = 32: battleScreen(centerX - 1, centerY - 2, 2) = 0
            battleScreen(centerX - 1, centerY - 1, 1) = 32: battleScreen(centerX - 1, centerY - 1, 2) = 0
            battleScreen(centerX + 1, centerY - 3, 1) = 32: battleScreen(centerX + 1, centerY - 3, 2) = 0
            battleScreen(centerX + 1, centerY - 2, 1) = 32: battleScreen(centerX + 1, centerY - 2, 2) = 0
            battleScreen(centerX + 1, centerY - 1, 1) = 32: battleScreen(centerX + 1, centerY - 1, 2) = 0
            battleScreen(centerX + 0, centerY - 4, 1) = 32: battleScreen(centerX + 0, centerY - 4, 2) = 0
            battleScreen(centerX + 0, centerY - 3, 1) = 32: battleScreen(centerX + 0, centerY - 3, 2) = 0
            battleScreen(centerX + 0, centerY - 2, 1) = 32: battleScreen(centerX + 0, centerY - 2, 2) = 0
            battleScreen(centerX + 0, centerY - 1, 1) = 32: battleScreen(centerX + 0, centerY - 1, 2) = 0
    END SELECT
    CALL PrintBattleScreen
END SUB

Easy solution to this is just to make the array large enough to handle the negative indexes:

DIM SHARED battleScreen(-5 TO 85, -5 TO 50, 1 TO 2) 


https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Jaze

  • Newbie
  • Posts: 86
    • View Profile
Re: why am i getting subscript out of range?!! #$%@#! The code looks good.
« Reply #2 on: December 08, 2020, 10:43:55 pm »
that solved one problem but created 2 more. the relocated should've assigned a positive random number to the variable sent to the DrawSarien SUB. when i redimensioned the array the sarien could get run over and the espializer didn't show up until an arrow key was pressed. i appreciated the help nonetheless

Offline Jaze

  • Newbie
  • Posts: 86
    • View Profile
Re: why am i getting subscript out of range?!! #$%@#! The code looks good.
« Reply #3 on: December 09, 2020, 04:07:16 pm »
I cut and pasted the code into the DrawSarien sub. With changes only to the variable names (after the cut and paste!) the code works fine. I suppose I simply don't have the skills to correct the error that appeared.

Marked as best answer by Jaze on December 10, 2020, 08:51:45 am

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: why am i getting subscript out of range?!! #$%@#! The code looks good.
« Reply #4 on: December 09, 2020, 05:24:32 pm »
I cut and pasted the code into the DrawSarien sub. With changes only to the variable names (after the cut and paste!) the code works fine...

Glad to see! Practice makes perfect :)  (It wont save you from blunders though );

BTW OPTION _EXPLICIT will save you from typos but can be annoying too.
« Last Edit: December 09, 2020, 05:26:50 pm by bplus »