Scratching the Surface of Programing 2

Embed Size (px)

Citation preview

  • 8/3/2019 Scratching the Surface of Programing 2

    1/22

  • 8/3/2019 Scratching the Surface of Programing 2

    2/22

    Big Picture: An Overarching Question

    Why Is It Important to Teach This Topic?

    How does it relate to the real world?

    Essential Questions

    How can we use program a computer to produce the desired

    outcome

    Or

    How can technology (computer programming) and problem-

    solving be combined to create new solutions to complex

    problems?

    Two or Three CCL Performance Skills

    Problem Solving

    Systems Thinking

    Performance Task (Final Project)

    The students will create a computer game or program that

    successfully challenges and interacts with the user.

    KNOW, UNDERSTAND and DO

    Know Program language and how it can communicate

    with a machine.

    Understand How can technology (computer

    programming) and problem-solving be combined to

    create new solutions to complex problems?

    Complex systems must interact and work together

    to produce an outcome.Changes within a system affect its ability to produce the

    desired outcome.

    Do The students will create a functional video game to

    entertain and challenge the user.

  • 8/3/2019 Scratching the Surface of Programing 2

    3/22

    Scratch and 21st Century Skills

    Information & Communication Skills

    Information and Media Literacy Skills

    By working on Scratch projects, students learn to select, create, and manage multiple forms of media,

    including text, images, animation, and audio recordings. As students gain experience creating with media,

    they become more perceptive and critical in analyzing the media they see in the world around them.

    Communication Skills

    Effective communication in todays world requires more than the ability to read and write text. Scratch

    engages young people in choosing, manipulating, and integrating a variety of media in order to expressthemselves creatively and persuasively.

    Thinking and Problem-Solving Skills

    Critical Thinking and Systems Thinking

    As they learn to program in Scratch, young people become engaged in critical reasoning and systems

    thinking. In order to build projects, students need to coordinate the timing and interactions between

    multiple sprites (programmable moving objects). The ability to program interactive input provides

    students direct experience with sensing, feedback, and other fundamental systems concepts.Problem Identification, Formulation & Solution

    Scratch supports problem finding and solving in a meaningful design context. Creating a Scratch project

    requires thinking of an idea, then figuring out how to break the problem into steps and implement them

    using Scratch programming blocks. Scratch is designed to be tinkerable: students can dynamicallychange pieces of code and immediately see the results (e.g., doubling a number to see how it changes a

    graphic effect). Throughout the design process, students engage in experimenting and iterative problem-

    solving.Creativity and Intellectual Curiosity

    Scratch encourages creative thinking, an increasingly important skill in todays rapidly changing world.

    Scratch involves young people in seeking innovative solutions to unexpected problemsnot just learning

    how to solve a predefined problem, but being prepared to come up with new solutions as new challenges

    arise.

    Interpersonal & Self-Directional Skills

    Interpersonal and Collaborative Skills

    Because Scratch programs are built of graphical blocks, the programming code is more readable and

    shareable than other programming languages. The visual objects and modular code supports collaboration,

    enabling students to work together on projects and exchange objects and code.Self-Direction

    Taking an idea and figuring out how to program it in Scratch requires persistence and practice. When

    young people work on project ideas they find personally meaningful, their ideas provide internal motivation

    for overcoming challenges and frustrations encountered in the design and problem-solving process.Accountability and Adaptability

    When students create Scratch projects, they have an audience in mind, and need to think about how other

    people will react and respond to their projects. Since Scratch projects are easy to change and revise,students can modify their projects based on feedback from others.Social Responsibility

    Because Scratch programs are shareable, students can use Scratch to provoke discussion of important issues

    with other members of their immediate learning environment, as well as with the wider international

    Scratch community.

    http://llk.media.mit.edu

  • 8/3/2019 Scratching the Surface of Programing 2

    4/22

    Scratching the Surface of Software Programing

    Rational PurposeHave you ever played a video game or used software and wondered how it works. What

    do programmers do behind the scenes to cause icons and sprites to move around the

    screen or perform some action. In this class you will lean this by becoming a programmerand solving the complex system of problems that is required for a game or program to

    function.

  • 8/3/2019 Scratching the Surface of Programing 2

    5/22

  • 8/3/2019 Scratching the Surface of Programing 2

    6/22

    Weekly Overview

    1 Background and

    (program) Overview1. Programming

    Language

    Timeline2. Video Game

    Timeline

    K: How is software used to control the actions of machines.

    U: How can technology (computer programming) and problem-solving be combined to create new solutions to complex

    problems?

    Do: Students will describe some of the similarities anddifferences between various programming languages and

    programs.

    Level 2-

    DescribeCause/Effect

    2 Event Handling User

    input and Control

    K: Students will know how user input is processed and how it is

    important to a program.U: Complex systems must interact and work together to

    produce an outcome.Do: Students will create a program that has a user controlled

    sprite.

    Level 4-Analyze &Synthesize

    3 Random Numbers and

    iteration (looping)

    Department Meetings

    K: Random numbers are an important part of the programming

    process.

    U: Changes within a system affect its ability to produce thedesired outcome.Do: Create a program that uses random numbers to control the

    movement of a sprite.

    Level 3 & 4-Apply, Analyze,

    & Synthesize

    4 Conditional Statements

    and Boolean Logic

    K: Conditional statements are the key to having a program be

    responsive to the users actions.U: Changes within a system affect its ability to produce the

    desired outcome.Do: Students will create a program where a script is activated bythe user meeting a certain condition.

    Level 4-

    Apply &Synthesize

    5 Variables and arrays

    Department Meetings

    K: Variables and arrays allow the computer to store informationthat may be useful in the program.U: Complex systems must interact and work together to produce

    an outcome.Do: Students will create a program that uses a variable to storeinformation that is important to the program.

    Level 4-

    Conduct a Project,Analyze, &Synthesize

    6 Broadcast and ReceiveMessages

    K: Sometimes it is useful for one part of a program to send amessage to another part of the program.U: Complex systems must interact and work together to produce

    an outcome.Do: Students will create a program that has a broadcast message

    that is received and responded to by at least one other part of theprogram.

    Level 4-

    Conduct a Project,Analyze, &Synthesize

    7 Final Project K: By combining multiple solutions a complete program can becreated.U: How can technology (computer programming) and problem-solving be combined to create new solutions to complex

    problems?Do:

    Level 4-

    Conduct a Project,

    Analyze, &Synthesize

    8 Debugging

    Department Meetings

    K: Testing out software (Debugging) is an important part of theprogramming process.U: Changes within a system affect its ability to produce thedesired outcome.

    Do: Students will run their programs and check for problemsand glitches, then adjust the program to fix any discovered

    problems.

    Level 4-Conduct a Project,

    Analyze, &Synthesize

  • 8/3/2019 Scratching the Surface of Programing 2

    7/22

    Week 1

    Overview

    Vocabulary

    Technology/ Materials

    Computer

    Scratch Program

    Lesson Tutorial on SMART Board

    History of video gamest from website

    http://www.pbs.org/kcts/videogamerevolution/about/index.html

    Overview of Scratch

    http://www.pbs.org/kcts/videogamerevolution/about/index.htmlhttp://www.pbs.org/kcts/videogamerevolution/about/index.html
  • 8/3/2019 Scratching the Surface of Programing 2

    8/22

    The origin of video games lies in early cathode ray tube-based

    missile defense systems in the late 1940s. These programs were

    later adapted into other simple games during the 1950s. By thelate 1950s and through the 1960s, more computer games were

    developed (mostly on mainframe computers), gradually

    increasing in sophistication and complexity.

    Following this period, video games diverged into different

    platforms:

    Arcade

    Mainframe

    Console

    Personal computer

    Handheld games

    The first commercially viable video game was Computer Space in 1971, which laid thefoundation for a new entertainment industry in the late 1970s within the United States,

    Japan, and Europe. arly on. Currently only Japanese companies have any major

    successful handheld gaming consoles, although in recent years handheld games have

    come to devices like cellphones and PDAs as technology continues to converge.

    Tennis for Two on

    cathode ray tube

    TRS-80, Early

    Personal Computer

  • 8/3/2019 Scratching the Surface of Programing 2

    9/22

    Week 2 Event Handling

    Vocabulary

    Technology/ Materials

    Computer

    Scratch Program

    Lesson Tutorial on SMART Board

    Introduction

    Most programs and games require some kind of user interaction. This could be through a

    mouse, keyboard or a controller of some kind. The program has to be told what user input

    to respond to and what to ignore, as well as what to do with the input data.

    In this example the event is a key press that you assign. You then create the program or

    actions that should occur as a result of this user created event.

    There are other events as well Such as:

    This event represents when the program is run.

    This event occurs when the user clicks an object.

    Daily Project:

    The project assignment for today is to create a program where the user controls an object

    using the keyboard.1. Look at the Monkey example. Demonstrate how the sprite can be moved around

    the screen with the arrow keys.

  • 8/3/2019 Scratching the Surface of Programing 2

    10/22

    2. Stop the program and look at the scripts that cause this to happen.

    3. Notice how four different scripts have to be created to give the player full control.4. Students should now choose or create a sprite and create the scripts that will

    control it.

    Extension:1. What things could be altered in these scripts?

    2. What do you think would happen if they were changed?

    Challenge:

    1. Create additional keyboard controls that cause the sprite to perform other actions.

    2. Create controls that require the user to click on something or use the mouse in

    some way.

  • 8/3/2019 Scratching the Surface of Programing 2

    11/22

    Week 3 Random Numbers and Iteration (Looping)

    Vocabulary

    Technology/ Materials

    Computer

    Scratch Program

    Lesson Tutorial on SMART Board

    Introduction

    Random Numbers

    In computer programs, games in particular, random numbers can be useful in many ways.

    They can be used in a similar way that dice or a spinner would be used in a board game.

    They can also be used to give random movement to a sprite, such as an enemy.

    This is the random number function.

    The range can be changed by altering the numbers, including negative numbers. The

    computer will choose a random integer.

    Looping

    Forever and repeat can be used to repeat a set of actions a certain number of times, or

    forever.

    Daily Project

    Todays project will combine random numbers and looping to give random movement to

    the banana sprite.

    Look at our example project named Random Movement Look at the script of the

    banana sprite.

  • 8/3/2019 Scratching the Surface of Programing 2

    12/22

    1. The top of the script begins with a green flag control, rather than a keyboard

    control, because this sprite will not be controlled by user input. When you use

    the green flag control you are telling the script to run when the program starts.2. The next control is a forever loop. The reason this is important is because you

    want this action to continue the entire time the program is running. That may

    seem obvious, but it can be easily forgotten as a script becomes morecomplex.

    3. The next few scripts control the motion on the x coordinates (horizontal) and

    the y coordinates (vertical). They also utilize the random number function. Inthis case we have the random number limited between 1 and 10. Why?

    Because the sprite may move more erratically, given a larger parameter.

    4. Notice there is also a wait between the tow motion scripts. This is there to

    slow down the movement.5. Students should now choose or create a sprite and create the scripts that will

    control it randomly.

    Extension:1. What things could be altered in these scripts?

    2. What do you think would happen if they were changed?

    Challenge:

    1. Create additional sprites that move at different speeds.

    2. Create a sprite that moves back an forth along a set path

  • 8/3/2019 Scratching the Surface of Programing 2

    13/22

    Week 4 Conditional Statements and Boolean Logic

    Vocabulary

    Technology/ Materials

    Computer

    Scratch Program

    Lesson Tutorial on SMART Board

    Introduction

    Conditional Statements

    If and If else check for a condition if that condition

    is met the commands inside are executed.. This is often

    useful to check and see if an enemy or object is inproximity.

    Boolean Logic

    Extension:1. What things could be altered in these scripts?2. What do you think would happen if they were changed?

    Challenge:1. Create additional sprites that are worth different amounts of points.

    2. Create a list instead of a variable and require the player to collect each of the

    items on the list.

  • 8/3/2019 Scratching the Surface of Programing 2

    14/22

    Week 5 Variables and arrays

    Vocabulary

    Technology/ Materials

    Computer

    Scratch Program

    Lesson Tutorial on SMART Board

    Introduction

    Variables and Arrays

    The variable blocks allow you to create variables and

    use them in a program. The variables can store

    numbers or strings. Scratch supports both global andobject-specific variables.

    In the case of game programming, a variable is often

    useful in storing the score or the health of the player

    or enemy character.

    The array or list blocks allow for storing and

    accessing a list of numbers and strings. Thiskind of data structure can be considered a

    dynamic array.

    This can be useful to have a character collect alist of items in the game such as a list of food

    items.

    Daily Project

    Todays project will use a variable to store the score for the monkey. Before you can usea variable you have to declare it. Choose make a variable and name it score. Check the

  • 8/3/2019 Scratching the Surface of Programing 2

    15/22

    box next to it to have it appear on screen. Sometimes you may create a variable that is not

    displayed, but displaying the score is essential.

    Lets look at each step of the script and what it does:

    1. At the beginning of the script the score variable is reset to zero to make sure that

    the score doesnt keep adding up each time the game starts out.2. Next there is a forever loop to ensure that the condition is constantly checked for.

    3. When the condition is met the banana is hidden, the score is increased by one, and

    the banana is sent to a random spot on the screen and then shown.4. Now try following these steps to add a scoring system to your game.

    5. Bug test your game by playing it for a while. What happens to the score if you

    keep playing? It just keeps going up and up, the game never ends. Next week we

    will look at a way to create an ending for your game.

    Extension:

    3. What things could be altered in these scripts?

    4. What do you think would happen if they were changed?

    Challenge:3. Create additional sprites that are worth different amounts of points.

    4. Create a list instead of a variable and require the player to collect each of the

    items on the list.

  • 8/3/2019 Scratching the Surface of Programing 2

    16/22

    Week 5

    Broadcast and receive messages

    Vocabulary

    Technology/ Materials

    Computer

    Scratch Program

    Lesson Tutorial on SMART Board

    Introduction

    Broadcast and when I receive can coordinate the actions of multiple sprites. Using

    broadcast and wait allows synchronization.

    The script watches your score variable and then

    uses a math operation. When the statementbecomes true the message is broadcast.

    Having a message broadcast alone will donothing, as far as you can see. The message is

    sent, but not received by anything.

    To make it work you also need to add the when

    I receive control. When the message is

    received, the script is executed.

    Daily Project

    1. Open the example project and examine the scripts

    2. There is a new script for the monkey. Forever if Score > 9 broadcast win I used

    greater instead of equal, just in case the score skips past ten. The condition still

    will be met.

    3. I also created a new sprite to receive the win message. It starts off hidden at thebeginning of the game, and only shows when you reach the score that will send

    the win message.

    4. Try adding these techniques to your project.

  • 8/3/2019 Scratching the Surface of Programing 2

    17/22

    Extension:

    1. What things could be altered in these scripts?

    2. What do you think would happen if they were changed?

    Challenge:

    1. Use multiple messages for different events in your game.2. Have multiple things happen for an event, in sequence, or simutaneusly.

  • 8/3/2019 Scratching the Surface of Programing 2

    18/22

    These Scripts go on the

    sprite that is getting

    chased.

    These Scripts go on the

    sprite that you makechase the other with

    your mouse

    Choose 2 Sprites and name them. You are going to create a game of tag where the it

    sprite follows your mouse to catch the other sprite. When caught the other spritemakes a sound and runs to a new random location.

  • 8/3/2019 Scratching the Surface of Programing 2

    19/22

    Software Programming Project Criteria Sheet.

    Every program begins with a statement of the problem to be solved. The journey fromproblem statement to finished program usually involves the following activities:

    1. Define the problem. (What do you want your program to do?)I want to create a tag game where the players sprite is controlled by the mouse and the

    enemy character is programmed to chase you around. Whenever he catches you a soundis played, a message is broadcast, and the enemy goes to a new random location.

    2. Analyze the problem. (Often there are multiple ways to solve a problem which methodshould you choose and why?)

    I could control my character with the keyboard, but in this case, I thought the mouse

    would give more fluid control.For random movement I chose to point the sprite to arandom degree and then move. This makes it look like it is running around the screen

    rather than floating.

    3. Develop an algorithm (a method) for solving the problem.Create a sprite the player controls with the mouse

    Create a random moving enemy

    Create the effect that occurs when the enemy gets you.

    Write the computer program which implements the algorithm.

    5. Test and debug (find the errors in) the program. What errors and glitches were there inthe program? How did you fix them?

    Enemy is moving to fastTried lowering the move speed.

    6. Document the program. (Explain how the program works and how to use it).Use the mouse to control your character, which is a number 9. Try to avoid the enemy,

    which is a number 7. Will you succeed? Or will 6 be afraid of 7 because 7 ate 9.

  • 8/3/2019 Scratching the Surface of Programing 2

    20/22

  • 8/3/2019 Scratching the Surface of Programing 2

    21/22

    Software Programming Project Criteria Sheet.

    Every program begins with a statement of the problem to be solved. The journey fromproblem statement to finished program usually involves the following activities:

    1. Define the problem. (What do you want your program to do?)

    _______________________________________________________________________

    ______________________________________________________________________________________________________________________________________________

    _______________________________________________________________________

    ____

    2. Analyze the problem. (Often there are multiple ways to solve a problem which methodshould you choose and why?)

    _______________________________________________________________________

    ______________________________________________________________________________________________________________________________________________

    _______________________________________________________________________

    ____

    3. Develop an algorithm (a method) for solving the problem._______________________________________________________________________

    _______________________________________________________________________

    _______________________________________________________________________

    ___________________________________________________________________________

    Write the computer program which implements the algorithm.

    5. Test and debug (find the errors in) the program. What errors and glitches were there inthe program? How did you fix them?

    _______________________________________________________________________

    _______________________________________________________________________

    ______________________________________________________________________________________________________________________________________________

    ____

    6. Document the program. (Explain how the program works and how to use it).______________________________________________________________________________________________________________________________________________

    _______________________________________________________________________

    ___________________________________________________________________________

  • 8/3/2019 Scratching the Surface of Programing 2

    22/22