Key Reading

Aug 27, 2015 at 3:00am
closed account (38qG1hU5)
I know I just posted a newby post but I have another one. I have bought c++ books and searched the web but still can't figure out how to make the code read when a key is pressed to the activate the code in the statement. I know in c# its

if(input.getKeyDown(1)){
kshadhgaidgbkajgdyajib
}

Please help the new guy on the block.
Aug 27, 2015 at 3:01am
What graphics/GUI library are you using? In SFML or Qt you should listen for the key down or key up events.

If you're trying to use the console, please read this first:
http://www.cplusplus.com/articles/G13hAqkS/
Last edited on Aug 27, 2015 at 3:02am
Aug 27, 2015 at 3:04am
closed account (38qG1hU5)
@LB I'm not using GUI as I'm just trying to make a simple console game to further my experience and knowledge in c++. nothing huge just something to do.
Aug 27, 2015 at 3:19am
Please read the article I linked. Making a console game will not further your experience, it will teach you things you will need to unlearn.
Aug 27, 2015 at 3:43am
I disagree. The only difference in a console game is the display medium and handling input in the event loop properly -- which is actually a bit more difficult in a console app than a GUI one.

That said, I agree that it is worth your time to play around with SDL or SFML instead and go straight to a GUI game. They're tons easier and much more fun.
Aug 27, 2015 at 5:06am
closed account (48T7M4Gy)
http://www.cplusplus.com/forum/beginner/25477/

http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1048384015&id=1043284392
Last edited on Aug 27, 2015 at 5:10am
Aug 27, 2015 at 11:59am
Um... why the hell have LB's and Duoas's posts been reported?
Aug 27, 2015 at 12:46pm
It's not just this tread. I think some nob is reporting *all* their posts.
Aug 27, 2015 at 1:27pm
Oh, look, they're doing it to me now.

Some people are easily amused, I guess.
Topic archived. No new replies allowed.