© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2023
B. TyersGameMaker Fundamentalshttps://doi.org/10.1007/978-1-4842-8713-2_21

21. Arrays

Ben Tyers1  
(1)
Worthing, West Sussex, UK
 
Arrays are an ideal way to store organized data, such as:
  • Keeping track of player’s weapons, whether available, and how many they have

  • Storing names and associated data, like height or birthday

Arrays can hold an assortment of data and is not limited to variables. You can store sprite names, sounds, instance ids, and more.

Array Example

An example of 1-dimensional array, holding the names of some planets:
planet[0]= "Mercury";
planet[1]= "Venus";
planet[2]= "Earth";
planet[3]= "Mars";
planet[4]= "Jupiter";
planet[5]= "Saturn";
planet[6]= "Uranus"; ...

Get GameMaker Fundamentals: Learn GML Programming to Start Making Amazing Games 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.