Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Reading individual numbers out of a file...

Author
Message
Mister Fuzzy
13
Years of Service
User Offline
Joined: 27th Feb 2011
Location: XNA
Posted: 17th Oct 2011 03:10 Edited at: 17th Oct 2011 03:13
I'm working on a new tileset reader that takes a file and reads out specific 2-digit numbers from a file written like this:

1205004505050523040505030274305093841212

However, I can't figure out the darn read commands! What I want my program to do is read one group at a time, as each pair ( 00 - 99 ) refers to a tile to load and blit to the screen: So really it will read the above chunk of text as:

12 05 00 45 05 05 05 23 04 05 05 03 02 74 30 50 93 84 12 12

How can I get it to single out certain digits like this?
Jcamden
12
Years of Service
User Offline
Joined: 5th Oct 2011
Location: Washington
Posted: 17th Oct 2011 03:16
Mister,

You have to create a read function using a pointer. I can provide an example if needed but I would create a pointer to read the data then just iterate through the numbers until you reach the end.

Joe
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 17th Oct 2011 15:22
if you are sure that the file will only contain pairs of numbers, you can do this:



either that, or do the same thing, but read them 2 by 2, i believe this one is more efficient in speed.

Login to post a reply

Server time is: 2024-10-02 21:37:57
Your offset time is: 2024-10-02 21:37:57