I'm posting new code to give you a better picture of what my problem is. Actually, I couldn't figure out if the problem lies on my "read file" or the drawtext function. :-)
- Code:
//my declarations
TCHAR name1[9],
name2[9],
name3[9],
name4[9],
name5[9],
score1[9],
score2[9],
score3[9],
score4[9],
score5[9];
//create temporary file
void CreateScoresFile()
{
#ifdef _WIN32_WCE
FILE *fp = _wfopen(GetPath(TEXT("scores.dat")), TEXT("w"));
#else
FILE *fp = fopen(GetPath(TEXT("scores.dat")), TEXT("w"));
#endif
if(fp == NULL) return;
fprintf(fp, "%s", " NAME 500 NAME15 400 NAME5 300 OK 200 NAME32 100");
fclose(fp);
}
//function to read data from created file
void ReadScoresFromFile()
{
#ifdef _WIN32_WCE
FILE *fp = _wfopen(GetPath(TEXT("scores.dat")), TEXT("r"));
#else
FILE *fp = fopen(GetPath(TEXT("scores.dat")), TEXT("r"));
#endif
if(fp == NULL) return;
fread(name1, sizeof(name1) - 1, 1, fp);
fread(score1, sizeof(score1) - 1, 1, fp);
fread(name2, sizeof(name2) - 1, 1, fp);
fread(score2, sizeof(score2) - 1, 1, fp);
fread(name3, sizeof(name3) - 1, 1, fp);
fread(score3, sizeof(score3) - 1, 1, fp);
fread(name4, sizeof(name4) - 1, 1, fp);
fread(score4, sizeof(score4) - 1, 1, fp);
fread(name5, sizeof(name5) - 1, 1, fp);
fread(score5, sizeof(score5) - 1, 1, fp);
fclose(fp);
}
//draw data read from file on screen
HRESULT CMyApplication::ProcessNextFrame(CGapiSurface& surface, DWORD dwFlags)
{
surface.DrawText(160, 118, name1, &m_font, GDDRAWTEXT_RIGHT, NULL, NULL);
surface.DrawText(222, 118, score1, &m_font, GDDRAWTEXT_RIGHT, NULL, NULL);
surface.DrawText(160, 140, name2, &m_font, GDDRAWTEXT_RIGHT, NULL, NULL);
surface.DrawText(222, 140, score2, &m_font, GDDRAWTEXT_RIGHT, NULL, NULL);
surface.DrawText(160, 162, name3, &m_font, GDDRAWTEXT_RIGHT, NULL, NULL);
surface.DrawText(222, 162, score3, &m_font, GDDRAWTEXT_RIGHT, NULL, NULL);
surface.DrawText(160, 184, name4, &m_font, GDDRAWTEXT_RIGHT, NULL, NULL);
surface.DrawText(222, 184, score4, &m_font, GDDRAWTEXT_RIGHT, NULL, NULL);
surface.DrawText(160, 206, name5, &m_font, GDDRAWTEXT_RIGHT, NULL, NULL);
surface.DrawText(222, 206, score5, &m_font, GDDRAWTEXT_RIGHT, NULL, NULL);
return S_OK;
}
In the first "name" example, the data displayed by DrawText on my PPC would only be "NM" instead of "NAME". On the PC however, it works great.
I called CreateScoresFile() then ReadScoresFromFile() upon the game's initialization. Is there something wrong with my code? Help please? :-)