There's more...

You might wonder why we did not call after_idle() instead of after() to schedule the process_movements() method.

It might look a valid approach since there are no other events to process, apart from redrawing our canvas and handling keyboard inputs, so there is no need to add a delay between calls to process_movements() if there are no pending GUI events.

However, using after_idle would cause the item to move at a pace that will depend on the computer speed. This means that a fast system will call process_movements() more times in the same interval of time than a slower one, and this difference will be noticeable in the item speed.

By introducing a minimum fixed delay, we give a chance to machines with different capabilities to behave in a similar manner.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset