© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2024
W. Wang, T. WalcottProgramming for Game Designhttps://doi.org/10.1007/979-8-8688-0190-7_7

7. Looping Statements

Wallace Wang1   and Tonnetta Walcott2
(1)
San Diego, CA, USA
(2)
El Cajon, CA, USA
 

A loop repeats one or more commands multiple times. When you play a video game, the entire game represents a loop because as soon as you finish (or die in the game), the game gives you a chance to play again. That’s a loop. Within a game, you have smaller loops. Enemies may pop up and move in a predictable pattern, which represents a loop. Whenever a random enemy pops up, that is called spawning, and a program can run a loop to spawn more enemies. Fighting a single enemy ...

Get Programming for Game Design: A Hands-On Guide with Godot now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.