C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem in C++ Program

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
~Wizard~
Guest





PostPosted: Thu Jun 29, 2006 4:27 pm    Post subject: Problem in C++ Program Reply with quote



Assalam u alaikum
well I'm Qasim going BCS(hons).
There are vocation of Summer Semester so i started to creat programs,
but ther is an obstical to actieve my program, kingly help me out.


I must not discuss my whole problem, i must tell u the specific
problem.

See
Take a situation that the program is printing "Qasim" on the monitor,
it's an infinite loop, i want that when u press any button it will stop
printing "Qasim". and just say that you have presseng that specific
button.

Kindly tell me how i could interfare durring the execution of program.

Actually I'm using this logic in the prepration of a game named "Pack
man". that is, if i pressed the up arrow key button the object eater
goes on moving and when i press left key, i'll start moving to the left
till the new button is not pressed.

Waitting for your help.


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Francis Glassborow
Guest





PostPosted: Sat Jul 01, 2006 2:23 am    Post subject: Re: Problem in C++ Program Reply with quote



In article <1151520764.346676.172940 (AT) p79g2000cwp (DOT) googlegroups.com>,
~Wizard~ <kingkazmi1988 (AT) gmail (DOT) com> writes
Quote:
Actually I'm using this logic in the prepration of a game named "Pack
man". that is, if i pressed the up arrow key button the object eater
goes on moving and when i press left key, i'll start moving to the left
till the new button is not pressed.

C++ does not support a raw keyboard read, not least because not every
system has such a thing as a keyboard. However there are platform
specific libraries that provide such support.

One example of such a library is the Playpen library that accompanies my
book (and that library supports both MS Windows platforms and X-Windows
supporting platforms such as Linux and MacOS X) The relevant source code
is available from the books' website.


--
Francis Glassborow ACCU
Author of 'You Can Do It!' and "You Can Program in C++"
see http://www.spellen.org/youcandoit
For project ideas and contributions:
http://www.spellen.org/youcandoit/projects


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Frederick Gotham
Guest





PostPosted: Sat Jul 01, 2006 2:25 am    Post subject: Re: Problem in C++ Program Reply with quote



~Wizard~ posted:

Quote:
Assalam u alaikum


Please keep the newsgroup religion-free.


Quote:
well I'm Qasim going BCS(hons).
There are vocation of Summer Semester so i started to creat programs,
but ther is an obstical to actieve my program, kingly help me out.


I must not discuss my whole problem, i must tell u the specific
problem.

See
Take a situation that the program is printing "Qasim" on the monitor,
it's an infinite loop, i want that when u press any button it will stop
printing "Qasim". and just say that you have presseng that specific
button.

Kindly tell me how i could interfare durring the execution of program.

Actually I'm using this logic in the prepration of a game named "Pack
man". that is, if i pressed the up arrow key button the object eater
goes on moving and when i press left key, i'll start moving to the left
till the new button is not pressed.


Can't be done with Standard C++.

Either use threads, or call some sort of system-specific API function which
tells you if there's a key being held down:

while ( !KeyIsDown() )
{
std::cout << "Qasim";
}


Go to a newsgroup specific to your platform.



--
Frederick Gotham

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Carl Barron
Guest





PostPosted: Sat Jul 01, 2006 6:15 am    Post subject: Re: Problem in C++ Program Reply with quote

In article <1151520764.346676.172940 (AT) p79g2000cwp (DOT) googlegroups.com>,
~Wizard~ <kingkazmi1988 (AT) gmail (DOT) com> wrote:

Quote:
Assalam u alaikum
well I'm Qasim going BCS(hons).
There are vocation of Summer Semester so i started to creat programs,
but ther is an obstical to actieve my program, kingly help me out.


I must not discuss my whole problem, i must tell u the specific
problem.

See
Take a situation that the program is printing "Qasim" on the monitor,
it's an infinite loop, i want that when u press any button it will stop
printing "Qasim". and just say that you have presseng that specific
button.

Kindly tell me how i could interfare durring the execution of program.

Actually I'm using this logic in the prepration of a game named "Pack
man". that is, if i pressed the up arrow key button the object eater
goes on moving and when i press left key, i'll start moving to the left
till the new button is not pressed.

Waitting for your help.

Ask in an OS specific newsgroup, as there is no standard way to to

determine if arrow keys are input to std::cin, and infact most
std::cins will buffer until a return is pressed, there is no standard
C++ or C function/class that gets any keycode from the keyboard and
returns when one key is pressed.

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
kanze
Guest





PostPosted: Mon Jul 03, 2006 4:14 pm    Post subject: Re: Problem in C++ Program Reply with quote

Francis Glassborow wrote:
Quote:
In article <1151520764.346676.172940 (AT) p79g2000cwp (DOT) googlegroups.com>,
~Wizard~ <kingkazmi1988 (AT) gmail (DOT) com> writes
Actually I'm using this logic in the prepration of a game
named "Pack man". that is, if i pressed the up arrow key
button the object eater goes on moving and when i press
left key, i'll start moving to the left till the new button
is not pressed.

C++ does not support a raw keyboard read, not least because
not every system has such a thing as a keyboard. However there
are platform specific libraries that provide such support.

I think the reasons are more complicated than that. After all,
C++ does support the function time(), although not all systems
have a real time clock.

Quote:
One example of such a library is the Playpen library that
accompanies my book (and that library supports both MS Windows
platforms and X-Windows supporting platforms such as Linux and
MacOS X) The relevant source code is available from the books'
website.

I think the quasi-standard for this sort of thing is (n)curses,
although that might be more complex than what the original
poster is looking for. There are a number of different
implementations, both as freeware and commerical products.

--
James Kanze GABI Software
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.