4.
3 Reflection [90] Name: Period:
1. [20] When the user touches an ImageSprite, both the [Link] and [Link] events
are triggered. This is important for more complex games. For instance, suppose there are "good" and
"bad" sprites in your game. If you hit one, you earn a point. If you hit the other, you lose two points. If
you hit the Canvas and don't hit the ImageSprite, you lose 1 point. How would you code this?
You would code this using the when [Link] event handler still, along with using the
touchedAnySprite variable. You would use an if-then statement, checking whether or not the touch on the
canvas was also touching a sprite that is on that same canvas. Then if the player’s touch is on the canvas and
NOT on the sprite the score is subtracted by one, while if the player’s touch was both on the canvas and on
the sprite it would only add points, not subtract.
2. [10] How do you speed up the movement of the ImageSprite? What is the fastest it could move?
Speeding up the movement of the imageSprite requires the coder to change the clock speed and how often
it ticks. In our lights Off Project app, the clock is initially set to 1000 milliseconds. This is able to be changed
within the game by changing the clock interval. The fastest the imagesprite could move would be 0
milliseconds because time can not be negative and that is the lowest number we can go.
3. [10] Describe in general what the reset procedure does.
The reset procedure first changes both scores and misses variables back to 0, resetting scores and misses.
Then the procedure would display these new values with our text commands. Finally the reset procedure
makes sure that the clocks are enabled by setting timerEnabled blocks to true.
4. [20] Describe how the reset procedure contributes to the overall functionality of the program.
The player is able to restart their game if they want to. The reset procedure also allows for the player to
play again after the game initially ends by making sure that the scores are reset and the sprites are
moving again. This makes the game actually functional so that there is some choice within the game
rather than the options being hard coded.
5. [10] Complete the block question in MobileCSP section 4.3. Define a procedure named resetScore that
sets the global variable score to 100. Put your correct screenshot here.
6. [10] Complete the block question in MobileCSP section 4.3. Using the pre-defined global variables,
define a procedure named calculateHitRate that calculates the player's hit percentage, which is defined
as: hitRate = hits / (hits + misses). Put your correct screenshot here.
7. [10] Complete the block question in MobileCSP section 4.3. The updateScore procedure contains a bug.
It's supposed to calculate the hit rate and then display the hit rate in Label1. Find and fix the bug. Put
your correct screenshot here.