TTF High Scores Dilema

Anything related in any way to game development as a whole is welcome here. Tell us about your game, grace us with your project, show us your new YouTube video, etc.

Moderator: PC Supremacists

Post Reply
RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

TTF High Scores Dilema

Post by RandomDever »

I'm currently working on a new project that I want to have a list of the top 5 high scores but ifstream objects seem to only be able to convert each line into a string.
However to print it to the screen I need it to be a char * so I don't know what to do.
And another more minor problem is that every time the program starts I want the highscores.txt file to be filled with fake scores but ONLY if it's empty, but I can't think of any way to check that.
Any and all help will be very appreciated.
K-Bal
ES Beta Backer
ES Beta Backer
Posts: 701
Joined: Sun Mar 15, 2009 3:21 pm
Location: Germany, Aachen
Contact:

Re: TTF High Scores Dilema

Post by K-Bal »

Look at the reference. They have a member function called c_str.
RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

Re: TTF High Scores Dilema

Post by RandomDever »

Tried that already.
User avatar
Bakkon
Chaos Rift Junior
Chaos Rift Junior
Posts: 384
Joined: Wed May 20, 2009 2:38 pm
Programming Language of Choice: C++
Location: Indiana

Re: TTF High Scores Dilema

Post by Bakkon »

RandomDever wrote:Tried that already.
Then it should work.

Code: Select all

string myString = "High Score";
TTF_RenderText_Solid(font, myString.c_str(), color);
Also, just have a bool named "makeFakeScores" or something, start it as true, if you find something in the high scores files, flip it to false.
RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

Re: TTF High Scores Dilema

Post by RandomDever »

EDIT: Well I tried it and it works now..... For some reason. :| :)
But how do I check whether a text file is empty or not?
And how do you add two strings together with a space added to separate them?
User avatar
Bakkon
Chaos Rift Junior
Chaos Rift Junior
Posts: 384
Joined: Wed May 20, 2009 2:38 pm
Programming Language of Choice: C++
Location: Indiana

Re: TTF High Scores Dilema

Post by Bakkon »

Have you tried reading any documentation?

http://www.cplusplus.com/reference/iostream/fstream/

peek() and see if it's empty.
User avatar
hurstshifter
ES Beta Backer
ES Beta Backer
Posts: 713
Joined: Mon Jun 08, 2009 8:33 pm
Favorite Gaming Platforms: SNES
Programming Language of Choice: C/++
Location: Boston, MA
Contact:

Re: TTF High Scores Dilema

Post by hurstshifter »

Bakkon wrote:Have you tried reading any documentation?

Haha, this
"Time is an illusion. Lunchtime, doubly so."
http://www.thenerdnight.com
Post Reply