Dictionary vs Class
When it comes to doing things such as levels (main focus for now), what would be better to do? My current (yet unfinished) system of storing level data in a NSMutableDictionary and storing each dictionary in an array, or making each level into a class of it's own, and just creating new instances of that class when I call to create a new level?
The problem with storing all the levels as dictionaries though, is that I must maintain a way of keeping track of them and accessing them.
The problem with storing all the levels as dictionaries though, is that I must maintain a way of keeping track of them and accessing them.
What do you actually need to store about these levels? That's the first thing to decide.
Some games will need loads of specific data for every level - like an RPG storing a lot of tile-based maps - in which case a big solid lump of data that you can read straight into memory might be a good idea. Other games don't really need to know much about a level - MAFFia's levels were just single dictionaries, basically (stored in individual .plist files), as all I needed to load was: background; scenery (with positions); and a few numbers about how many and how fast the sheep would be.
The only advice I'd give is to make your levels separate files (one .plist/chunk of binary each), and that's pretty much just for simplicity's sake - it'll be much easier to change things around etc.
Some games will need loads of specific data for every level - like an RPG storing a lot of tile-based maps - in which case a big solid lump of data that you can read straight into memory might be a good idea. Other games don't really need to know much about a level - MAFFia's levels were just single dictionaries, basically (stored in individual .plist files), as all I needed to load was: background; scenery (with positions); and a few numbers about how many and how fast the sheep would be.
The only advice I'd give is to make your levels separate files (one .plist/chunk of binary each), and that's pretty much just for simplicity's sake - it'll be much easier to change things around etc.
I think you should store each level as a bundle... then you need can have a separate Dictionary stored in their as well as a subclass of your parent "Level" object that can implement different behaviors. I did this with Zed Nought, and even stored the Bosses for each level as bundles inside the level bundle.
How do I go about making a bundle and putting all the different stuff in it?
Possibly Related Threads...
Thread: | Author | Replies: | Views: | Last Post | |
Dictionary Checking for word games | avidgamer101 | 5 | 9,342 |
Jan 14, 2013 02:28 AM Last Post: avidgamer101 |
|
how to init and get a dictionary working | kensuguro | 4 | 6,422 |
Oct 2, 2005 02:33 PM Last Post: blobbo |