© 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_10

10. Functions

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

You can attach a script to any item in Godot to make it interactive. To avoid creating one massive script of code, it’s better to divide a large program into smaller ones that work together. Such small programs that make up a larger program are called functions.

Ideally, a function should perform one task and take up no more than one page or screen. By keeping a function small, it’s easy to understand how it works. Large amounts of code can be difficult to search to find errors. ...

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.