3.) A. The names of the two sprites are "cat" and "wall".
B. Only the cat has a script; it has one script.
4.) Pseudocode:
When Green Flag clicked
Set MOVE_INCREMENT to 5
Set direction to 1
forever
change x by direction * MOVE_INCREMENT
if touching wall then
set direction to -1
if x position < -239 then
set direction to 1
5.) A programmer would want to use a variable like MOVE_INCREMENT instead of just putting 5 in the relevant code because that way the result is consistent; even if the variable is not at the set speed of 5, it will still be able to perform the same function. You can change it around easily.
6.) The variable direction controls which way the sprite is moving. The value 1 means the sprite will go forward (to the right), and the value -1 means the sprite will go backward (to the left).
8.) When the direction is set to 0, the sprite does not move.
9.) The variable direction is best described as the "most recent" role because the most recent value is unpredictable as it is affected by the user input. All variables store the value most recently assigned to them.
10.)
11.)
13.) The new variable is the accumulator.
14.) The variable accumulator makes it so that every time you click the cat, the number of your x position is added to the number on the accumulator monitor.
15.) The purpose of the variable accumulator in this code is to add up each x position you click the cat on and to keep score of it for as long as you're playing.
17.) Sums up all the points in the current context. It is a running list.
Conclusion
1.) With a fixed variable, you only have to set it once and it will keep running throughout the program. You can also change the variable value easily and it adjusts everything accordingly.
2.) Move forward for 1s
Read the price from the next jar
Place the box back on the shelf
3A.) Calculators and games that show scores use an accumulator.
3B.) Games that show the score changes as you collect "points"- the game always remembers how many points you earned in one level so that it may be added to the points collected in the next level, and adding it on to the next level, and so on. The score (number of points you gain) accumulate.
4.) The accumulator is a running total, it adds up the points or inputs you give it; the aggregator is a running list, it remembers every input it is given (and displays them as individuals- they are separate from each other).
No comments:
Post a Comment