Download presentation
Presentation is loading. Please wait.
1
Input Repeat until Concatenation
Lesson 4 Input Repeat until Concatenation
2
Recall… Variables Events Looks Use: store the value of something
Directly give a value to the variable Adding/subtracting a number from the value of the variable Events Looks
3
Recall… Control blocks Operators
4
Input (sensing) Ask a question and allow the user to input the answer
Input value stored
5
Repeat until (control)
Repeat the following commands until (something) is correct. E.g. You deposit $500 in a bank at an interest rate of 5% p.a. compounded yearly. You will take the money out when the amount is greater than $1000.
6
Concatenation join the words together
You need to use this when you want to join words stored in different variables/typed text. E.g. Name = Mary Compare the output of these two blocks: My name isMary My name is Mary.
7
Exercise 4 (開口中) How to play:
The player has to guess a number from 1 to 100. The range of guessing will be narrowed down based on the number guessed by the player. The game continues until the player guesses the number.
8
Exercise 4 Example: The secret number is 35.
The FLOWCHART of the program can be found in the pdf file. Example: The secret number is 35. (starting range: 1 – 100; lower bound=1, upper bound=100) 1st time: If the player guessed 50, then the player is asked to guess again from 1 to 50. (Guiding question: when the number guessed is greater than the secret number, is the lower bound/upper bound changed?) 2nd time: If the player guessed 20, then the player is asked to guess again from 20 to 50. (Guiding question: when the number guessed is less than the secret number, is the lower bound/upper bound changed?)
9
Exercise 4 Hint: asking the player to guess again between 2 numbers:
Your task: The computer randomly picks a number from 1 to 100. Then one sprite (grizz) will ask the player to guess the secret number. (Hey. Guess the secret number between 1 and 100.) Check if the number is correct or not. If not, ask the player to guess again from a correct range. Hint: asking the player to guess again between 2 numbers: Join “The secret number is between ” (lower bound) “ and ” (upper bound) “. Guess again!” Words to be typed: “xxx”; Variables: (xxx) The game continues until the player input the correct number.
10
Exercise 4 Features to be included:
You may need to use this: to stop the music playing when game ends. Features to be included: Background music (We Bare Bears-Intro HD.mp3) (stop music when the game ends) Change backdrop when starting a new game. Grizz (with costume “grizz”) moves front and back during the game. When the player got the correct answer, play drum roll (play drum 1) and then a crash cymbal (play drum 4). Change the costume of Grizz to “grizz_excited”, then say “You got it!” (add this block), and play “yeah”. [Hint: use broadcast]
11
Exercise 4 Bonus Features:
The other sprite (ice bear) represents the player, saying the answer input. Ice bear “thinks” while waiting for the input. If the player (ice bear) got the correct answer within 5 times, ice bear says “Ice bear meant to do that.” and play sound “meant to do that” at the same time. Grizz grumbles (play sound “grunt”) when the no. of trials is a multiple of 3. Replay button (must be on click) If the answer input is not within the range, Grizz should warn the player. (The no. of trials does not increase by 1.)
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.