01-01-2004, 11:43 PM
My SUB to load map files is this:
Where the format of the map files is:
1,1,1
1,2,3
3,7,3
etc. etc., with comma-seperated values across, 25 down (I'm using SCREEN 13, 40x25).
And my SUB that prints the map:
Alright, and I declared a SHARED map(1 TO 40, 1 TO 25), adn the blank, tile, smiley, etc. are CONSTS.
The problem is, when I run the program, it doesn't print exactly what the map says...Most of it is OK, but there is a streak of blanks diagonally where in the file it's almost completely tiles (CHR$(177)s), and some things are out of place, like some of the "$"s are where they shouldn't be.
I suspect that the problem lies within the loadmap SUB, but I can't see a problem.
Any ideas?
Code:
SUB loadmap (filename$)
IF LEN(filename$) > 0 THEN
OPEN filename$ FOR INPUT AS #1
FOR y = 1 TO 25
FOR x = 1 TO 40
INPUT #1, tile
map(x, y) = tile
NEXT
NEXT
CLOSE #1
END IF
END SUB
1,1,1
1,2,3
3,7,3
etc. etc., with comma-seperated values across, 25 down (I'm using SCREEN 13, 40x25).
And my SUB that prints the map:
Code:
SUB setscreen
FOR y = 1 TO 25
FOR x = 1 TO 40
IF x = 40 THEN
PRINT CHR$(177)
ELSE
IF map(x, y) = blank THEN PRINT " ";
IF map(x, y) = tile THEN PRINT CHR$(177);
IF map(x, y) = smiley THEN PRINT CHR$(1);
IF map(x, y) = enemy THEN PRINT "*";
IF map(x, y) = points THEN PRINT "$";
IF map(x, y) = endlevel THEN PRINT "#";
END IF
NEXT
NEXT
END SUB
The problem is, when I run the program, it doesn't print exactly what the map says...Most of it is OK, but there is a streak of blanks diagonally where in the file it's almost completely tiles (CHR$(177)s), and some things are out of place, like some of the "$"s are where they shouldn't be.
I suspect that the problem lies within the loadmap SUB, but I can't see a problem.
Any ideas?