Goal: Define the driving with arrow keys behavior to control sprite acceleration, braking, turning, and wall collision.
Customize the driving behavior that lets the rider steer, speed up, reverse, and bounce off the edges.
- Open the driving with arrow keys with: this sprite behavior.
- Add an if up is pressed block with an inner if this sprite speed ≤ 6 block.
- Add a change this sprite speed by 0.25 block inside the inner if block.
- Add a move this sprite this sprite speed pixels forward block inside the up is pressed block.
- Add an else branch checking if this sprite speed > 0 and add a change this sprite speed by -1 block.
- Add an if down is pressed block.
- Set this sprite speed to 1 inside the down is pressed block.
- Add a move this sprite this sprite speed pixels backward block.
- Add an if left is pressed block.
- Add a change this sprite movement direction by -5 block.
- Add a change this sprite rotation by -5 block.
- Add an if right is pressed block.
- Add a change this sprite movement direction by 5 block.
- Add a change this sprite rotation by 5 block.
- Add an if this sprite is touching edges block.
- Add an edges block this sprite from moving block inside the condition.