QUIZ! You can bring notes you took during class Any concept/topic we’ve covered may be up for grabs
HW #1 Read Chapter 1 of Blown to Bits
Review
LET’S REVIEW SOME THINGS What do we call the elements that make up the ‘grid’ that is the area our program is drawn in? What’s the size of the Stage? X: -240 to 240 Y: -180 to 180
LET’S REVIEW SOME THINGS What are the terms on the 3 tabs at the top of the main coding area? Scripts, Costumes, Sounds If I want to change the ‘look’ of a sprite what’s the easiest way? Change the costume What’s the easiest way to copy some code? Right-click and duplicate In what section is the ‘Wait’ command? Control What color is the ‘Sound’ section?
WHAT IS COMPUTER SCIENCE? Computing is a Creative Activity Abstraction reduces information and detail to facilitate focus on relevant topic Rocket launch - calls around to 10 different systems. Launch coordinator doesn't need to know the details about all of the subsystems. Data and information facilitate the creation of knowledge Algorithms are used to develop and express solutions to computational problems Programming enables problem solving, human expression, and creation of knowledge The Internet pervades modern computing Computing has global Impacts
Here’s what I might have said… Computer programming is about giving instructions to a computer Telling a computer what to do Computer programming is the art of creating something a computer interprets Computer programming is the what and how of what a computer does WHAT IS COMPUTER SCIENCE (CS) – PARTIAL ANSWER
Abstraction
ABSTRACTION Such a weird word…. Let’s see if we can figure it out What does abstract mean?
ABSTRACTION REVIEWED Let’s try some examples… How does a car work? Can you drive a car? How does a computer work? Can you use a computer? How is chocolate made? Can you eat it and enjoy it? How are your clothes made? Can you wear them?
ABSTRACTION So we can USE all those things, and yet we have no idea how they work In computer science, abstraction is the same thing The way in which code WORKS, doesn’t prevent you from using it…
ABSTRACTION How does move work for example? Something must be turning the pixels on and off from one area, to the next Do you know how? That’s abstraction The WAY in which move works, doesn’t mean you can’t use it!
ABSTRACTION So, abstraction means… The WAY something works, is separated from its ability to be used How a car works is abstracted from someone driving it In coding, all you see is move. Or repeat. Or change costume HOW each of those works is separate from them
ABSTRACTION The best example of us doing this, is making a block We hide the implementation. All someone sees (unless they choose to look harder) is say, ‘Draw Platforms’ If I read your code, that could tell me enough! I may be quite happy just seeing that The implementation of the code is kept separate from the usable part
Golden Code
GOLDEN CODE: WHAT IS IT? This is a term used in Computer Science… what does it mean? Golden code refers to code which is perfect or ideal This means you can take it as is and use in a project
GOLDEN CODE: WHAT IS IT? The code the teachers give you is nearly golden We could coin a new phrase? Silver code What this means is for your projects, pay attention, follow along, and save the code You will be able to use much of what we do as a group directly in your project
NEW TOPIC! SENSING We’ve done some of this already! If you made your Mario project have a goal, then the easiest way to detect the goal would be, if Mario touched the goal object
NEW TOPIC! SENSING Sensing is about determining … When one object is touching something else (or how far away it is from something else) Or A key is pressed Or The mouse is clicked Or Timing Or Noise Or The value of an attribute or object
NEW TOPIC! SENSING There’s 5 things that can be sensed 1.An object can sense if it is touching a color Really cool feature! But… Problematic! What if I make say a platform, but it’s multiple colors? What if the color I sense exists elsewhere in my program? Still useful, but caution urged Touching
NEW TOPIC! SENSING There’s 5 things that can be sensed 2. Any object can sense if one color is touching another color Very similar to ‘touching color’, but it detects when 2 colors collide caution urged Touching
NEW TOPIC! SENSING There’s 5 things that can be sensed 3. An object can sense if it is touching the edge Exceptionally limited Only one command supported: ‘bounce’ Notice, this is in the motion section, because of the ‘bounce’ But, a very cool, and useful way to say, let a ball bounce off the side of the screen (hint, hint) Touching
NEW TOPIC! SENSING There’s 5 things that can be sensed 4. An object can sense if it is touching another object This is the coolest command Allows one object to sense when it is touching another Then, it can react If I’m touching I win I die I get 50 points Most robust sensing command Touching
NEW TOPIC! SENSING There’s 5 things that can be sensed 5. An object can sense if it is near another object Useful if you want a sprite to change its behavior with proximity Handy, because otherwise you’d have to figure this out yourself Touching
NEW TOPIC! SENSING Hmmmm…. Can my app use all of these? Or 2 or 3 of them? Of course it can! Will this be useful in Pong? You bet it will! Are there any gotchas? always
NEW TOPIC! SENSING Let’s make something that bounces a ball around the screen
NEW TOPIC! SENSING Time to try it out yourself! Create a new project Change your sprites costume. Set its size Randomize your position, and direction Copy the sprite Change the costume of the second sprite When the first sprite touches the second make it ‘bounce’ Make a background with a specific color somewhere on it (like a ‘sun’) If either of your sprites hits that color, make them ‘bounce’ When either sprite hits anything else a total of times (such as 5). Use a variable per sprite! stop everything, and show a ‘game over’ screen
NEW TOPIC! SENSING Make a background with a specific color somewhere on it If either of your sprites hits that color, make them ‘bounce’ When either sprite hits anything else a total of times (such as 5) stop everything, and show a ‘game over’ screen
IF ON EDGE, BOUNCE
DIRECTION
VARIABLES
Used to store information Are by their nature temporary This differentiates them from databases or data stores such as files Have values that can change Hence their name! Differentiates them from ‘constants’, values that do NOT change (we won’t see those in Snap!)
VARIABLES So, what things might change in the real world, that we want to measure? I’ll give some examples…. Number of cars in a parking lot Number of points by the Seahawks in a game And their opponents! Number of clean socks I have left The current time (do I have to get up yet?) Amount of money in my bank account Number of Olympians in the Olympics
VARIABLES In pairs, YOU come up with some examples You have 4 minutes to come up with 5 examples in your pairs
VARIABLES SO why STORE that information? It allows us to remember what a value WAS How do I track the number of cars in a parking lot, without counting ? Well, when you count, you are effectively using a variable That way we can … Keep track of a value that’s changing Pass it around to other parts of the system And they can react to it if it changes! Show it to the user!
VARIABLES There are some existing variables for standard apps we’ve built! x position This is the position of the sprite it refers to y position direction costume # size give me some others!!! What does a variable look like in BYOB?
VARIABLES Game Ask the user 5 questions Then, ASK them what they answered to each of your questions If they type in the right answer say ‘correct’ Otherwise, say ‘wrong!’