Loading Levels from Files
Autor: | Jeroen D. Fokker, Mark H. Overmars, Arjan Egges |
---|---|
Rok vydání: | 2019 |
Předmět: | |
Zdroj: | Learning C# by Programming Games ISBN: 9783662592519 Learning C# by Programming Games ISBN: 9783642365799 |
DOI: | 10.1007/978-3-662-59252-6_19 |
Popis: | Many games consist of different levels. Especially in casual games such as puzzles and maze games, the game may have several hundreds of levels. With the programming tools that we have seen thus far, we could add different levels to our game by, for example, writing a generic Level class, and then defining (hundreds of) subclasses, where each class defines what the particular level looks like. A much better approach, however, would be to store the different levels in a text file, and then read the information from this text file to create the levels. Then, if we want to add another level to our game, we do not have to change the source code but we can simply edit the text file. In this chapter, we will see how we can load levels from a text file using the C# file I/O classes. As an example, we will show how to create a tile-based game world based on information saved in a text file. |
Databáze: | OpenAIRE |
Externí odkaz: |