Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Loading Tile Based Maps from text files
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Adaub7282




PostPosted: 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
Sponsor
sponsor
Tony




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
DemonWasp




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: