Following with the previous issue of Shot the Bull’s-eye in ecode (I), we would continue programming and enable it to achieve shooting and scoring functions. The principle is very simple, let’s do it together now! First, we need to add a code to the arrow and launch the arrow when the space bar is pressed.
When the space bar is pressed, another script is stopped (the script that moves the crosshair).
Game effect demonstration:
Test your program again. This time the crosshair should stop moving when the space bar is pressed.
Add some animation to the crosshair to make it look like it is constantly moving towards the target.
Test your game again. Now when you press the space bar, you should see the crosshair keeps getting smaller, as if it is moving towards the target.
Once the arrow hits the target, you can tell the player how many points they scored. For example, if you hit the blue bullseye, you can get 60 points.
Finally, we add the score of the corresponding color area, when you hit the different color area of the bullseye, you will get a score. At the end, we need to broadcast the new arrow message again to get a new arrow. In this way, arrows can be fired continuously to get different scores.
I can get up to 100 points. Come and test how many points you can get?
If you have any ideas or opinions, please feel free to contact us via [email protected].