The Partridge Family were neither partridges nor a family. Discuss.
-
Psychoman
- Posts: 36
- Joined: June 13th, 2013, 2:12 pm
Post
by Psychoman » July 22nd, 2013, 7:47 pm
Hello, I hate myself for asking dumb easy questions, but I have some kind of problem that I listened through and tried to do the same thing.The problem is like ,when I get the first score it saves it to the file ,but there I also have some of other crap.This is what I have rewritten from chili.
Code: Select all
oid Game::InsertScore( HighScore score )
{
int i;
for( i = 0;i < NSCORES && scores[i].score >= score.score;i++ );
if( i < NSCORES )
{
for( int shuffleIndex = NSCORES - 2;shuffleIndex >= i;shuffleIndex-- )
{
scores[shuffleIndex + 1] = scores[shuffleIndex];
}
scores[i] = score;
}
}
void Game::SaveScoreboard()
{
FILE* pFile = fopen( "hiscore.txt","w" );
for( int i = 0; i < NSCORES && scores[i].score >= 0;i++ )
{
fprintf( pFile,"%d.\t%d\t\t%s\r\n",(i + 1),scores[i].score,scores[i].time );
}
fclose( pFile );
}
Game::HighScore Game::GetScore()
{
HighScore score;
score.score = nGoal;
time_t curTime = time( NULL );
strftime( score.time,TIMEBUFLEN,"%X/%x",localtime( &curTime ) );
return score;
}
Here's the crap that shows up in the file:
-
Attachments
-
- crap.png
- (5.79 KiB) Downloaded 106 times
-
bobloblaw
- Posts: 100
- Joined: April 15th, 2013, 3:05 am
- Location: Earth, USA, California, SF Bay Area
-
Contact:
Post
by bobloblaw » July 22nd, 2013, 10:53 pm
Don't hate yourself for asking dumb questions, that's how we learn. I'm assuming the "v" is there on the first "void" and it was just left out for the post. Also you have "index" as "i" shouldn't be a problem though. Sometimes it helps to type exactly what chilli has for debugging purposes.
Under void Game::SaveScoreBoard()
change pfile string from "%d.\t%d\t\t%s\r\n" to "%d.\t%d\t%s\n" Might not be the problem but it's just different from chilli's.
If none of those changes make a difference post your files up so I can run it on my comp to give a better solution.
Good Luck,
-Cheers
Here for your Artistic needs, Pixel or Vector I love it all. Check it out -
Click Me
-
LuisR14
- Posts: 1248
- Joined: May 23rd, 2013, 3:52 pm
- Location: USA
-
Contact:
Post
by LuisR14 » July 23rd, 2013, 12:59 am
have you initialized your scores array(or w/e it was lol) to null?
always available, always on, about ~10 years c/c++, java[script], win32/directx api, [x]html/css/php/some asp/sql experience. (all self taught)
Knows English, Spanish and Japanese.
[url=irc://irc.freenode.net/#pchili]
irc://irc.freenode.net/#pchili[/url] [url=irc://luisr14.no-ip.org/#pchili]
alt[/url] -- join up if ever want real-time help or to just
chat --
-
Psychoman
- Posts: 36
- Joined: June 13th, 2013, 2:12 pm
Post
by Psychoman » July 23rd, 2013, 6:49 am
Yeap, LuisR14 is again right, I just didn't initialize array in constructor.Btw I type "i" not "index" just to implement my style of program or some other things.
-
LuisR14
- Posts: 1248
- Joined: May 23rd, 2013, 3:52 pm
- Location: USA
-
Contact:
Post
by LuisR14 » July 23rd, 2013, 11:26 am
Psychoman wrote:Btw I type "i" not "index" just to implement my style of program or some other things.
hehe, yea i use that style as well (since i would be short for index
)
always available, always on, about ~10 years c/c++, java[script], win32/directx api, [x]html/css/php/some asp/sql experience. (all self taught)
Knows English, Spanish and Japanese.
[url=irc://irc.freenode.net/#pchili]
irc://irc.freenode.net/#pchili[/url] [url=irc://luisr14.no-ip.org/#pchili]
alt[/url] -- join up if ever want real-time help or to just
chat --