Archived

This topic is now archived and is closed to further replies.

Unidentified

File Extentions

Recommended Posts

Unidentified    136
I'm reading Cone3d's tutorial about sprites, and I don't get what the info file is. How do you create it? I can only get the code that comes with the tutorial to work. Do you have to write a program to create one, like open up a file stream, put the needed data in it, and save it, without an extension? Is it recommended to use the way the tutorial does it? What other ways are there to do sprite animation with SDL? [edited by - Unidentified on January 18, 2004 9:40:52 PM]

Share this post


Link to post
Share on other sites
vaneger    100
the info file is just a plain text file, but with no extension, just open notepad edit the info file to what you need and save it. thats what i do anyways, however if you prefered you could alter the loading code to use .txt files like so

//this is in CSpriteBase.cpp

int CSpriteBase::init(char *dir)
{
char buffer[255];
char filename[255];
char name[255];
int pause=0, r=0, g=0, b=0;
FILE *fp;

//change this line

sprintf(filename, "%s/info", dir);

//to this this line instead

sprintf(filename, "%s/info.txt", dir);


Share this post


Link to post
Share on other sites
Unidentified    136
I'm using C++ for this. I have another question about files. How do you go about reading numbers from a text file. I'm assuming you can't, I made a text file with numbers and used the >> operator to input numbers into the file, and it doens't read. I decided to use .txt instead of the extension used. So how do I deal with number data in text file. Should convert it from a char to an into? Or is there another way.

[edited by - Unidentified on January 18, 2004 9:50:41 PM]

Share this post


Link to post
Share on other sites
Oluseyi    2114
quote:
Original post by Unidentified
I''m using C++ for this. I have another question about files. How do you go about reading numbers from a text file. I''m assuming you can''t...
Of course you can.

quote:
I made a text file with numbers and used the >> operator to input numbers into the file, and it doesn''t read.
Code speaks louder than words. Show us the code.

Share this post


Link to post
Share on other sites
krez    443
the file extension means nothing at all as far as opening or reading or writing the file. the windows OS uses the extensions to decide what program to use to open the files if you double-click them (and also what icon to put next to it), but other than that they are just more characters in the filename. they do give a clue as to the format of the file, but it isn''t definite (you can change all of your .bmp files to .txt files, or write a text file and call it something.jpg)...

if you can open and read/write a .txt file, you can do it with a file with no extension, or any other extension. the code is the same.

Share this post


Link to post
Share on other sites