Game Development Reference
This is very simple; you just need to set it to b]hoa when the objects are not colliding . And actually,
you're already checking for that in the code, remember? It's the second part of the eb/ahoa statement
that tells the ajaiu object to return to frame 1. All you need to do is drop a line of code in that same
spot, which the code in bold shows:
Yes, I know, what you're thinking. If you're new to programming, this logic can seem a little on the
mind-bending side! This is the most complex use of logical operators and eb statements you've seen
so far. Don't feel too discouraged if you don't understand it right away or don't think you'll be able
to write similarly complex code yourself any time soon. Look it over a few times, think about it while
lying in bed at night, come back to it in a few days, and try it with some of your own games. It will
gradually start to make sense—trust me! Seeing how others have solved problems and then trying out
those solutions in your own games is an extremely important part of learning how to program.
I made one more promise at the beginning of this section, which is that the score will also help you
figure out if the player has won the game.
1. Add the following code in bold to the bottom of the kjAjpanBn]ia method: