WEBVTT

00:00.480 --> 00:04.520
Else take a look at input for courses.

00:04.650 --> 00:13.620
So there's a similar function to our C in that can get one character from the input and Bouverie seen

00:13.620 --> 00:14.030
it.

00:14.050 --> 00:15.510
It's called.

00:15.770 --> 00:21.850
You get character get CH S.H. like this.

00:21.850 --> 00:32.530
So this will actually read one character from the input.

00:32.600 --> 00:40.370
So let's take a look at how to use this example.

00:40.490 --> 00:59.360
So say we had Julian Colquitt set false initially in the character store while not quit.

00:59.490 --> 01:15.660
You will set the input to this good character and if the input is a cue then we'll set quit to be false.

01:17.060 --> 01:18.160
Or true sir.

01:23.590 --> 01:24.740
In it.

01:24.880 --> 01:28.800
So it's kind of read this and see what happens.

01:29.580 --> 01:44.540
So if I type in here a c whatever and then I finally typed Q It will actually exit the curses window.

01:44.610 --> 01:46.830
And that's kind of what is this.

01:47.100 --> 01:52.170
And when does it kind of returns the terminal to its original state.

01:52.190 --> 01:53.790
Right.

01:54.390 --> 01:56.170
So it actually got it.

01:56.340 --> 02:05.470
But if you noticed it runs more time for you if we type something we'll see the characters here.

02:05.510 --> 02:11.950
I'm just typing randomly and we see a character who's kind of appearing on the screen.

02:12.020 --> 02:16.160
Well in our interactive games you don't want that to really happen.

02:16.160 --> 02:28.470
So how to make it so that when you type something it doesn't appear we can say no echo like this.

02:28.480 --> 02:38.170
So now if you run right into it again I'm typing can't see what I'm typing stuff but it's not working

02:38.640 --> 02:42.710
ok or it's not appear on the screen.

02:42.720 --> 02:48.150
But still if I press Q it'll it.

02:48.560 --> 02:56.690
So that's kind of nice to get rid of the echo of the characters you type.

02:56.690 --> 03:05.780
There's one more important thing and that is we've noticed that this character will block and even kind

03:05.780 --> 03:07.410
of prove it to you.

03:07.520 --> 03:20.810
I'll say M.V. all it's fresh here in the French w

03:24.580 --> 03:26.720
I'll just print it

03:29.140 --> 03:32.260
20:20.

03:32.340 --> 03:33.810
Hello everyone.

03:36.770 --> 03:37.660
OK.

03:37.990 --> 03:46.690
So if I run this you'll see that it never printed the M.V. print function.

03:46.710 --> 03:47.740
Hello everyone.

03:47.930 --> 03:48.590
OK.

03:48.960 --> 03:51.370
So it never actually printed this.

03:51.780 --> 03:55.730
So that means that this character is actually blocking.

03:55.740 --> 04:02.590
So if I type something it will actually show the hello everyone that we had for.

04:03.100 --> 04:10.900
You type again and again it just keep showing that which And actually exit OK.

04:11.090 --> 04:21.200
So that really means that this character kind of blocks the well everything's kind of blocked until

04:21.380 --> 04:23.580
good character works.

04:23.610 --> 04:25.990
So we can actually fix that.

04:27.730 --> 04:32.620
And we could say you know the way

04:35.730 --> 04:48.340
and no delay takes the windows no s d c r and then whether or not we want to do this or no delay.

04:48.360 --> 04:50.840
So it's true.

04:50.970 --> 04:52.400
So don't want delays.

04:52.500 --> 05:10.350
True means no delay and that will actually cause good character to not block any so actually.

05:10.630 --> 05:17.740
So you can actually still input but it kind of it'll check to see if you actually got any input if you

05:17.740 --> 05:23.830
didn't it'll kind of just keep going and then loop back and then again backtrack again.

05:24.120 --> 05:28.370
OK so let's see that kind of work.

05:28.370 --> 05:32.780
So now we should see if we run it we should actually see Hello everyone being printed.

05:34.060 --> 05:43.110
Stu so it actually printed it's not waiting for us to input it character anymore.

05:43.120 --> 05:51.080
OK so that's going to be very useful for our interactive games.

05:51.100 --> 06:00.860
So if I type something that happens type quit it still works it quits the way one nerves.

06:00.860 --> 06:14.810
One last thing we look at here and that is if you notice we can't actually use the arrow keys for input

06:14.930 --> 06:15.660
right now.

06:16.490 --> 06:20.110
And that could be useful for our games.

06:20.180 --> 06:23.180
A lot of these Iraqis.

06:23.420 --> 06:29.600
So you can actually fix that by seeing pad

06:33.160 --> 06:38.230
baps in using STDs are insane.

06:38.230 --> 06:39.070
True.

06:41.010 --> 06:44.910
And this war actually enables

06:47.160 --> 06:51.200
keyboard or arrow keys.

06:56.360 --> 07:05.210
So there's one other problem though and that is if this good character actually doesn't return characters

07:05.210 --> 07:06.330
or turns integer.

07:06.330 --> 07:09.990
So we should be using it here.

07:11.140 --> 07:13.400
And you actually compare.

07:13.420 --> 07:18.450
This is actually like I think I've mentioned this much earlier.

07:18.500 --> 07:20.600
We were talking about characters.

07:20.620 --> 07:22.120
This is actually an integer.

07:22.170 --> 07:25.600
It's quote Q here.

07:26.230 --> 07:32.050
So we should be using integers for input character.

07:32.260 --> 07:42.280
And now let's actually use the arrow keys so the arrow keys are actually defined by this key and underscore

07:43.090 --> 07:44.630
down here.

07:44.880 --> 07:50.150
There's also key up key like

07:53.110 --> 07:56.980
in key right.

07:57.510 --> 08:01.410
So we'll probably want to use that for our games.

08:01.710 --> 08:03.810
So now if I run this

08:08.730 --> 08:13.270
and if I press the arrow key down it'll actually quit.

08:14.430 --> 08:18.850
So that's kind of how to enable the.

08:18.950 --> 08:23.320
So that's kind of it for inputs in the next lecture.

08:23.320 --> 08:33.000
I want to go over a complete example and show you how to really how to put it all together into something

08:33.210 --> 08:38.950
that we can base our games off of you in the next lecture.
