Physics Forums

Physics Forums (http://www.physicsforums.com/index.php)
-   Computing & Technology (http://www.physicsforums.com/forumdisplay.php?f=188)
-   -   Program to respond to commands in C++ (http://www.physicsforums.com/showthread.php?t=89707)

JamesU Sep18-05 10:26 PM

program to respond to commands in C++
 
I want to know how I can get my program to respond to commands in C++. for instance, when someone presses the up, down, or side arrows; or when somebody clicks something.

franznietzsche Sep19-05 12:05 AM

Quote:

Quote by yomamma
I want to know how I can get my program to respond to commands in C++. for instance, when someone presses the up, down, or side arrows; or when somebody clicks something.

That's fairly complicated. You have to have some sort of event handling subroutines to respond to various keycodes(as I understand it. I've never needed such a thing, and so have never bothered to learn how). Try googling for event handling in C++ or some such thing.

dduardo Sep19-05 05:31 AM

SDL:

http://www.libsdl.org/index.php

JamesU Sep19-05 06:34 PM

well, I'm trying to learn how to move something (like a basic game) but how would I make the computer respond to the arrow key. woul I use something like?:

arrokey

cin>>arrowkey>>\n

if (arrowkey==uparrow)
{
}

My nect question is about what I would put inbetween the curly braces. how could I get something to change position?

and I don't really want to download any pregrams, just write it out.

dduardo Sep19-05 07:21 PM

Your thinking on too simple of a level.

You need to do something like this:

http://www.libsdl.org/cgi/docwiki.cgi/Event_20Examples

This example is actual very simple. If you wanted to be more sophiscated you would have your input handled by another thread.

saltydog Sep19-05 07:54 PM

Quote:

Quote by yomamma
I want to know how I can get my program to respond to commands in C++. for instance, when someone presses the up, down, or side arrows; or when somebody clicks something.

In the past, I've used quite a bit the Microsoft Developer Studio Visual C++ and the Microsoft Foundation Class Library: Can create a working windows program in a few key strokes then just add to it. Simple matter then to add event handlers to respond to keystrokes. Know about "Scribble"? That's the tutorial to get you going on Windows programming. Of course I suppose you need to already know quite a bit about Windows programming to do the tutorial. Also, Developer Studio has a great debugger.


All times are GMT -5. The time now is 08:40 AM.

Powered by vBulletin Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2014 Physics Forums