file i/o stuff

Started by
2 comments, last by OoMMMoO 23 years, 11 months ago
Is there a way you can read from certain lines in a text file? I know how to read from the top down a certain amount of lines but what if you want to read from the center down? Also another question which isnt about file i/o are most sidescrollers tile based games? or are there some games were it is just a bitmap that is bigger than the screen?
Advertisement
I''m pretty sure you use fseek() for going to a certain place in a file. To your other question, yes, I think most sidescrollers are tile-based (although I''ve never made one!).

altair
altair734@yahoo.com
www.geocities.com/altair734
altairaltair734@yahoo.comwww.geocities.com/altair734
>> Is there a way you can read from certain lines in a text file? I know how to read from the top down a certain amount of lines but what if you want to read from the center down?

If I understand your question correctly, you want to calculate the "center" of a file? You can do that like so (old skool C file pointers ):

FILE *fp;
long f_length, f_center;
fp = fopen("yourfile.bin", "rb");

// Go to end of file
fseek(fp, 0, SEEK_END);

// Get length of file
f_length = ftell(fp);

// Calculate center of file
f_center = f_length / 2;

// Go to the center of the file
fseek(fp, f_center, SEEK_SET);

// Read stuff from center of file
fread(...)

>> are most sidescrollers tile based games? or are there some games were it is just a bitmap that is bigger than the screen?

Yep, most sidescrollsers are tilebased.

/. Muzzafarath

Edited by - Muzzafarath on 5/5/00 1:41:34 PM
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
Can you imagine the size of the bitmap that would be required for the average level in Super Mario? I would be enormous! Probably 50 screens long and 3 high.

Make you game run in 16 bit color, 800x600, and you''re looking at allocating over 137 MEGABYTES of memory.

That''s one BIG DAMN video card! Where can I buy one?

This topic is closed to new replies.

Advertisement