We will be well on our way to present our games at the STEM fest with this homework! Please email Michael if you feel that you need help.
What I want you to get out of the assignment is that when you use glide you go from point A to pt B and you can’t effect the sprite as it glides. But if you use a loop and decrement the y position you can now put an if statement in the code. You already have all the code from the last class.
Please keep on working on your game for the STEM fest.
I have shared a project that you can use for the exercise. If you go to backdrops, you can find a background of an x-y axis. You might find this helpful.
1. Make an x and y axis on paper and plot the the following point (0,0), (1,1), (-3,-2), (5,-2)
Please use the shared link for the rest of the homework. The ball has two costumes: a blue and yellow costume.
2. In Scratch, make the ball go to (100,100) using the blue costume.
3. Now make the ball go from (100,100) to (100, -100) using the glide command.
4. Now, what if we want the costume to change from blue to yellow when the y value is between 50 and -50. If the ball is outside of 50 and -50, it should go back to blue. Can we do this using glide? Why not?
5. Instead of using glide you can use a loop to move the ball. How do we have the costume change as specified in part 4?
Below is a representation of how the ball color should be changing based on its height.
Blue —- change happens when y value is below 50
Blue —- change happens again when y value drops below -50
Next class we are going to be building structures in Minecraft. The code would look like something like this:
mc.setBlock(x, y, z, block_type)
So for example:
mc.setBlock(100, 200, 300, 3)
would mean to set a block at position:
block_type =3 —> dirt
I’d like you to write some code to print out numbers. In class I will show you how we can modify this code with very little extra code and build walls. It’s all about “for” loops.
Do a search on Google for “python for loop and nested for loops” if you want a refresher. There are tons of good videos. It’s a great habit to use Google to help you learn. I use it all the time.
A. write a program that will print out the following using a for loop:
B. Write a program that will print out the following using a nested for loop:
Please continue working on your game in Scratch. Come to class ready to present your game and talk about your code.
In class we went over how to write a function for our hangman game that will take a word as an input and then return a string with the correct number of underscores. For example
“banana” —-> “_ _ _ _ _ _ _ _”
Now write a function that takes 3 inputs. First_Name, Middle_Name, and Last Name and returns a string which is the initials.
Lets call the function “Initials”
Initials(“Michael”, “Zvi”, “Liebis”) —–> “MZL”
if you have a string
x = “Michael”
x is the first character or “M”
Test out this code:
s = sum(2,3)
As we discussed in class, be prepared at the next class to make a proposal for the group project. I want you to at least have some graphics (no code) in place so you can explain how the “game” will work.
Write a program that asked the user for a password (That only you know and have put into the code). If they get it correct it prints out “Welcome” otherwise it prints out “You do not have Access”