newbie needs help
i want to get the players name and then put it in the highscores, ive done the reading, writing and sorting of the highscores file. The bit im having problems with is when i try to input a name it doesnt work,im using c++ and directx and gdi to draw the text. please help.
"I have realised that maths can explain everything. How it can is unimportant, I want to know why." -Me
char playersName[20];
HDC xdc; // the working dc
// get the dc from secondary back buffer
lpddsback->GetDC(&xdc);
// set the colors for the text up
SetTextColor(xdc, RGB(0,0,255));
// set background mode to transparent so black isn''t copied
SetBkMode(xdc, TRANSPARENT);
int length = sprintf(buffer,"Enter Name: ");
TextOut(xdc,150,200,buffer,length);
// release the dc
lpddsback->ReleaseDC(xdc);
// get the dc from secondary back buffer
lddsback->GetDC(&xdc);
// set the colors for the text up
SetTextColor(xdc, RGB(0,0,255));
// set background mode to transparent so black isn''t copied
SetBkMode(xdc, TRANSPARENT);
length = scanf(" %s ", playersName);
TextOut(xdc,300,200,playersName,length);
// release the dc
lpddsback->ReleaseDC(xdc);
HDC xdc; // the working dc
// get the dc from secondary back buffer
lpddsback->GetDC(&xdc);
// set the colors for the text up
SetTextColor(xdc, RGB(0,0,255));
// set background mode to transparent so black isn''t copied
SetBkMode(xdc, TRANSPARENT);
int length = sprintf(buffer,"Enter Name: ");
TextOut(xdc,150,200,buffer,length);
// release the dc
lpddsback->ReleaseDC(xdc);
// get the dc from secondary back buffer
lddsback->GetDC(&xdc);
// set the colors for the text up
SetTextColor(xdc, RGB(0,0,255));
// set background mode to transparent so black isn''t copied
SetBkMode(xdc, TRANSPARENT);
length = scanf(" %s ", playersName);
TextOut(xdc,300,200,playersName,length);
// release the dc
lpddsback->ReleaseDC(xdc);
"I have realised that maths can explain everything. How it can is unimportant, I want to know why." -Me
The function scanf() is for console input (like DOS).
What you need to do is set up a processing routine for the WM_CHAR windows message, use a state machine.
What you need to do is set up a processing routine for the WM_CHAR windows message, use a state machine.
Yeah, kieren_j is right. Remember, you''re in Windows now. There''s really no way to handle inputting characters like in DOS.
Here''s a tip. Just because you are using DirectInput doesn''t mean that you have to do everything with DirectInput. For this type of keyboard interaction, the regular Windows message pump is the best way to go.
Here''s a tip. Just because you are using DirectInput doesn''t mean that you have to do everything with DirectInput. For this type of keyboard interaction, the regular Windows message pump is the best way to go.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement