iDevGames Forums
Dictionary vs Class - Printable Version

+- iDevGames Forums (
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Dictionary vs Class (/thread-7351.html)

Dictionary vs Class - Justin Brimm - Feb 4, 2003 01:13 AM

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.

Dictionary vs Class - w_reade - Feb 4, 2003 07:13 AM

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.

Dictionary vs Class - GoodDoug - Feb 5, 2003 02:05 PM

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.

Dictionary vs Class - Justin Brimm - Feb 5, 2003 04:56 PM

How do I go about making a bundle and putting all the different stuff in it?