This document discusses arrays and their use for efficiently storing multiple entities in a game. Arrays allow storing many objects of the same type. Each location in an array is called an element, and its number is called an index. Individual elements are accessed using the array name and index. Arrays can have any number of dimensions.
This document discusses arrays and their use for efficiently storing multiple entities in a game. Arrays allow storing many objects of the same type. Each location in an array is called an element, and its number is called an index. Individual elements are accessed using the array name and index. Arrays can have any number of dimensions.
In this module, were going to look at how we can efficiently store and use multiple entities in our game
In-Lecture Quiz
Arrays are
A: colorful B: weird C: green D: objects
What can we store in arrays? Anything! But A particular array can only store a single data type So we can have an array of i nt s and another array of TeddyBear s, but we cant mix them in a single array
In-Lecture Quiz
A single array can store many objects of
A: different types B: the same type C: glass D: any weapon type In-Lecture Quiz
The value stored at each location in the array is called
A: Fred B: an element C: an index D: never, its texted instead In-Lecture Quiz
The number of each location in the array is called
A: Tommy B: an element C: an index D: okay, its not texted either In-Lecture Quiz
We access individual elements of an array using
A: the array name and an index B: the array name and a pinky C: the array name and a pixie D: Im a pixie; my name is Pinky In-Lecture Quiz
Arrays can have the following number of dimensions:
A: 0 B: 1 C: 42 D: as many as you want
Recap We discussed how we can use arrays to store multiple values All the elements in a particular array need to be the same data type Next Time Well look at another, more robust, way to store multiple values