﻿1
00:00:04,470 --> 00:00:05,550
‫Hello and welcome.

2
00:00:05,550 --> 00:00:09,960
‫In this lecture, we're going to be learning about comments, these things in Green and Visual Studio

3
00:00:09,960 --> 00:00:17,550
‫code and how we can use them to write pseudo code to essentially be a note to ourselves on how we want

4
00:00:17,550 --> 00:00:18,930
‫to implement something.

5
00:00:18,930 --> 00:00:21,420
‫Let's dive in and learn about these concepts.

6
00:00:21,960 --> 00:00:24,650
‫So what is pseudocode?

7
00:00:24,660 --> 00:00:25,650
‫Pseudocode?

8
00:00:26,250 --> 00:00:32,520
‫This is the dictionary definition is a plain language description of the steps that we're going to be

9
00:00:32,520 --> 00:00:33,660
‫using in an algorithm.

10
00:00:33,660 --> 00:00:41,040
‫So I want to write a plain language description of what we're planning to do to make this moving platform

11
00:00:41,040 --> 00:00:43,320
‫go backwards and forwards.

12
00:00:43,590 --> 00:00:49,200
‫Now, to do that, I could write out on a piece of paper, but I can actually write it into my code

13
00:00:49,200 --> 00:00:51,930
‫without having to worry about making sure it's correct.

14
00:00:51,930 --> 00:00:55,230
‫C++ and that is the whole point of pseudocode.

15
00:00:55,230 --> 00:01:00,600
‫But to do that, we need to know one more piece of the puzzle, which is what is a comment?

16
00:01:00,600 --> 00:01:04,680
‫A comment is code that is ignored by the compiler.

17
00:01:04,680 --> 00:01:11,070
‫So it's a way of writing into our text file stuff for humans to read that the compiler will then ignore.

18
00:01:11,070 --> 00:01:13,320
‫And we can just use that to write pseudocode.

19
00:01:13,320 --> 00:01:19,590
‫We can use it to write notes to each other as programmers and to clarify what it is we're trying to

20
00:01:19,590 --> 00:01:21,210
‫do in a piece of code.

21
00:01:21,210 --> 00:01:24,660
‫So let's have a look at doing this over in the moving platform.

22
00:01:24,660 --> 00:01:26,940
‫Keep in tick.

23
00:01:26,940 --> 00:01:32,910
‫Now a comment is basically any line that starts with a double forward slash.

24
00:01:32,910 --> 00:01:38,280
‫You can see that in Visual Studio code, this automatically gets coloured in in green and we can see

25
00:01:38,280 --> 00:01:45,780
‫examples of these green lines elsewhere in the C++ file, you can see it says fill out a copyright notice.

26
00:01:45,780 --> 00:01:51,300
‫It says sets default values called well, the game starts or when spawn called every frame.

27
00:01:51,300 --> 00:01:56,430
‫So actually these comments are already helping us understand what's going on in this C++ file.

28
00:01:56,430 --> 00:02:01,470
‫And now we understand that these lines have no particular meaning to the compiler.

29
00:02:01,470 --> 00:02:07,110
‫In fact, as far as the compiler is concerned, one of the first things it does is just remove all comments

30
00:02:07,110 --> 00:02:09,390
‫from the file because it just doesn't need them.

31
00:02:09,390 --> 00:02:13,620
‫It ignores them when it's dealing with them and turning them into binary.

32
00:02:13,950 --> 00:02:21,420
‫So what we want to do is write out a little plan for how we are going to make our platform move backwards

33
00:02:21,420 --> 00:02:22,860
‫and forwards.

34
00:02:23,010 --> 00:02:30,330
‫So the first thing we're going to do is update the location of our platform.

35
00:02:30,330 --> 00:02:36,570
‫So move the platform forwards, so move platform forwards.

36
00:02:36,570 --> 00:02:37,710
‫And how are we going to do that?

37
00:02:37,710 --> 00:02:42,330
‫Well, I'm going to use some indentation to show that this is how we're going to be moving the platform

38
00:02:42,330 --> 00:02:43,170
‫forwards.

39
00:02:43,170 --> 00:02:46,020
‫We're going to get its current location.

40
00:02:46,020 --> 00:02:51,240
‫Then we are going to add a vector to that current location.

41
00:02:51,240 --> 00:02:56,490
‫And that might be a good place for us to use a local variable because we don't want that intermediate

42
00:02:56,490 --> 00:03:00,150
‫result to be remembered at the class level.

43
00:03:00,840 --> 00:03:04,080
‫Then we're going to set that location.

44
00:03:04,080 --> 00:03:07,260
‫But what about sending the platform back?

45
00:03:07,260 --> 00:03:09,180
‫Well, let's have another comment here.

46
00:03:09,180 --> 00:03:18,930
‫Just at the indentation level below, we're going to send platform back if gone too far.

47
00:03:19,320 --> 00:03:24,450
‫So what we're going to have to do there is check how far we've moved, first of all.

48
00:03:24,450 --> 00:03:29,520
‫And if we've gone too far, we're going to reverse the direction of motion.

49
00:03:29,520 --> 00:03:36,570
‫So reverse direction of motion if gone too far.

50
00:03:36,570 --> 00:03:45,510
‫So here we have a very basic pseudocode description of what we're planning to do in the upcoming lectures.

51
00:03:45,510 --> 00:03:48,570
‫Please go ahead and add this to your own C++ file.

52
00:03:48,570 --> 00:03:51,180
‫You can use your own words to describe each step.

53
00:03:51,180 --> 00:03:53,580
‫This is just my interpretation of it.

54
00:03:53,580 --> 00:03:59,340
‫And because this isn't used by the compiler at all, it doesn't matter whether you have a typo or anything

55
00:03:59,340 --> 00:03:59,670
‫like that.

56
00:03:59,670 --> 00:04:04,980
‫The most important thing is that you just start each line with a double forward slash.

57
00:04:05,010 --> 00:04:07,230
‫Okay, I will see you in the next lecture.

