Jump to content
  • Advertisement

Archived

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

randomDecay

int main(int argc, char * argv[]) (command line args)

This topic is 6041 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am working on a text game where the player enters commands in a console window. I've seen other games that allow the user to press the UP ARROW key to display the last 10 or so messages (1 at a time. I know the formal parameters to main are int argc, char *argv[], but how would I be able to do this in my game? Thanks much. Edited by - randomDecay on February 3, 2002 1:20:11 PM

Share this post


Link to post
Share on other sites
Advertisement
I don''t think the main() parameters have anything to do with this. I''m guessing you mean you''re making your own console, not implementing the game through multiple executions of the program from the command line, in which case it would be the shell''s job for the "UP and DOWN" arrows.

(http://www.ironfroggy.com/)
(http://www.ironfroggy.com/pinch)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
not sure but i think you could use GetASyncKeyState() in windows.h to get the current status of any key but i can''t remember the arguments.

Share this post


Link to post
Share on other sites
GetAsyncKeyState(VK_UP);

A better bet might be to use GetKeyboardState() to get the status of all 256 virtual keys and then handle them individually (this way you don''t have a bunch of GetAsyncKeyState() calls, one for each key you wish to respond to).

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!

Share this post


Link to post
Share on other sites
try:

game loop ()
{
MSG msg;
if(PeekMessage(&msg,0,0,0,PM_REMOVE))
{
TranslateMessage(&msg);

if(msg.message == WM_KEYDOWN)
{
if(msg.wParam == VK_UP)
//do stuff
}
else if(msg.message == WM_QUIT)
// quit
if(msg.message == WM_CHAR)
{
if(msg.wParam == 'A')
//do stuff
}
}
}

Edited by - AlexM on February 3, 2002 3:00:05 PM

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!