Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Arrays and subs....
#1
Can anyone tell me why this code isn't working. I press 'compile and run' and it gives me the following error "error 60: Illegal specification, at parameter 6: map On line: 26"

Code:
SCREEN 17            
CLS                  

DIM map%(1 TO 80, 1 TO 25)

FOR grassy% = 1 TO 24
   FOR grassx% = 1 TO 80
      map%(grassx%, grassy%) = 1    
   NEXT grassx%
NEXT grassy%

FOR x = 1 to 80
   for y = 1 to 25
      if map%(x, y) = 1 THEN
         LOCATE y, x
         COLOR 47, 0
         PRINT CHR$(177)
      end if
   next y
next x

locx% = 1
locy% = 1
player$ = CHR$(2)

sub graphics(x as integer, y as integer, oldx as integer, oldy as integer, char as string, map(1 TO 80, 1 TO 25) AS integer)
   CLS
   map(x, y) = 0
   LOCATE y, x
   COLOR 31, 0
   PRINT char
   map%(oldx, oldy) = 1
end sub



DO
  
   press$ = INKEY$
  
   IF press$ = "s" THEN
      oldy% = locy%
      locy% = locy + 1
      graphics locx%, locy%, oldx%, oldy%, player$, map%(1 TO 80, 1 TO 25)
   ELSEIF press$ = "w" THEN
      oldy% = locy%
      locy% = locy% - 1
      graphics locx%, locy%, oldx%, oldy%, player$, map%(1 TO 80, 1 TO 25)
   ELSEIF press$ = "d" THEN
      oldx% = locx%
      locx% = locx% + 1
      graphics locx%, locy%, oldx%, oldy%, player$, map%(1 TO 80, 1 TO 25)
   ELSEIF press$ = "a" THEN
      oldx% = locx%
      locx% = locx% - 1
      graphics locx%, locy%, oldx%, oldy%, player$, map%(1 TO 80, 1 TO 25)
   END IF
  
   FOR x = 1 to 80
   for y = 1 to 25
      if map%(x, y) = 1 THEN
         LOCATE y, x
         COLOR 47, 0
         PRINT CHR$(177)
      end if
   next y
next x
  
   IF press$ <> "" THEN
      CLS
      press$ = ""
   END IF
  
LOOP UNTIL press$ = CHR$(27)

Thanks in advance.

Jack
Reply
#2
use map() instead of map(1 TO 80, 1 TO 25). You only need to defined the upper and lower bounds when you DIM it, the rest is safely passed to the subroutine.
Reply
#3
Okay, thank you very much.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)