Loading Tile Based Maps from text files
Author |
Message |
Adaub7282
|
Posted: Tue Oct 06, 2009 9:52 am Post subject: Loading Tile Based Maps from text files |
|
|
So I am attempting to make tile based maps that will be loaded from a text file. Problem is, there's a problem. "Variable has no data" I am asking the people of compsci, in their infinite Turing wisdom, for guidance.
Turing: | /* Using Tile Based Maps: Version 0.2 ("Pirate") */
/* Aaron Daub */
/* October 6th, yarr */
View.Set ("graphics:300;300") %Here be where I set the screen size
var stream : int % And here be where I declare the stream, arrghh
var tiles : array 0 .. 14, 0 .. 14 of int %These be my tile arrays
open : stream, "map.txt", read %Open the stream, mateys
for x : 0 .. 14
for y : 0 .. 14
read : stream, tiles (x, y ) %Ponder o'er the data
end for
end for
close (stream ) %Fasten the stream
for x : 0 .. 14
for y : 0 .. 14
if tiles (x, y ) = 1 then %And 'ere be where the problem lies
Draw.FillBox (x * 20, y * 20, x * 20 + 20, y * 20 + 20, red)
elsif tiles (x, y ) = 0 then
Draw.FillBox (x * 20, y * 20, x * 20 + 20, y * 20 + 20, green)
end if
end for
end for |
[/syntax] |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Tue Oct 06, 2009 10:33 am Post subject: RE:Loading Tile Based Maps from text files |
|
|
You are loading a file as a binary read, while I suspect that you want ASCII get. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
DemonWasp
|
Posted: Tue Oct 06, 2009 10:35 am Post subject: RE:Loading Tile Based Maps from text files |
|
|
Just a guess, but did you really mean to open your stream for read? Read is only used when your file is binary-encoded. If you created "map.txt" in an editor like Notepad, you want to use get, which expects an ASCII-encoded file. |
|
|
|
|
|
|
|