Geeks With Blogs

News

Google My Blog

Catch me at: The List!


My InstallScript Utility Belt My Amazon Wishlist
My Standard Disclaimer


Archives
Chris G. Williams Beware: I mix tech and personal interests here.
I'm keeping to my original decision. I haven't looked at any game development stuff at all, with the exception of some late-night work on Heroic Adventure! (as I said I would.) 

For example, I haven't looked at the new XNA refresh, though if you would like to, it's being splashed across every mildly game dev related blog between here and Seattle. You should have no trouble finding it.

Most of my days lately, when not being threatened by crazed store owners, I have been studying my butt off for the new .NET 2.0 certs. I'm using a combination of books and Transcenders and I feel like it's going fairly well. Since I already have my MCSD.NET, I only need to take two upgrade exams.

Damn there's a lot of stuff in the upgrade exams. Between the flashcards and the practice exams, I've crammed so much stuff in my head it's about to explode.

So enough about that for now. I'm curious about something...

In Heroic Adventure!, I have an array where each cell contains information about the corresponding location on the map. One of the data items in the cell is Monster, which is an integer that corresponds to the index of an array of monster objects. As monsters move about the map, this value moves from cell to cell, and the Monster value of the previous cell is set back to 0. When a monster is killed, the object is removed from the array and the Monster value at that location is set to 0.

Having a separate Monster array makes some things easier, such as handling the Monster turn. I can loop through the Monsters and perform whatever actions, rather than going through every cell of the Map array to see if a monster is there.

So my question is, is this the "right" way to be doing this? Should I be sticking the Monster objects right into the map array, or doing it like I am now, where one array effectively points to the other?
Posted on Wednesday, April 25, 2007 12:34 AM General Interest | Back to top


Comments on this post: keeping my word

# re: keeping my word
Requesting Gravatar...
I would personally store the monster objects directly in the map cells. Just storing the indices sounds like premature optimization to me. I think there might be other ways to solve the "turn" issue. Even if you looped through every single item on the map and "updated" just the monsters, that should be fine until you can show that it's a performance problem.

Just my $0.02.
Left by Jason Olson on Apr 25, 2007 1:27 AM

# re: keeping my word
Requesting Gravatar...
You could store then monster object in both places - after all 'objects' are really only reference pointers.

Dim m1 As New Monster()
cell(0)(1).Monster = m1
monsterArray.Add(m1)

You can then access it via the monster array or via the cell property.
Left by Sam Judson on Apr 25, 2007 6:50 AM

# re: keeping my word
Requesting Gravatar...
I kept the information in both places, like Sam suggested, except that I kept a collection of monsters in each cell so I could support multiple monsters in a cell based on their size.
Left by Jay Miller on Apr 25, 2007 7:14 AM

Your comment:
 (will show your gravatar)


Copyright © Chris G. Williams | Powered by: GeeksWithBlogs.net