1 00:00:00,810 --> 00:00:05,020 Launch the work space on this page and then let's talk about programming. 2 00:00:05,020 --> 00:00:07,980 But before we get started, take a look at all the words and 3 00:00:07,980 --> 00:00:11,690 symbols in front of you, this is our program. 4 00:00:11,690 --> 00:00:15,090 Now, if you're beginning to panic because it all looks like a foreign language and 5 00:00:15,090 --> 00:00:18,460 you're feeling like maybe this is too difficult for you. 6 00:00:18,460 --> 00:00:21,140 Don't worry, as I mentioned in the last video, 7 00:00:21,140 --> 00:00:25,700 you don't need to understand everything you see here to have fun in this course. 8 00:00:25,700 --> 00:00:29,220 In fact, when we're done you still won't understand everything here. 9 00:00:29,220 --> 00:00:32,450 This course is intended to just give you a taste of programming. 10 00:00:32,450 --> 00:00:35,990 All you need to do is follow along, experiment a little, and have fun. 11 00:00:37,310 --> 00:00:38,790 You can preview the webpage, 12 00:00:38,790 --> 00:00:43,930 this index.html file, by clicking the preview button. 13 00:00:45,295 --> 00:00:48,169 Here's the current state of our game, the score is zero, 14 00:00:48,169 --> 00:00:50,761 there's one coin, one platform, and one player. 15 00:00:50,761 --> 00:00:54,717 The game.js file contains the programming that makes our current game work 16 00:00:54,717 --> 00:00:56,509 It’s written in JavaScript, but 17 00:00:56,509 --> 00:01:00,760 there are literally hundreds of different programming languages. 18 00:01:00,760 --> 00:01:01,940 All programing languages, 19 00:01:01,940 --> 00:01:06,940 however, share some basic features which I'll introduce to you in this course. 20 00:01:06,940 --> 00:01:11,870 Syntax is the vocabulary, punctuation and grammar of a programming language. 21 00:01:11,870 --> 00:01:15,696 The syntax includes key words which are the languages vocabulary. 22 00:01:15,696 --> 00:01:19,645 For example, here var, function, 23 00:01:24,268 --> 00:01:27,760 And if are keywords in the JavaScript language. 24 00:01:27,760 --> 00:01:31,860 They all have special meanings, and we'll look at each of these in this course. 25 00:01:33,270 --> 00:01:36,450 Values, values are the data in your program. 26 00:01:36,450 --> 00:01:41,100 They could be numbers, like 375 Or 300 here. 27 00:01:41,100 --> 00:01:46,420 Or they could be letters inside of quote marks, like 'coin'. 28 00:01:46,420 --> 00:01:50,810 This is called a string value, because it's a set of letters strung together. 29 00:01:50,810 --> 00:01:53,745 There are many different types of values. 30 00:01:53,745 --> 00:01:58,565 Variables, variables hold values, they're like boxes that you put a value into. 31 00:01:58,565 --> 00:02:01,635 You can look inside the box to see the value it contains, and 32 00:02:01,635 --> 00:02:04,535 even replace the current value with a new value. 33 00:02:04,535 --> 00:02:06,205 For example, in the last video, 34 00:02:06,205 --> 00:02:09,745 you saw that when a player collected a coin, the score changed. 35 00:02:10,850 --> 00:02:15,260 The current score is a variable or box in our game. 36 00:02:15,260 --> 00:02:19,000 A program uses these boxes to pass information around and 37 00:02:19,000 --> 00:02:22,270 control what the program does and how it works. 38 00:02:22,270 --> 00:02:26,200 The var keyword you see here, in fact, is a JavaScript keyword, 39 00:02:26,200 --> 00:02:31,180 part of the syntax that creates a variable named current score. 40 00:02:31,180 --> 00:02:35,110 The equal sign, puts a value into a variable. 41 00:02:35,110 --> 00:02:39,820 So this code stores the value zero into the variable named, current score. 42 00:02:41,460 --> 00:02:46,316 Change the score to 5000, 43 00:02:46,316 --> 00:02:51,212 Save the file, And preview it. 44 00:02:53,444 --> 00:02:55,510 The score's now 5000. 45 00:02:55,510 --> 00:02:59,160 Changing the value in the variable changes the game. 46 00:02:59,160 --> 00:03:00,560 Hey let's look at another example. 47 00:03:00,560 --> 00:03:03,730 Let's go back to work space and set the score back to zero. 48 00:03:05,450 --> 00:03:11,020 Notice this other variable named won, as in I won the game. 49 00:03:11,020 --> 00:03:15,100 It's set to false, which is another type of value, called a boolean. 50 00:03:15,100 --> 00:03:16,290 Let's change it to true. 51 00:03:19,735 --> 00:03:20,790 Save the file. 52 00:03:23,793 --> 00:03:24,293 And preview it. 53 00:03:26,197 --> 00:03:27,910 Look, you won the game! 54 00:03:27,910 --> 00:03:30,440 Okay, that doesn't make for a very fun game, but 55 00:03:30,440 --> 00:03:33,738 you can see how values affect how programs work. 56 00:03:33,738 --> 00:03:39,220 Changing this won variable to true changes the information of our program and 57 00:03:39,220 --> 00:03:41,580 causes it to end the game. 58 00:03:41,580 --> 00:03:45,490 Working with data, values, and variables is one of the most common features you'll 59 00:03:45,490 --> 00:03:47,670 use in any programming language. 60 00:03:47,670 --> 00:03:50,360 Let's set the value back to false and save the file. 61 00:03:55,607 --> 00:03:59,141 Another feature of programming languages, and programming in general, 62 00:03:59,141 --> 00:04:00,890 are control structures. 63 00:04:00,890 --> 00:04:04,750 Control structures control the flow of the program, what happens and 64 00:04:04,750 --> 00:04:06,730 when it happens in a program. 65 00:04:06,730 --> 00:04:12,599 For example, in our game, if we grab a coin, the score changes. 66 00:04:13,730 --> 00:04:17,850 Likewise, if the value of the variable won is set to false, the player 67 00:04:17,850 --> 00:04:21,380 can run around the screen, jumping onto platforms and collecting coins. 68 00:04:22,390 --> 00:04:27,460 However, when the value of one is true, then a message appears on the screen and 69 00:04:27,460 --> 00:04:28,190 the game is over. 70 00:04:29,830 --> 00:04:33,000 These are both examples of a type of control structure called 71 00:04:33,000 --> 00:04:34,760 a conditional statement. 72 00:04:34,760 --> 00:04:36,700 There are other types of control structures but 73 00:04:36,700 --> 00:04:40,040 the important thing to keep in mind is that we can control the flow or 74 00:04:40,040 --> 00:04:43,820 the steps a program follows as the program runs. 75 00:04:43,820 --> 00:04:48,420 This is one of the things that makes computer programs flexible and useful. 76 00:04:48,420 --> 00:04:51,940 Finally there are commands which are often called functions. 77 00:04:51,940 --> 00:04:53,950 Functions are the heart of a program. 78 00:04:53,950 --> 00:04:57,480 They're the commands we ask the computer to complete. 79 00:04:57,480 --> 00:05:02,620 A function can be as simple as adding two numbers together, and giving you a result. 80 00:05:02,620 --> 00:05:06,400 Or it could be as complex as adding information to a database. 81 00:05:06,400 --> 00:05:10,350 In the next video, I'll introduce you to functions, as we build out our game