This topic is now archived and is closed to further replies.

Krypto night

escape characters

Recommended Posts

I might be wrong on this

but at the top in your defines add,

#define KEY_DOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)

Then in your main game loop you can add something such as,

// In your case I think you'd replace VK_ESCAPE with
// 51 which is the hexadecimal value for the Q key

PostMessage(main_window_handle, WM_DESTROY,0,0);

As for CTRL-Q? I have no idea

[edited by - _vizual_ on January 24, 2004 3:48:41 PM]

Share this post

Link to post
Share on other sites
the only way i can think of is each time you ask for input, allow a "quit" input. For example, if you''re asking for a choice of 0-9, you accept all input 0-9 as well as q, where if the input''s q you quit.

If, however, you''re for example calculating a billion numbers and you want to allow the user to quit inbetween you could setup intervals (like every 10 million calculatoins) at which point you ask the user whether or not he wishes to quit. Also, it''d be a good idea to insert a timer so that after x seconds it goes on (if no input was given).

As for an example, here''s my (rather messy) input loop from my console game:
if(i>=0&&i<=6){ /* needs to be changed if menu is expanded! */
}else if(i+48==''x''||i+48==''X''||i+48==''q''||i+48==''Q''){
std::cout<<"Are you sure you wish to quit? (Y/N)"<<std::endl;

in case you''re wondering, getint() is just a getch() + 48.

Share this post

Link to post
Share on other sites