3. Making it real
(This is a slight aside from the current topic of events, but very useful in understanding how to make your animations look more realistic.)
To answer the question on the previous page - an Alice turn left is not like a real car turning left. As you will have seen if you remove the car go forward instruction, an Alice turn left instruction just makes the car spin around its vertical axis. This doesn't look like any real car we've seen! Instead, real cars have to be moving forward with their front wheels turned and power going to their drive wheels in order for the car to turn left or right.
One of the challenges with computer graphics like those Alice uses is to make the movements look realistic. Our Alice model of a car is far simpler than a real car. For example, we can't steer the wheels, nor can we say "send power to the drive wheels now". Instead, we have to use the instructions we do have to make the movement look real.
By putting the turn left instruction (effectively a spin) together with a move forward instruction into a Do Together, we achieve this realistic look. The spin and the moving forward happening at the same time give us a pretty good end result.
We've used another features of Alice in this code to make the car movement look more realistic. Look in the code of the car go forward method, and take a look at the move instruction itself:
Notice the style = abruptly segment in the middle of the instruction. style is another of those extensions to the method call that are found under the more... button at the end of most instructions - just like the duration extension we used in an earlier chapter.
Now click on abruptly, and you'll see there are four options:
Set this now to gently, and then run the program again. If you hit the up arrow (go forward) a few times in quick succession, what do you see? Stop the program, change the style of the move instruction back to abruptly, run again, and do the same - hit the up arrow a few times in quick succession.
[Q6.3.1]:What difference did you see? If you didn't notice any difference - try that again!
The gently style makes movements start very slowly and speed up to the top speed, and then at the end of the movement, slow down to nothing gently. Using the abruptly style, objects immediately start moving at the top speed, and at the end of the move, stop instantly.
In general, real objects move with more of a gently style. They don't instantaneously start and stop. Instant starting and stopping looks too mechanical for realistic movement.
So why do we use abruptly in our car example? Well - if you want it to look as though you are driving the car somewhere, that will take many presses of the arrow keys - left, right and forward. Using gently, each single press would mean the car would speed up to top speed and then slow down again - if we'd pressed forward three times, that would look like a very uncomfortable stop-start ride! By using abruptly, we can't tell easily where the effect of one key press ends and the next starts, and so the motion looks much smoother and more realistic.