Level 4: Online Articles - IncrediCoders/Python1 GitHub Wiki
SideWinder added this page on June 6, 2026
Here are some more Online Articles that will help with Elif, Key Events, and Moving/Rotating Sprites. You can skip down to these sections on the page:
More About For Loops
-
Creating Game Loops in Pygame for Real-time Games - Python Lore - This article shows you that at the heart of any real-time game lies the concept of the game loop, an endlessly repeating sequence that manages the flow of the game.
-
Loops in Python - Geeks for Geeks - This article includes flow charts to explain how for and while loops work.
For Loop Videos
-
Learn Python for loops in 5 minutes! - Bro Code - This is a video showing how for loops work in Python
-
Python Tutorial for Beginners 7: Loops and Iterations - For/While Loops - Corey Schafer - This video describes the two basic types of loops in Python, while and for.
For Loop Examples
-
Python For Loops - W3Schools - This is a W3Schools page on for loops in Python. Here you will see examples of lists and how for loops can iterate through the list.
-
For Loops - Python.org - This is the official Python documentation for how for loops work.
-
How to Set Up the Game Loop in Python - Geeks for Geeks - In this example, we will see how to set up a game loop in Pygame.
-
How to create a game loop in Pygame for real-time updates in Python - Python FAQ - This article shows you how to build out a code sample that features a game loop.
-
Guessing Games with Random Numbers and Loops - Program Arcade Games - This example walks you through how to use for loops to program a guessing game.
More About Elif Statements
-
Python Elif - 365datascience.com - This site give an in depth description of the definition of elif as well as the different code commands for elif. It also provides coded examples using these code commands, as well as displaying the output of the program.
-
Python Elif Statement - tutorialgateway.org - This page goes into detail about the syntax of the elif statement. It describes what can be put after "elif" and it describes what happens when that event is true and false. It also provides coded examples using elif statements.
-
Python Elif Example - pythonexamples.org - This page gives a brief description of what elif is, as well as the syntax used and needed to write elif statements. Then, it gives coded examples using these code commands and describes the output of each program as well as alternate outputs when the code is changed.
-
Python If-Else - tutorialspoint.com - This site describes what elif code commands are and how they can be used. Then, it displays diagrams of the process of the elif statements, as well as coded examples that show the diagram being used in an actual program.
-
Python If, Elif, Else Statements - pythonforbeginners.com - This page gives a definition for elif statements, as well as describing how it is used with if and else statements. Then, it gives examples of all three of these statements used together in a coded example.
Elif Videos
-
Python 3: If Elif Else - sentdex - In this video, he describes what if and elif statements are, as well as if-else and elif statements. He also provides detailed coded examples in Python programs of these different statements, and describes what each of the commands mean and the output.
-
If Elif Else Statements in Python - Telusko - In this video, he gives a definition for If, Elif, and Else statements and how they are used in Python. Then, he gives coded examples of each of these different statements and describes what each command means.
-
If/Elif/Else Tutorial - TechWithTim - In this video, he describes how to use the if, elif and else keywords in python make decisions. He then provides written out coded examples of each of these three statements, describing what each of the steps mean in the overall program.
Elif Examples
-
Python Elif - w3schools.com - This page starts with a brief description of what an elif statement is. Then, it gives coded examples with varying amounts of lines, as well as the output of the program and a description of the different parts of the program, as well as the meaning of the output.
-
Python If-Else - tutorialspoint.com - This site describes what elif code commands are and how they can be used. Then, it displays diagrams of the process of the elif statements, as well as multiple coded examples that show the diagram being used in an actual program.
More About Key Events
-
Keyboard events - pythonhosted.org - This site gives you the different commands that are considered "key events" where a key is pressed. It also goes more in depth than the challenges for this course talking about modifiers and how they interact with key events.
-
Pygame.key - pygame.org - This site gives you a list of all the different pygame.key commands that can be used in Python. Then, after the list, it describes what pygame.key means and where it can and should be used in code. Then, there are examples of some of the ways that pygame.key can be used.
-
Keyboard Input Events - coderslegacy.com - This site gives an in depth description of the different aspects of a key being pressed and the code that can be used to make that command. It also gives examples of code for each of those aspects and how it looks written out.
-
Pygame Programming - nerdparadise.com - This site gives a description of a few of the key event commands, as well as a brief description about what they mean. Then, at the bottom there is an example of the key events described used in a code example as well as other key events.
-
Pygame: Event Handling - Geeks for Geeks - This article covers keyboard and mouse events.
Key Event Videos
-
Keyboard Event Binding - Codemy.com - In this video, he explains that binding allows us to grab keyboard and mouse events. Then, he shows how to do keyboard event binding using written out coded examples that he takes step by step and explains what each part means.
-
Python GUI Keyboard Events - BroCode - In this video, he gives a basic tutorial for Python key bind events using tkinter and also GUI. He then provides examples using tkinter of keyboard events, and describes what each of the steps of the process does to the overall program.
-
Python Keyboard Press and Events - TechWithTim - In this video, he uses turtle graphics to make statements for keyboard presses. He then describes that the turtle graphics module has built in functionality to listen to events and detect key presses and he shows examples of this in a Python program.
-
Python Detect Keypresses - CoderGautam - This video describes an easier way to detect key presses in Python. He also describes how to use the "keyboard" module, and provides examples of these different concepts in an actual written coded example using Python code.
Key Event Examples
-
Event-Driven Programming - Art of Problem Solving - This page provides a Turtle example for keyboard events.
-
How to handle events like key presses and mouse movement in Pygame in Python - Python FAQ - This page provides a few samples to walk you through some keyboard event scenarios using Pygame in Python.
-
How to get keyboard input in Pygame - Geeks for Geeks - This example helps you detect if a key is pressed.
More About Moving/Rotating Sprites
-
Rotating/Moving Sprite - stackoverflow.com - This pages answers a question about moving and rotating a sprite. The answer is a coded example using the code commands for moving and rotating a sprite. Make sure you look at the answer, and not the question, in the answer, each part is important for moving or rotating the sprite.
-
Python Sprite Moving - python-forum.io - This site gives a specific example of the coding commands used to write out a program that moves the sprite. Above the program, there is a brief description of what the code does, or the output of it, and also which parts specifically refer to moving and rotating the sprite.
-
Rotating a Sprite - daniweb.com - This site gives you a brief description of the code commands used to move and rotate a sprite. Then, there is a coded example of the different code commands that were described, making one large program that moves but more specifically focuses on rotating the sprite.
-
Moving Sprites in Python - csteach488.github.io - This page gives an in depth description on the different parts of moving and rotating sprites. It gives examples of written code examples in between definitions that describe each of the parts that were described in the previous definition.
-
Asteroids Game Python - realpython.com - This sites starts with a brief description of how to move and rotate a sprite. Then, it gives an example of a coded asteroid game. Not all of the lines are about moving and rotating the sprite, but read through it and see if you can pick out the lines that do relate to moving and rotating the sprite.
Moving/Rotating Sprites Videos
-
Move a Sprite - GiovanniPythno - IN this video, he provides several examples on how to move your sprite in Python. He describes both the directions and the angle commands that can be used, and provides written out coded examples of several of these commands and show what they do to the sprite.
-
Rotating Sprites - ClearCode - In this video, he mainly describes how to rotate and object or image in pygame. He then takes an image of Pikachu and uses both pygame.transform.rotate and pygame.transform.rotozoom to rotate it around its own center using those pygame functions.
-
Rotating Player Sprite - KidCanCode - In this video, he shows how to implement rotation for the player sprite, and also handle how this affects our wall collision code. He then shows coded examples of these concepts, showing step by step what certain commands do to the overall program.
-
Centering Images and Clean Rotation - DaFluffyPotato - In this video, he explains that centering is how you get clean rotations in pygame with the weird image resizing pygame does when you rotate an image. He says that in general, centering is useful for a bunch of stuff.
Moving/Rotating Sprites Examples
-
Pygame: Control Sprites - Geeks for Geeks - This detailed example shows you how to use your keyboard to move a sprite around the screen.
-
Pygame and rotation of a sprite - Stack Overflow - This example shows you how to rotate a sprite around the center of the image.
-
Rotating and moving a sprite in Pygame - Stack Overflow - This detailed example uses the pygame.math.Vector2 class.
More About States
-
Managing Game States and Screens in Pygame - Python Lore - In the realm of game development with Pygame, managing game states and screens is an important aspect of creating a cohesive and engaging experience for players. This article explains all the details!
-
State - Python: From None to AI - This article covers how the State design pattern is a behavioral design pattern that allows an object to change its behavior when its internal state changes.
State Videos
-
Python Tutorials: From SimpleGUI to Pygame with Game States - CodeSkool101 - This video covers game states and class inheritance.
-
Pygame Game States Tutorial: Creating an In-game Menu using States - CDcodes - In this video, we are going to create a flexible game state framework that will allow us to create an in-game menu using Pygame.
-
The State Pattern in Python - ArjanCodes - In this video, Arjan dives into the State Design Pattern in Python, a game-changer for managing state changes in object-oriented programming.
State Examples
-
How to manage game states and screens in Pygame in Python - Python FAQ - This example walks you through creating different states for a simple game.
-
Pygame how to handle states - Stack Overflow - This example shows you how to create two classes to use for the two states in a Connect 4 type of game.
-
State in Python - Refactoring-Guru - This example extracts state-related behaviors into separate state classes and forces the original object to delegate the work to an instance of these classes, instead of acting on its own.
Next Steps
Next, you can take on the two extra challenges to add to your Space Wars program and learn more! When you're done, you can move on to Level 5, the Creeper Chase!
Take the Challenges!
-
Challenge 1: In this challenge, you are going to write more code on the SpaceWars.py file!
-
Challenge 2: In this challenge, you are going to write code that will allow two players to play the Space Wars game together!
More Level 4 Resources
In addition to this Online Articles page and the instructions for our Level 4 challenges, we also have a Help Page, a Learning Quiz, an Unplugged Activity, and a Rewards article:
-
Level 4: Help - This page helps you complete the instructions in the book, in case you get stuck.
-
Level 4: Learning Quiz - I wrote some questions in case you want to quiz yourself about what you learned. Or you can teach others and quiz them!
-
Level 4: Unplugged Activity - I wrote this page with more details than what you saw in the book. In this game,
-
Level 4: Rewards - If you completed the Space Wars project that we talked about, then I set up this page to act as a reward. You can see some illustrations of me and learn more about who I am! You'll also find the **WHAT **Award digital download, to show off your accomplishment!
Level 5
After you're completely done with Level 4 (did you do the challenges?), then it's time to move on to Level 5! While you read through Level 5 in your book, you can check out the resources from Intelli-Scents, as she teaches you how to build the Creeper Chase program:
I hope you had fun learning about space wars!
-- SideWinder