Well got a bit more done. So far the attached exe will do this.
1) Shows a catergory view before game starts. so far only one option.
2) Loads in a text resource file. Picks a random line, and puts the line to the screen.
3) Lets you make guesses with the letters.
What it doesn't do yet.
1) It doesn't penalise you for a wrong answer.
2) It doesn't end the round when you get the whole word.
Ok I have another thing to work out. I need to add a fixed width font, but here is the problem. So far all my data is inside the exe. eg, pictures and text. Now I can load in a font using this line
AddFontResourceEx(L"data/mt.ttf",FR_PRIVATE,0);
The font doesn't have to be installed either, and it will work, but I am wondering if I can put this font in my resource file and somehow load it from there.
The reason for this is that I can't just guess that the user will have the font I want to use.
So I am not sure if this is possible.
The reason I want to use fixed width is because the dash spacing on some letters is narrower than other letters, so when you guess a letter right the spacing changes, if you know what I mean.
I might come up with another solution soon.
BTW for those who wants to know. Below is my final solution to loading a textfile to my vector strings from a resource file.
Code: Select all
void Dict::loadText(int textFile)
{
dictionary.clear();
HRSRC hRes = FindResource(NULL, MAKEINTRESOURCE(textFile), L"TXT"); // <- make sure it's the type you specify it to be...
if (hRes == 0)
{
MessageBox(NULL, LPWSTR(L"Text Not Loaded"), TEXT("TEXT"), NULL);
}
HGLOBAL hMem = LoadResource(NULL, hRes);
DWORD size = SizeofResource(NULL, hRes);
char* resText = (char*)LockResource(hMem);
char* text = (char*)malloc(size + 1);
memcpy(text, resText, size);
text[size] = 0;
void* lockedRes = LockResource(hMem);
char buffer[100];
int buffercount=0;
for (int g=0; g<size; g++)
{
buffer[buffercount]=((char*)lockedRes)[g];
buffercount++;
if(((char*)lockedRes)[g]=='\n')
{
dictionary.push_back(string(buffer,buffercount-2));
buffercount=0;
}
}
FreeResource(hMem);
}