All posts by Michael

Summer Week 1

This week we worked on scaffolding. How to go from an idea to some idea of what the components of the code for a program are going to be. I want us to think in terms of nouns and verbs.

Lets go over the Piggy Game:

Here are some nouns:

Player 1
Total score
Score for a round

Player 2
Total Score
Score For a Round

Die
The idea of a turn (this is an abstract object but is still a noun)

Here are some verbs:
pass
roll
update the total score
update the score for a turn
win

Now I want you to come up with the nouns and verbs for a video game you would build to draw a Jackson Pollack painting.

Week 2 – 1/17/15

We talked a bit about about using variables in Scratch.

We use the block: Set “variable_name” = value

For example set x = 5

We talked about how you can think about this as if there were a bucket that you place 5 in and then when you want to know what is in the bucket you use the variable x.

Now think about this and write the code in scratch. Test it!!!

set x = 5
set  y = x
say y

What prints out?
Now explain in words what is going on. Explain it with buckets etc….

Now write a program in Scratch that asks the user for a number between 1-10. Then it asks the user for a second number between 1-10. Then prints out “Same” if the two numbers are the same and “Different” if they are different.

Week 6-11/22

I am going to be posting a lot of code over next few day. The best thing to do is to try to understand how each program works before going on to the next one.  Feel free to email me for help.

A. See link :    http://scratch.mit.edu/projects/35818966/

Try to understand how the code works. Look at the yVolocity variable. See how it changes. Think about why I have a forever loop that is never going to terminate (exit).  Notice what happens when “key a” is pressed.  What happens when “key a” is pressed and then pressed again? Change the initialization of yVolocity from 10 to something else. See if you can write the code so the the butterfly does not go through the block (I will be posting that tomorrow so try to do it yourself before looking at answer).

B See link:   http://scratch.mit.edu/projects/35994486/

Start the game and then hit the key s.  I used “s” for stop. Try to understand how this works. Look at code from part A and see the changes I made to part B. (Hint: I replaced forever loops with repeat until loops, why?)

C See link http://scratch.mit.edu/projects/36065712/

Start the game and jump so that you hit the yellow block.  Notice the bytterfly bounces down. See if you can figure out how the changes to the code made that happen.

 

D: Notice in the code above when the butterfly jumps and hits its head on the block it bounces down. This is good but it then goes to low. Can you figure out how to make it stop falling so that it stops and is fully in the display?

 

More to follow in next few days

 

 

Week 5 – 11/15

Please used the link below to see the code that we worked on in class

http://scratch.mit.edu/projects/34657820/

 

Assignment:

1. Please work on adding new features to your game incorporating some of the ideas we worked on in class.  Some other ideas are to have a sprite’s costume change continually by putting it in a loop. You can also have its size increase and then decrease in a loop to create a nice visual. There are things you can come up with that I have not even thought of.  Be creative!!!! We will share our work at the beginning of next class.

2.  Start to think about how we can make a sprite jump onto a horizontal moving platform and then how to have the sprite move with the platform. Also how to make the sprite fall if it  does not land on the platform.

Week 4 11/8

Below is a link to the work we did in class

http://scratch.mit.edu/projects/33429694/

1. Change the initial value of step size different values. What happens?

2. Change the initial value of growth rate to different values. What happens?

3. Be creative. You can add lots of things to this game. Use your creativity!!!!!!

4. Look at other game online. Figure out what features you like. If not sure how to program then have link ready so we can look at together in class.

5. Have Fun!!!!!!!!!!!

Week 3 – 11/1

First off want to thank Maddie for the cool Halloween Program. Nice use of the for loop. If someone else wants to share work with the class please send the program to me first and then during break we can all look at it.

As always will post the assignment over the next few days

Problem 1:

Please look at the following link:

http://scratch.mit.edu/projects/32219774/

Notice I have a variable called doorEvent. Look at the code for the blue door, Then look at the code for the red door. Notice how door event is being updated. Now look at the code for the yellow door notice there is something missing. Add what needs to be added.

Problem 2:

A big part of coding is learning to figure out how someone else’s code works. Look at the code in the link below

http://scratch.mit.edu/projects/32278730/#editor

Figure out what is does. Figure out how to add it to problem 1 for our game.

A reminder of how the game works:

example 1:
Prize is behind Door A
Player Selects Door B
Then we need to open Door C

example 2:
Prize is behind Door C
Player Selects Door C
Then we need to open Door either A or B

 

Problem 3:

Given the code for problem 1 and problem 2 and some code that we worked on in class try to see if you can figure out how to make the correct door disappear (open) in our game.

Week 2 – Oct 25th

I will be adding problems over the next few days. I want the class to start working on little bits of code in scratch that will be related to the 3 door game we are going to code.

Feel free to email me with questions and I can probably get back to you by the following morning if not sooner.

Scratch Problems:

Problem 1: In Scratch, make a list with elements A,B,C . Then imagine that a player picked door A and the prize was behind door B. So which door gets opened? Now remove “A” from the list and remove “B” from the list.  Whats left?

Problem 2. In Scratch make a list with elements A,B,C . Then imagine that a player picked door A and the prize was behind door A. Now which door should be opened? Is there a choice? So remove element “A'” from the list.  What do you think is the next line of code?

Python Problems:

I made a post about using an online interpreter for python. Its pretty simple and will allow everyone to run code without dealing with installing etc. So once you get code to work save your code in another file, email or just write down on piece of paper.

Problem 1:

Go to link  http://www.compileonline.com/execute_python_online.php

In the upper right hand corner is an arrow labeled execute script. Click on this arrow. Do you see where it printed out “Hello World”

Congratulations,  You just ran your first python script!!!!!!! (If there were a fancy Nancy book on coding in Python, Nancy would explain that a script is just a fancy word for a a program or bit of code that you write in python)

Problem 2: Type in the code below

x = 2

if ( x > 9):

    print “yes”

else:

    print  “no”

Then run the script. What happened?

Now change the first line to:

x=10

Run the script. What happened?

Can you explain what is going on?