0

As an example:

Console.ReadLine();
Console.WriteLine("What are you waiting for?");

How would I get anything after Console.ReadLine(); to execute before an input is received?

To give background/ be more specific I've been trying to make a breakout game in command-line and I can't figure out how to allow the ball to process without the paddle moving. So if there is some specific way to allow key inputs while other things are processing that would work wonders too.

  • https://msdn.microsoft.com/en-us/library/aa645740%28v=vs.71%29.aspx –  Feb 25 '15 at 03:43
  • Oh awesome thank you, I'm having trouble know all the words for programming things right now. I'm finally taking a good class on programming but we're not too deep into it. – Garrett Hale Feb 25 '15 at 03:46
  • 5
    Threads are not the right solution. Use a `while()` loop and https://msdn.microsoft.com/en-us/library/system.console.keyavailable – SLaks Feb 25 '15 at 03:48
  • What you're trying to implement is the central game loop of your game, which is explained really well [here](http://stackoverflow.com/a/17440807/1726343). – Asad Saeeduddin Feb 25 '15 at 04:42
  • I just realized I'm probably doing it all wrong, I'm not assuming no buttons pressed in fact I'm forcing the computer to wait for a button press. Thanks for all these suggestions really got me out of a 2 year tunnel vision! – Garrett Hale Feb 25 '15 at 04:53
  • @SLaks: Well, if he's creating a game, he may as well start reading up on threading anyway. ;) –  Feb 25 '15 at 11:36
  • I'll definitely keep threading in mind, seems a bit complicated right now but I understand it's usefulness. – Garrett Hale Feb 25 '15 at 23:09

1 Answers1

0

I am not quite clear here, but is this what you desire my friend...

Console.ReadKey(true);
Console.WriteLine("Do Something");
Console.ReadKey();
Ozesh
  • 6,536
  • 1
  • 25
  • 23