Thursday 7 February 2013

Improving Scratch Programs

We worked some more on our 'Bee_Sting' project and made some improvements. Using the 'Point towards' block I added large googly eyes onto the Cat that watched the Bee wherever it moved . The eyes stayed at one point while watching though, so I had to program the eyes to move with the arrows so that they stay on the Cat. I then also had to program the eyes to go to two different coordinates so that when the green flag was clicked the eyes don't get left behind. The eyes still looked a little bit weird on top of the Cat's original eyes. I fixed this by painting over the Cat's main costume and making the eyes orange to match the Cat's fur, so that they look invisible. The googly eyes then looked better.
I then wanted the Cat's eyes to go red and pop off when the Cat was stung. I could not say 'If touching' as then the eyes would not always change, and only one eye would if in contact with the Bee. I accomplished this task by using messages. These are similar to variables, and have an On or Off state. I used the block 'Broadcast Sting' and told the eyes 'When receive Sting...'. When the eyes saw that the message 'Sting' was broadcasting  or set to On, the eyes performed code telling them to change costume and fly to certain coordinates in the corners.
I also fixed a bug where the Bee kept moving upside-down after it dies.
I found it quite easy, but I could improve it by making the eyes fly off faster, as they wait for one second and then fly off.