That certainly does the job, but as we've mentioned before, it's good coding style not to scatter the same number (when it means the same thing) all throughout your code. It makes it laborious and prone to error if you ever need to change it.
In the code below, I've made a variable which I've chosen to name quickness. It's set to 3, and then used for the velocity setting.
Now, to make the hero move more quickly, you only have to change the "3" in one place, and it's impossible to miss any.
It's good style for objects to know all about themselves. We'll do that in a later session.
|