The Running of the Bools

9/6/2017

Agenda

  1. Review boolean values and blocks
  2. Cat bath warm up / review
  3. Break from coding with Puzzles
  4. Create boolean program
  5. Look ahead to Project 2
  6. Finish Katie K.'s Lab from Yesterday
  7. **CHALLENGE**


The game of Guess Who is played by asking a series of Yes/No questions determine who your opponent's hidden character is. What sorts of questions can you ask your Sprite? What values do you know about your Sprites? What are the blocks called that store these values (what shape are they)?

Boolean Review

What shape are Booleans?

What two values can a Boolean be?

Boolean Warm Up

Cats hate baths = TRUE

***** This is a hat block

Boolean blocks serve as answers to yes or no questions.

Questions like is the x position of my sprite greater than zero? Is the y value of one sprite higher than the y sprite of another? Is a button being pressed?

Right now I want you to practice detecting if two sprites are touching (Is sprite one touching sprite two? (yes/no))

For this assignment:

  • Create a sprite that starts with the normal looking cat
  • Create a sprite that uses the bath tub costume
  • Using hat blocks**** and boolean blocks, have the cat change to the panicked cat when it touches the bath tub (You can drag the cat to the bath tub, no need to make it move with button presses)
  • Once you have the cat appropriately changing when it touches the bath tub, have it change costume to the original cat when it is NOT touching the bath tub
  • For additional debugging try making the cat always say the value of the boolean block you are testing. (Drag the boolean hexagon into the say block and have the cat say that value forever)

Mini Bool Review

The previous assignment had you detecting boolean conditions by themselves. Booleans can be combined so that multiple conditions are checked. This can be done through boolean operators (AND, OR). In a notebook or digital notepad answer the questions in the following paragraphs:

Consider the statement "if there is snow or a holiday, school is cancelled". What conditions need to be true for school to be cancelled? Do they both need to be true for school to be cancelled? What if they are both true, would school still be cancelled?

How about the statement "you can't wear white after labor day" what two conditions both need to be met to break this fashion rule. How would you word a question using the boolean operator AND that determines if someone is breaking this rule? Is someone breaking this fashion rule if they are only meeting one of the requirements?

Complicated Kitten

To complicate your cat further we want it to be scared of more things. We will be introducing complexity to this feline by adding a boolean operator to your code. Please follow the below requirements:

  • Introduce an OR block to your code so that the cat panics when it is close to something else it doesn't like OR it is touching the bath.

Pay attention that I did not choose the word touching for the new sprite. Try to find another boolean block other than the touching block.

We have completed assignments already that have sprites decorated to something a cat would dislike but feel free to use whatever costume you'd like here.

You will know you are finished when the cat panics when it is touching the bath AND it panics when it is close to something else it does not like.

** [optional fun] if you want to be real obnoxious throw a cat hissing sound in there when it panics

Take a coding break with some puzzles

Playing Guess Who

Follow the link to the left.

In it there is a Guess Who game that uses "fake" code to help you play along.

Run these fake programs by following the instructions and clicking the cards when you are instructed to flip them down.

At the end of each exercise you should be left with one card that is the solution to each Guess Who puzzle. Write your answers alongside your answers from the previous bool review.

.... and now back to coding ......

When Mario <Is Revisited>

Knowing what you know now about boolean blocks and triggering activities based on those boolean values how could you change your Mario code so that Mario knows when he is touching the mushroom sprite?

This doesn't just apply to the Mario challenge. For your Nursery Rhyme Project you used timing (waits and moves) to trigger animations, how could you use Boolean expressions to ask your program about it's current values and make it more interactive so that you do not need to be calculating exact timing?

For this part of lab I want you to create a program or edit an existing program of yours (doesn't have to be Mario) such that it follows the below requirements:

  • (Changes a costume based off a boolean value changing) OR (There needs to be one costume for when a boolean block evaluates to true and one for when it evaluates to false)

That's it! Be creative and make something fun.

If you would like to do this with Mario go right ahead. If Mario is not your thing maybe you want to:

  • make a football player who spikes a football when they reach an end zone (when touching endzone sprite) OR
  • have a score increase when the player reaches a certain point (use your counter lab and evaluate sprite positions) OR
  • recreate gravity by having all sprites above a given y value slowly descend towards the ground (When Sprite.y > 0, change y so that it is closer to 0) OR
  • a runner that gets showered with confetti when they cross a finish line (sprite.x > finishLine.x) OR
  • a sprite that gets knocked over or flies off screen when it gets falcon punched OR
  • come up with something and make it your own OR
  • implement an idea discussed in class

AND no matter what you choose have fun with it. Pick something you find interesting and make it interactive.

**RUNNER CHALLENGE**

After today's lab you have enough tools in your toolbox to begin making complex, fun games. It may not seem like it but consider what you know and how to use your knowledge to create fun experiments.

Google Chrome comes packaged with a game you can play when there is no internet connection. By pressing the space bar you begin this "endless runner" game below:

This game can completely be built given tools we know. Break this program down into smaller problems and questions you know the answers to. When combined these answers are what make up larger, more complex games/programs.

  • How do you make the T-Rex constantly animate as if it were running?
  • How do you move cactus sprites towards the T-Rex?
  • What interactions are present?
  • What animation changes does the T-Rex do based on user input (keyboard key presses)?

When the user presses space bar the T-Rex changes his y position (positively) over time and eventually comes back down to his original y position (or in not so nerdy words, the T-Rex Jumps).

  • What boolean block and hat block could be used to make a sprite slowly return to it's original y (let's say 0 for simplicity) when it detects that it's current y is greater than that value (0)?
  • What block could be used to detect a T-Rex has moved to the right of a cactus?
  • What blocks could you use broadcast that a point was scored when the T-Rex jumps over a cactus?

How about the cactus interaction:

  • What blocks could be used to detect that the T-Rex has smacked a cactus?
  • What could be broadcast to signal the end of game?

If you breezed through everything today consider trying to implement an endless runner like the above game included in the Google Chrome browser.

There are many games on the mobile market that do not have logic any more complicated than this. Your ability to replicate this means you can begin creating games that already match professionally made games that exist on software marketplaces. Try your hand at matching the work of existing professional programmers and show off how far you've come since LightBot.

Looking ahead to Project 2

We will begin posting projects ahead of when we assign them so that you may review them and begin mentally planning them before they are officially on your calendar.

For anyone who finishes labs quickly this is a wonderful opportunity to grow your programming skills beyond the bare requirements of the project.

By planning ahead you can build out the parts that most interest you and ask questions of the teachers that help you do cooler and cooler things.

Your next Project will be creating a platform game and the project after that will be recreating the classic video game Pong. Visit the Projects link in the nav bar at the top of bhs.fun to review the requirements of your upcoming projects.

Lastly, remember

THERE IS ALWAYS MORE TO LEARN!