Practice

Quit Pygame

Create a pygame window (you don’t need to put anything on it). Close the pygame window when either the quit event occurs or the escape key is pressed.

💻 Template code

Solution code

Move Rectangle

Draw an object on the screen (a rectangle would suffice). Move the object up when either the W or up arrow key is pressed; right when either the D or right arrow is pressed; etc.

💻 Template code

Solution code

Previous Section

3.5 - Example

Next Section

3.7 - Conclusion

<aside> ⚖️ Copyright © 2021 Code 4 Tomorrow. All rights reserved. The code in this course is licensed under the MIT License.

If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact [email protected] for inquiries.

</aside>