Game Development Reference
In-Depth Information
Fig. 12.1
A lot of snow this year in the Swiss mountains
12.3 Snowflakes
In the beautiful Swiss mountains, it regularly snows (see Fig. 12.1 ). Obviously, the
game company in charge of developing the (slightly gory) first-person shooter game
'Sauerkraut Zombies' wants to display snow to the players as realistically as possi-
ble. In order to simulate snow falling from the sky, the lead game designer has de-
termined that there should be about 400-500 snowflakes visible on the screen. Since
the developer of this game has only read this topic up until the previous chapter, the
first version of the game has the following member variables (among others):
SnowFlake snowflake1, snowflake2, snowflake3, snowflake4, snowflake5, snowflake6,
snowflake7, snowflake8, snowflake9, snowflake10, snowflake11, snowflake12,
snowflake13, snowflake14, snowflake15, snowflake16, ...
Guess who was fired the next day? Of course, in this case it makes no sense at all
to try and declare hundreds of variables of the same type, all with more or less the
same behavior. For such kinds of cases, C# has something called Collections .
12.4 Collections of Objects
Instead of storing a separate member variable for each object, we can store an entire
collection of similar objects using one of the Collection classes. In order to use any
of the collection classes, an extra using -instruction is required:
Search WWH ::




Custom Search