|
-
Jul 12th, 2006, 09:32 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [2005] Accessing one instance in many locations
I've got a problem that is very hard to explain. I'd appreciate it if anybody who reads this could perservere through this explaination to help (thanks in advance).
I've got a game with 10 levels. I have monsters in this game. Each monster has stats I need to store (eg strength, speed, hit points, etc) which requires about 8 integers and 4 singles.
The monster is a generic structure that can be adapted to be any monster in my game. I create instances of monster, give them names, and place them in the level's I want them. For example I could have 3 baddies on level 1, 7 baddies on level 2, and 4 baddies on level 4, as well as 5 bandits on level 2, 3 bandits on level 3, and 3 bandits on level 4. The baddies and bandits are all different instances of the monster structure.
To store them I created this array: arrayOfMonsters(levelNumber)(IDNumber). The levelNumber is the number of the level that instance of monster is on, and the IDNumber only used to differentiate different monsters on the same level (it doesn't store anything about what type of monster they are or anything).
I wanted the storage to be efficient, so I only use as much of the array as I need. I've tried to create a picture of the array from the above example:
arrayOfMonsters(level1) = {}
arrayOfMonsters(level2) = {baddie, baddie, bandit, baddie, bandit, bandit, bandit, bandit}
arrayOfMonsters(level3) = {bandit, bandit, bandit}
arrayOfMonsters(level4) = {bandit, baddie, baddie, bandit, bandit, baddie, baddie}
For the remaining levels, there are no monsters. This works great for that information, but now I need to add bosses as well. Bosses are just a different type of monster, except they can be on multiple levels. This means that a boss on the first three levels could be just one instance of a monster. The problem comes when trying to add the boss to my array. I need to be able to keep track of the fact that the boss is the same over many levels, but he can't be assumed to be at the same IDNumber on different levels because of how the others are stored (he could be the first monster on level 1, the 9th on level 2, and the 4th on level 3).
This leads to the two solutions I've thought of and my question. My solutions are 1) Create a new array just for bosses, 2) use pointers in the 1st, 9th, and 4th positions of levels 1, 2, and 3 respectively (from my example) that all point to the same boss monster. Unfortunately, pointers seem to be C++, not vb (I need to use VB.net 2005 for this project).
So my question is, can anybody think of a way of implementing one array with something resembling pointers (or otherwise) to store all that information, or should I just use a second array?
Thanks for the perseverence in reading this (and hopefully responding)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|